[PATCH v5] crecord: add an event that scrolls the selected line to the top of the screen

Nathan Goldbaum nathan12343 at gmail.com
Tue Sep 20 15:04:15 UTC 2016


# HG changeset patch
# User Nathan Goldbaum <ngoldbau at illinois.edu>
# Date 1474383830 18000
#      Tue Sep 20 10:03:50 2016 -0500
# Node ID da914962b6c3f55c3f14cd7b82a4c0204c2d6a0d
# Parent  769aee32fae0f7eb8768ea2e90780af4e9a92761
crecord: add an event that scrolls the selected line to the top of the screen

Using ctrl-l for this purpose seems to be a fairly widely used practice,
presumably following emacs. This doesn't scroll the selected line all
the way to the top of the window, instead it leaves a 3 line buffer for
context. Use curses.unctrl() to resolve keypressed to '^L' to avoid
hard-coding hexadecimal key codes.

diff -r 769aee32fae0 -r da914962b6c3 mercurial/crecord.py
--- a/mercurial/crecord.py	Mon Sep 19 09:14:35 2016 -0700
+++ b/mercurial/crecord.py	Tue Sep 20 10:03:50 2016 -0500
@@ -715,6 +715,7 @@ class curseschunkselector(object):
 
         self.currentselecteditem = currentitem
 
+
     def updatescroll(self):
         "scroll the screen to fully show the currently-selected"
         selstart = self.selecteditemstartline
@@ -1338,6 +1339,7 @@ the following are valid keystrokes:
  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
+                 ctrl-l : scroll the selected line to the top of the screen
                       m : edit / resume editing the commit message
                       e : edit the currently selected hunk
                       a : toggle amend mode, only with commit -i
@@ -1582,6 +1584,9 @@ are you sure you want to review/edit and
             self.helpwindow()
             self.stdscr.clear()
             self.stdscr.refresh()
+        elif curses.unctrl(keypressed) in ["^L"]:
+            # scroll the current line to the top of the screen
+            self.scrolllines(self.selecteditemstartline)
 
     def main(self, stdscr):
         """


More information about the Mercurial-devel mailing list