edgimar avatar edgimar committed ee79f51

- implement toggle-all option ('A' key) to toggle applied status of all
files/hunks, based on a patch provided by Nicholas Riley.

Comments (0)

Files changed (1)

crecord/chunk_selector.py

         # stores optional text for a commit comment provided by the user
         self.commentText = ""
 
+        # if the last 'toggle all' command caused all changes to be applied
+        self.wasLastToggleAllApplied = True
+
     def upArrowEvent(self):
         """
         Try to select the previous item to the current item that has the
                 item.hunk.header.applied = True
                 item.hunk.header.partial = (someParentSiblingsPartial or \
                                             not allParentSiblingsApplied)
+
+    def toggleAll(self):
+        "Toggle the applied flag of all items."
+        if self.wasLastToggleAllApplied: # then unapply them this time
+            for item in self.headerList:
+                if item.applied:
+                    self.toggleApply(item)
+        else:
+            for item in self.headerList:
+                if not item.applied:
+                    self.toggleApply(item)
+        self.wasLastToggleAllApplied = not self.wasLastToggleAllApplied
+
     def toggleFolded(self, item=None, foldParent=False):
         "Toggle folded flag of specified item (defaults to currently selected)"
         if item is None:
 
         # print out the status lines at the top
         try:
-            printString(self.statuswin, "SELECT CHUNKS: (j/k/up/down/pgup/pgdn) move cursor; (space) toggle applied", pairName="legend")
+            printString(self.statuswin, "SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; (space/A) toggle hunk/all", pairName="legend")
             printString(self.statuswin, " (f)old/unfold; (c)ommit applied; (q)uit; (?) help | [X]=hunk applied **=folded", pairName="legend")
         except curses.error:
             pass
 The following are valid keystrokes:
 
                 [SPACE] : (un-)select item ([~]/[X] = partly/fully applied)
+                      A : (un-)select all items
     Up/Down-arrow [k/j] : go to previous/next unfolded item
         PgUp/PgDn [K/J] : go to previous/next item of same type
  Right/Left-arrow [l/h] : go to child item / parent item
                     break
             elif keyPressed in [' ']:
                 self.toggleApply()
+            elif keyPressed in ['A']:
+                self.toggleAll()
             elif keyPressed in ["f"]:
                 self.toggleFolded()
             elif keyPressed in ["F"]:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.