606 uicolor = stringutil.parsebool(self.ui.config('ui', 'color')) |
606 uicolor = stringutil.parsebool(self.ui.config('ui', 'color')) |
607 self.usecolor = uicolor is not False |
607 self.usecolor = uicolor is not False |
608 |
608 |
609 # the currently selected header, hunk, or hunk-line |
609 # the currently selected header, hunk, or hunk-line |
610 self.currentselecteditem = self.headerlist[0] |
610 self.currentselecteditem = self.headerlist[0] |
|
611 self.lastapplieditem = None |
611 |
612 |
612 # updated when printing out patch-display -- the 'lines' here are the |
613 # updated when printing out patch-display -- the 'lines' here are the |
613 # line positions *in the pad*, not on the screen. |
614 # line positions *in the pad*, not on the screen. |
614 self.selecteditemstartline = 0 |
615 self.selecteditemstartline = 0 |
615 self.selecteditemendline = None |
616 self.selecteditemendline = None |
837 toggle the applied flag of the specified item. if no item is specified, |
838 toggle the applied flag of the specified item. if no item is specified, |
838 toggle the flag of the currently selected item. |
839 toggle the flag of the currently selected item. |
839 """ |
840 """ |
840 if item is None: |
841 if item is None: |
841 item = self.currentselecteditem |
842 item = self.currentselecteditem |
|
843 # Only set this when NOT using 'toggleall' |
|
844 self.lastapplieditem = item |
842 |
845 |
843 item.applied = not item.applied |
846 item.applied = not item.applied |
844 |
847 |
845 if isinstance(item, uiheader): |
848 if isinstance(item, uiheader): |
846 item.partial = False |
849 item.partial = False |
929 else: |
932 else: |
930 for item in self.headerlist: |
933 for item in self.headerlist: |
931 if not item.applied: |
934 if not item.applied: |
932 self.toggleapply(item) |
935 self.toggleapply(item) |
933 self.waslasttoggleallapplied = not self.waslasttoggleallapplied |
936 self.waslasttoggleallapplied = not self.waslasttoggleallapplied |
|
937 |
|
938 def toggleallbetween(self): |
|
939 "toggle applied on or off for all items in range [lastapplied,current]." |
|
940 if (not self.lastapplieditem or |
|
941 self.currentselecteditem == self.lastapplieditem): |
|
942 # Treat this like a normal 'x'/' ' |
|
943 self.toggleapply() |
|
944 return |
|
945 |
|
946 startitem = self.lastapplieditem |
|
947 enditem = self.currentselecteditem |
|
948 # Verify that enditem is "after" startitem, otherwise swap them. |
|
949 for direction in ['forward', 'reverse']: |
|
950 nextitem = startitem.nextitem() |
|
951 while nextitem and nextitem != enditem: |
|
952 nextitem = nextitem.nextitem() |
|
953 if nextitem: |
|
954 break |
|
955 # Looks like we went the wrong direction :) |
|
956 startitem, enditem = enditem, startitem |
|
957 |
|
958 if not nextitem: |
|
959 # We didn't find a path going either forward or backward? Don't know |
|
960 # how this can happen, let's not crash though. |
|
961 return |
|
962 |
|
963 nextitem = startitem |
|
964 # Switch all items to be the opposite state of the currently selected |
|
965 # item. Specifically: |
|
966 # [ ] startitem |
|
967 # [x] middleitem |
|
968 # [ ] enditem <-- currently selected |
|
969 # This will turn all three on, since the currently selected item is off. |
|
970 # This does *not* invert each item (i.e. middleitem stays marked/on) |
|
971 desiredstate = not self.currentselecteditem.applied |
|
972 while nextitem != enditem.nextitem(): |
|
973 if nextitem.applied != desiredstate: |
|
974 self.toggleapply(item=nextitem) |
|
975 nextitem = nextitem.nextitem() |
934 |
976 |
935 def togglefolded(self, item=None, foldparent=False): |
977 def togglefolded(self, item=None, foldparent=False): |
936 "toggle folded flag of specified item (defaults to currently selected)" |
978 "toggle folded flag of specified item (defaults to currently selected)" |
937 if item is None: |
979 if item is None: |
938 item = self.currentselecteditem |
980 item = self.currentselecteditem |
1462 the following are valid keystrokes: |
1504 the following are valid keystrokes: |
1463 |
1505 |
1464 x [space] : (un-)select item ([~]/[x] = partly/fully applied) |
1506 x [space] : (un-)select item ([~]/[x] = partly/fully applied) |
1465 [enter] : (un-)select item and go to next item of same type |
1507 [enter] : (un-)select item and go to next item of same type |
1466 A : (un-)select all items |
1508 A : (un-)select all items |
|
1509 X : (un-)select all items between current and most-recent |
1467 up/down-arrow [k/j] : go to previous/next unfolded item |
1510 up/down-arrow [k/j] : go to previous/next unfolded item |
1468 pgup/pgdn [K/J] : go to previous/next item of same type |
1511 pgup/pgdn [K/J] : go to previous/next item of same type |
1469 right/left-arrow [l/h] : go to child item / parent item |
1512 right/left-arrow [l/h] : go to child item / parent item |
1470 shift-left-arrow [H] : go to parent header / fold selected header |
1513 shift-left-arrow [H] : go to parent header / fold selected header |
1471 g : go to the top |
1514 g : go to the top |
1753 elif keypressed in [' ', 'x']: |
1796 elif keypressed in [' ', 'x']: |
1754 self.toggleapply() |
1797 self.toggleapply() |
1755 elif keypressed in ['\n', 'KEY_ENTER']: |
1798 elif keypressed in ['\n', 'KEY_ENTER']: |
1756 self.toggleapply() |
1799 self.toggleapply() |
1757 self.nextsametype(test=test) |
1800 self.nextsametype(test=test) |
|
1801 elif keypressed in ['X']: |
|
1802 self.toggleallbetween() |
1758 elif keypressed in ['A']: |
1803 elif keypressed in ['A']: |
1759 self.toggleall() |
1804 self.toggleall() |
1760 elif keypressed in ['e']: |
1805 elif keypressed in ['e']: |
1761 self.toggleedit(test=test) |
1806 self.toggleedit(test=test) |
1762 elif keypressed in ["f"]: |
1807 elif keypressed in ["f"]: |