[PATCH v4] crecord: add an event that scrolls the selected line to the top of the screen
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Sep 20 10:01:40 EDT 2016
On 09/20/2016 12:23 AM, Nathan Goldbaum wrote:
> # HG changeset patch
> # User Nathan Goldbaum <ngoldbau at illinois.edu>
> # Date 1474321033 18000
> # Mon Sep 19 16:37:13 2016 -0500
> # Node ID 94afc22065e475ab1a61f68012be44f6dbbd0d64
> # Parent 285a8c3e53f2183438f0cdbc238e4ab851d0d110
> 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 285a8c3e53f2 -r 94afc22065e4 mercurial/crecord.py
> --- a/mercurial/crecord.py Tue May 03 13:36:12 2016 +0900
> +++ b/mercurial/crecord.py Mon Sep 19 16:37:13 2016 -0500
> @@ -715,6 +715,10 @@ class curseschunkselector(object):
>
> self.currentselecteditem = currentitem
>
> + def topscroll(self):
> + "scroll so the currently selected line is at the top of the screen"
> + self.scrolllines(self.selecteditemstartline)
> +
> def updatescroll(self):
> "scroll the screen to fully show the currently-selected"
> selstart = self.selecteditemstartline
> @@ -1338,6 +1342,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 +1587,8 @@ are you sure you want to review/edit and
> self.helpwindow()
> self.stdscr.clear()
> self.stdscr.refresh()
> + elif curses.unctrl(keypressed) in ["^L"]:
> + self.topscroll()
any reason why we use 'in' instead of "==" here?
Also, I'm not sure if the 'topscroll' method is that useful as it a
one-liner. Should just call that code in the if clause?
Cheers,
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list