Download raw body.
tog: C-n/C-p to scroll by line
Hello,
The attached patch adds C-n and C-p bindings to the various tog views to
scroll by one line up and down.
I don't intend to replicate the whole set of Emacs keybindings inside
tog, but I think it's worth to include at least some like control-n and
control-p. I've been using tog patched this way for a while and can't
imagine going back ;-) muscle memory is hard to defeat.
Anyway, I can keep this patch locally if it causes problems or if we
don't want to add even more keys.
Cheers,
Omar Polo
-----------------------------------------------
commit 996dcc583e1f12b15494eb59810036cbf84480bc (main)
from: Omar Polo <op@omarpolo.com>
date: Sat Oct 16 16:22:59 2021 UTC
add C-p/C-n to scroll by lines
diff 8ddfd03b6e0002c98708e2ba8bd053d0fdbb5013 5a7106209091736561265303faa31bbc1480781f
blob - 6782772927c2e0682e87d5728b008b4502aff17b
blob + 0e414ba8af3db6bb003ec9b35d7e1510d7c18632
--- tog/tog.1
+++ tog/tog.1
@@ -100,9 +100,9 @@ The key bindings for
.Cm tog log
are as follows:
.Bl -tag -width Ds
-.It Cm Down-arrow, j, >, Full stop
+.It Cm Down-arrow, j, >, Full stop, Ctrl-n
Move the selection cursor down.
-.It Cm Up-arrow, k, <, Comma
+.It Cm Up-arrow, k, <, Comma, Ctrl-p
Move the selection cursor up.
.It Cm Page-down, Ctrl+f
Move the selection cursor down one page.
@@ -211,9 +211,9 @@ are as follows:
.It Cm a
Toggle treatment of file contents as ASCII text even if binary data was
detected.
-.It Cm Down-arrow, j
+.It Cm Down-arrow, j, Ctrl-n
Scroll down.
-.It Cm Up-arrow, k
+.It Cm Up-arrow, k, Ctrl-p
Scroll up.
.It Cm Page-down, Space, Ctrl+f
Scroll down one page.
@@ -278,9 +278,9 @@ The key bindings for
.Cm tog blame
are as follows:
.Bl -tag -width Ds
-.It Cm Down-arrow, j
+.It Cm Down-arrow, j, Ctrl-n
Move the selection cursor down.
-.It Cm Up-arrow, k
+.It Cm Up-arrow, k, Ctrl-p
Move the selection cursor up.
.It Cm Page-down, Space, Ctrl+f
Move the selection cursor down one page.
@@ -357,9 +357,9 @@ The key bindings for
.Cm tog tree
are as follows:
.Bl -tag -width Ds
-.It Cm Down-arrow, j
+.It Cm Down-arrow, j, Ctrl-n
Move the selection cursor down.
-.It Cm Up-arrow, k
+.It Cm Up-arrow, k, Ctrl-p
Move the selection cursor up.
.It Cm Page-down, Ctrl+f
Move the selection cursor down one page.
@@ -427,9 +427,9 @@ The key bindings for
.Cm tog ref
are as follows:
.Bl -tag -width Ds
-.It Cm Down-arrow, j
+.It Cm Down-arrow, j, Ctrl-n
Move the selection cursor down.
-.It Cm Up-arrow, k
+.It Cm Up-arrow, k, Ctrl-p
Move the selection cursor up.
.It Cm Page-down, Ctrl+f
Move the selection cursor down one page.
blob - 810503c77404623c48136692ab83b09ef677b70f
blob + 76ba8e8898929dfddaecf63b2b816b7508330a5d
--- tog/tog.c
+++ tog/tog.c
@@ -2411,6 +2411,7 @@ input_log_view(struct tog_view **new_view, struct tog_
case KEY_UP:
case '<':
case ',':
+ case CTRL('P'):
if (s->first_displayed_entry == NULL)
break;
if (s->selected > 0)
@@ -2439,6 +2440,7 @@ input_log_view(struct tog_view **new_view, struct tog_
case KEY_DOWN:
case '>':
case '.':
+ case CTRL('N'):
if (s->first_displayed_entry == NULL)
break;
if (s->selected < MIN(view->nlines - 2,
@@ -3719,6 +3721,7 @@ input_diff_view(struct tog_view **new_view, struct tog
break;
case 'k':
case KEY_UP:
+ case CTRL('P'):
if (s->first_displayed_line > 1)
s->first_displayed_line--;
break;
@@ -3733,6 +3736,7 @@ input_diff_view(struct tog_view **new_view, struct tog
break;
case 'j':
case KEY_DOWN:
+ case CTRL('N'):
if (!s->eof)
s->first_displayed_line++;
break;
@@ -4579,6 +4583,7 @@ input_blame_view(struct tog_view **new_view, struct to
break;
case 'k':
case KEY_UP:
+ case CTRL('P'):
if (s->selected_line > 1)
s->selected_line--;
else if (s->selected_line == 1 &&
@@ -4599,6 +4604,7 @@ input_blame_view(struct tog_view **new_view, struct to
break;
case 'j':
case KEY_DOWN:
+ case CTRL('N'):
if (s->selected_line < view->nlines - 2 &&
s->first_displayed_line +
s->selected_line <= s->blame.nlines)
@@ -5501,6 +5507,7 @@ input_tree_view(struct tog_view **new_view, struct tog
break;
case 'k':
case KEY_UP:
+ case CTRL('P'):
if (s->selected > 0) {
s->selected--;
break;
@@ -5521,6 +5528,7 @@ input_tree_view(struct tog_view **new_view, struct tog
break;
case 'j':
case KEY_DOWN:
+ case CTRL('N'):
if (s->selected < s->ndisplayed - 1) {
s->selected++;
break;
@@ -6281,6 +6289,7 @@ input_ref_view(struct tog_view **new_view, struct tog_
break;
case 'k':
case KEY_UP:
+ case CTRL('P'):
if (s->selected > 0) {
s->selected--;
break;
@@ -6295,6 +6304,7 @@ input_ref_view(struct tog_view **new_view, struct tog_
break;
case 'j':
case KEY_DOWN:
+ case CTRL('N'):
if (s->selected < s->ndisplayed - 1) {
s->selected++;
break;
tog: C-n/C-p to scroll by line