tog: add Ctrl-n/Ctrl-p shortcuts scrolling one line down/up; patch by Omar Polo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
diff --git a/tog/tog.1 b/tog/tog.1
index 6782772..0e414ba 100644
--- a/tog/tog.1
+++ b/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.
diff --git a/tog/tog.c b/tog/tog.c
index 810503c..74c6676 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2411,6 +2411,7 @@ input_log_view(struct tog_view **new_view, struct tog_view *view, int ch)
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_view *view, int ch)
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_view *view, int ch)
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_view *view, int ch)
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 tog_view *view, int ch)
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 tog_view *view, int ch)
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_view *view, int ch)
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_view *view, int ch)
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_view *view, int ch)
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_view *view, int ch)
break;
case 'j':
case KEY_DOWN:
+ case CTRL('n'):
if (s->selected < s->ndisplayed - 1) {
s->selected++;
break;