Patchwork [2,of,2,v2] crecord: add an event that scrolls the selected line to the top of the screen

login
register
mail settings
Submitter Nathan Goldbaum
Date Sept. 15, 2016, 6:49 p.m.
Message ID <3d1c9a829692bfb65ee2.1473965359@rous2.ncsa.illinois.edu>
Download mbox | patch
Permalink /patch/16639/
State Accepted
Headers show

Comments

Nathan Goldbaum - Sept. 15, 2016, 6:49 p.m.
# HG changeset patch
# User Nathan Goldbaum <ngoldbau@illinois.edu>
# Date 1473965349 18000
#      Thu Sep 15 13:49:09 2016 -0500
# Node ID 3d1c9a829692bfb65ee269b236e2d695d9fed2b3
# Parent  dec5dfcbd772a9f51674067ad18dff6d9bad78cf
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.
Sean Farley - Sept. 15, 2016, 6:51 p.m.
Nathan Goldbaum <nathan12343@gmail.com> writes:

> # HG changeset patch
> # User Nathan Goldbaum <ngoldbau@illinois.edu>
> # Date 1473965349 18000
> #      Thu Sep 15 13:49:09 2016 -0500
> # Node ID 3d1c9a829692bfb65ee269b236e2d695d9fed2b3
> # Parent  dec5dfcbd772a9f51674067ad18dff6d9bad78cf
> 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.

Without actually testing this, it seems cool with me.
Augie Fackler - Sept. 16, 2016, 2:37 p.m.
On Thu, Sep 15, 2016 at 11:51:39AM -0700, Sean Farley wrote:
> Nathan Goldbaum <nathan12343@gmail.com> writes:
>
> > # HG changeset patch
> > # User Nathan Goldbaum <ngoldbau@illinois.edu>
> > # Date 1473965349 18000
> > #      Thu Sep 15 13:49:09 2016 -0500
> > # Node ID 3d1c9a829692bfb65ee269b236e2d695d9fed2b3
> > # Parent  dec5dfcbd772a9f51674067ad18dff6d9bad78cf
> > 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.
>
> Without actually testing this, it seems cool with me.

Agreed. I didn't test it, but this seems obviously correct to me.

I'd love to hear a vim user chime in as to the feature's obviousness there.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r dec5dfcbd772 -r 3d1c9a829692 mercurial/crecord.py
--- a/mercurial/crecord.py	Wed Sep 14 11:39:47 2016 -0500
+++ b/mercurial/crecord.py	Thu Sep 15 13:49:09 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.keyname(ord(keypressed)) in ["^L"]:
+            self.topscroll()
 
     def main(self, stdscr):
         """