tog: add support for navigating to first/last item of log and diff views The keybindings that we settled on are Home, Ctrl-u and g to go to the first item and End, G to go to the last. This resembles those commonly found elsewhere, eg vi/less. discussed with and ok stsp
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
diff --git a/tog/tog.1 b/tog/tog.1
index e22d907..3d45c56 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -108,6 +108,12 @@ Move the selection cursor up.
Move the selection cursor down one page.
.It Cm Page-up, Ctrl+b
Move the selection cursor up one page.
+.It Cm Home, g, Ctrl-u
+Move the cursor to the newest commit.
+.It Cm End, G
+Move the cursor to the oldest commit.
+This will iterate over all commit objects in the repository and may take
+a long time depending on the size of the repository.
.It Cm Enter, Space
Open a
.Cm diff
@@ -210,6 +216,10 @@ Scroll up.
Scroll down one page.
.It Cm Page-up, Ctrl+b
Scroll up one page.
+.It Cm Home, g, Ctrl-u
+Scroll to the top of the view.
+.It Cm End, G
+Scroll to the bottom of the view.
.It Cm \&[
Reduce the amount of diff context lines.
.It Cm \&]
diff --git a/tog/tog.c b/tog/tog.c
index fc51be8..f19156f 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2406,6 +2406,16 @@ input_log_view(struct tog_view **new_view, struct tog_view *view, int ch)
log_scroll_up(s, 1);
select_commit(s);
break;
+ case 'g':
+ case CTRL('u'):
+ case KEY_HOME:
+ if (s->first_displayed_entry == NULL)
+ break;
+
+ s->selected = 0;
+ log_scroll_up(s, s->commits.ncommits);
+ select_commit(s);
+ break;
case KEY_PPAGE:
case CTRL('b'):
if (s->first_displayed_entry == NULL)
@@ -2432,6 +2442,25 @@ input_log_view(struct tog_view **new_view, struct tog_view *view, int ch)
}
select_commit(s);
break;
+ case 'G':
+ case KEY_END: {
+ /* We don't know yet how many commits, so we're forced to
+ * traverse them all. */
+ while (1) {
+ if (s->thread_args.log_complete)
+ break;
+
+ s->thread_args.commits_needed++;
+ err = trigger_log_thread(view, 1);
+ if (err)
+ return err;
+ }
+
+ log_scroll_down(view, s->commits.ncommits);
+ s->selected = MIN(view->nlines - 2, s->commits.ncommits - 1);
+ select_commit(s);
+ break;
+ }
case KEY_NPAGE:
case CTRL('f'): {
struct commit_queue_entry *first;
@@ -3641,6 +3670,19 @@ input_diff_view(struct tog_view **new_view, struct tog_view *view, int ch)
diff_view_indicate_progress(view);
err = create_diff(s);
break;
+ case 'g':
+ case CTRL('u'):
+ case KEY_HOME:
+ s->first_displayed_line = 1;
+ break;
+ case 'G':
+ case KEY_END:
+ if (s->eof)
+ break;
+
+ s->first_displayed_line = (s->nlines - view->nlines) + 2;
+ s->eof = 1;
+ break;
case 'k':
case KEY_UP:
if (s->first_displayed_line > 1)