##// 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 111 def parentitem(self):
112 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
117 of the same type where there are no items of different types between
118 the current item and this closest item.
116 Try to return the next item closest to this item, regardless of item's
117 type (header, hunk, or hunkline).
119 118
120 If constrainLevel == False, then try to return the next item
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
119 If skipfolded == True, and the current item is folded, then the child
125 120 items that are hidden due to folding will be skipped when determining
126 121 the next item.
127 122
@@ -131,9 +126,7 b' class patchnode(object):'
131 126 itemfolded = self.folded
132 127 except AttributeError:
133 128 itemfolded = False
134 if constrainlevel:
135 return self.nextsibling()
136 elif skipfolded and itemfolded:
129 if skipfolded and itemfolded:
137 130 nextitem = self.nextsibling()
138 131 if nextitem is None:
139 132 try:
@@ -164,21 +157,13 b' class patchnode(object):'
164 157 except AttributeError: # parent and/or grandparent was None
165 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
170 of the same type where there are no items of different types between
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).
162 Try to return the previous item closest to this item, regardless of
163 item's type (header, hunk, or hunkline).
176 164
177 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 167 # try previous sibling's last child's last child,
183 168 # else try previous sibling's last child, else try previous sibling
184 169 prevsibling = self.prevsibling()
@@ -603,7 +588,7 b' class curseschunkselector(object):'
603 588 """
604 589 currentitem = self.currentselecteditem
605 590
606 nextitem = currentitem.previtem(constrainlevel=False)
591 nextitem = currentitem.previtem()
607 592
608 593 if nextitem is None:
609 594 # if no parent item (i.e. currentitem is the first header), then
@@ -619,8 +604,8 b' class curseschunkselector(object):'
619 604 parent-item of the currently selected item.
620 605 """
621 606 currentitem = self.currentselecteditem
622 nextitem = currentitem.previtem()
623 # if there's no previous item on this level, try choosing the parent
607 nextitem = currentitem.prevsibling()
608 # if there's no previous sibling, try choosing the parent
624 609 if nextitem is None:
625 610 nextitem = currentitem.parentitem()
626 611 if nextitem is None:
@@ -641,7 +626,7 b' class curseschunkselector(object):'
641 626 #self.startprintline += 1 #debug
642 627 currentitem = self.currentselecteditem
643 628
644 nextitem = currentitem.nextitem(constrainlevel=False)
629 nextitem = currentitem.nextitem()
645 630 # if there's no next item, keep the selection as-is
646 631 if nextitem is None:
647 632 nextitem = currentitem
@@ -655,17 +640,16 b' class curseschunkselector(object):'
655 640 same level as the parent item of the currently selected item.
656 641 """
657 642 currentitem = self.currentselecteditem
658 nextitem = currentitem.nextitem()
659 # if there's no next item on this level, try choosing the parent's
660 # nextitem.
643 nextitem = currentitem.nextsibling()
644 # if there's no next sibling, try choosing the parent's nextsibling
661 645 if nextitem is None:
662 646 try:
663 nextitem = currentitem.parentitem().nextitem()
647 nextitem = currentitem.parentitem().nextsibling()
664 648 except AttributeError:
665 # parentitem returned None, so nextitem() can't be called
649 # parentitem returned None, so nextsibling() can't be called
666 650 nextitem = None
667 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 653 nextitem = currentitem
670 654
671 655 self.currentselecteditem = nextitem
General Comments 0
You need to be logged in to leave comments. Login now