changeset 77:d4a4f739a039

- add shift-left (shift-h) event which either moves to the header of the selected node, or folds a selected header.
author Mark Edgington <edgimar@gmail.com>
date Thu, 03 Feb 2011 11:10:55 +0100
parents 4af10dce21e0
children 5618ae4accb4
files crecord/chunk_selector.py
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/crecord/chunk_selector.py
+++ b/crecord/chunk_selector.py
@@ -251,6 +251,29 @@
 
         self.currentSelectedItem = nextItem
 
+    def leftArrowShiftEvent(self):
+        """
+        Select the header of the current item (or fold current item if the
+        current item is already a header).
+
+        """
+        currentItem = self.currentSelectedItem
+
+        if isinstance(currentItem, header):
+            if not currentItem.folded:
+                self.toggleFolded(item=currentItem)
+                return
+
+        # select the parent item recursively until we're at a header
+        while True:
+            nextItem = currentItem.parentItem()
+            if nextItem is None:
+                break
+            else:
+                currentItem = nextItem
+
+        self.currentSelectedItem = currentItem
+
     def updateScroll(self):
         "Scroll the screen to fully show the currently-selected"
         selStart = self.selectedItemStartLine
@@ -871,6 +894,7 @@
     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
+ Shift-Left-arrow   [H] : go to parent header / fold selected header
                       f : fold / unfold item, hiding/revealing its children
                       F : fold / unfold parent item and all of its ancestors
                       m : edit / resume editing the commit message
@@ -1017,6 +1041,8 @@
                 self.rightArrowEvent()
             elif keyPressed in ["h", "KEY_LEFT"]:
                 self.leftArrowEvent()
+            elif keyPressed in ["H", "KEY_SLEFT"]:
+                self.leftArrowShiftEvent()
             elif keyPressed in ["q"]:
                 raise util.Abort(_('user quit'))
             elif keyPressed in ["c"]: