##// END OF EJS Templates
crecord: call prevsibling() and nextsibling() directly...
av6 -
r29130:ed2a3818 default
parent child Browse files
Show More
@@ -111,17 +111,12 b' class patchnode(object):'
111 def parentitem(self):
111 def parentitem(self):
112 raise NotImplementedError("method must be implemented by subclass")
112 raise NotImplementedError("method must be implemented by subclass")
113
113
114 def nextitem(self, constrainlevel=True, skipfolded=True):
114 def nextitem(self, skipfolded=True):
115 """
115 """
116 If constrainLevel == True, return the closest next item
116 Try to return the next item closest to this item, regardless of item's
117 of the same type where there are no items of different types between
117 type (header, hunk, or hunkline).
118 the current item and this closest item.
119
118
120 If constrainLevel == False, then try to return the next item
119 If skipfolded == True, and the current item is folded, then the child
121 closest to this item, regardless of item's type (header, hunk, or
122 HunkLine).
123
124 If skipFolded == True, and the current item is folded, then the child
125 items that are hidden due to folding will be skipped when determining
120 items that are hidden due to folding will be skipped when determining
126 the next item.
121 the next item.
127
122
@@ -131,9 +126,7 b' class patchnode(object):'
131 itemfolded = self.folded
126 itemfolded = self.folded
132 except AttributeError:
127 except AttributeError:
133 itemfolded = False
128 itemfolded = False
134 if constrainlevel:
129 if skipfolded and itemfolded:
135 return self.nextsibling()
136 elif skipfolded and itemfolded:
137 nextitem = self.nextsibling()
130 nextitem = self.nextsibling()
138 if nextitem is None:
131 if nextitem is None:
139 try:
132 try:
@@ -164,21 +157,13 b' class patchnode(object):'
164 except AttributeError: # parent and/or grandparent was None
157 except AttributeError: # parent and/or grandparent was None
165 return None
158 return None
166
159
167 def previtem(self, constrainlevel=True):
160 def previtem(self):
168 """
161 """
169 If constrainLevel == True, return the closest previous item
162 Try to return the previous item closest to this item, regardless of
170 of the same type where there are no items of different types between
163 item's type (header, hunk, or hunkline).
171 the current item and this closest item.
172
173 If constrainLevel == False, then try to return the previous item
174 closest to this item, regardless of item's type (header, hunk, or
175 HunkLine).
176
164
177 If it is not possible to get the previous item, return None.
165 If it is not possible to get the previous item, return None.
178 """
166 """
179 if constrainlevel:
180 return self.prevsibling()
181 else:
182 # try previous sibling's last child's last child,
167 # try previous sibling's last child's last child,
183 # else try previous sibling's last child, else try previous sibling
168 # else try previous sibling's last child, else try previous sibling
184 prevsibling = self.prevsibling()
169 prevsibling = self.prevsibling()
@@ -603,7 +588,7 b' class curseschunkselector(object):'
603 """
588 """
604 currentitem = self.currentselecteditem
589 currentitem = self.currentselecteditem
605
590
606 nextitem = currentitem.previtem(constrainlevel=False)
591 nextitem = currentitem.previtem()
607
592
608 if nextitem is None:
593 if nextitem is None:
609 # if no parent item (i.e. currentitem is the first header), then
594 # if no parent item (i.e. currentitem is the first header), then
@@ -619,8 +604,8 b' class curseschunkselector(object):'
619 parent-item of the currently selected item.
604 parent-item of the currently selected item.
620 """
605 """
621 currentitem = self.currentselecteditem
606 currentitem = self.currentselecteditem
622 nextitem = currentitem.previtem()
607 nextitem = currentitem.prevsibling()
623 # if there's no previous item on this level, try choosing the parent
608 # if there's no previous sibling, try choosing the parent
624 if nextitem is None:
609 if nextitem is None:
625 nextitem = currentitem.parentitem()
610 nextitem = currentitem.parentitem()
626 if nextitem is None:
611 if nextitem is None:
@@ -641,7 +626,7 b' class curseschunkselector(object):'
641 #self.startprintline += 1 #debug
626 #self.startprintline += 1 #debug
642 currentitem = self.currentselecteditem
627 currentitem = self.currentselecteditem
643
628
644 nextitem = currentitem.nextitem(constrainlevel=False)
629 nextitem = currentitem.nextitem()
645 # if there's no next item, keep the selection as-is
630 # if there's no next item, keep the selection as-is
646 if nextitem is None:
631 if nextitem is None:
647 nextitem = currentitem
632 nextitem = currentitem
@@ -655,17 +640,16 b' class curseschunkselector(object):'
655 same level as the parent item of the currently selected item.
640 same level as the parent item of the currently selected item.
656 """
641 """
657 currentitem = self.currentselecteditem
642 currentitem = self.currentselecteditem
658 nextitem = currentitem.nextitem()
643 nextitem = currentitem.nextsibling()
659 # if there's no next item on this level, try choosing the parent's
644 # if there's no next sibling, try choosing the parent's nextsibling
660 # nextitem.
661 if nextitem is None:
645 if nextitem is None:
662 try:
646 try:
663 nextitem = currentitem.parentitem().nextitem()
647 nextitem = currentitem.parentitem().nextsibling()
664 except AttributeError:
648 except AttributeError:
665 # parentitem returned None, so nextitem() can't be called
649 # parentitem returned None, so nextsibling() can't be called
666 nextitem = None
650 nextitem = None
667 if nextitem is None:
651 if nextitem is None:
668 # if no next item on parent-level, then no change...
652 # if parent has no next sibling, then no change...
669 nextitem = currentitem
653 nextitem = currentitem
670
654
671 self.currentselecteditem = nextitem
655 self.currentselecteditem = nextitem
General Comments 0
You need to be logged in to leave comments. Login now