tog: add support for navigating to first/last line of tree and ref views 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109
diff --git a/tog/tog.1 b/tog/tog.1
index e146064..6782772 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -365,6 +365,10 @@ 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
+Move the selection cursor to the first entry.
+.It Cm End, G
+Move the selection cursor to the last entry.
.It Cm Enter
Enter the currently selected directory, or switch to the
.Cm blame
@@ -431,6 +435,10 @@ 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
+Move the selection cursor to the first reference.
+.It Cm End, G
+Move the selection cursor to the last reference.
.It Cm Enter
Open a
.Cm log
diff --git a/tog/tog.c b/tog/tog.c
index 676aa5b..6571f11 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -5396,7 +5396,8 @@ input_tree_view(struct tog_view **new_view, struct tog_view *view, int ch)
const struct got_error *err = NULL;
struct tog_tree_view_state *s = &view->state.tree;
struct tog_view *log_view, *ref_view;
- int begin_x = 0;
+ struct got_tree_entry *te;
+ int begin_x = 0, n;
switch (ch) {
case 'i':
@@ -5442,6 +5443,33 @@ input_tree_view(struct tog_view **new_view, struct tog_view *view, int ch)
} else
*new_view = ref_view;
break;
+ case 'g':
+ case KEY_HOME:
+ s->selected = 0;
+ if (s->tree == s->root)
+ s->first_displayed_entry =
+ got_object_tree_get_first_entry(s->tree);
+ else
+ s->first_displayed_entry = NULL;
+ break;
+ case 'G':
+ case KEY_END:
+ s->selected = 0;
+ te = got_object_tree_get_last_entry(s->tree);
+ for (n = 0; n < view->nlines - 3; n++) {
+ if (te == NULL) {
+ if(s->tree != s->root) {
+ s->first_displayed_entry = NULL;
+ n++;
+ }
+ break;
+ }
+ s->first_displayed_entry = te;
+ te = got_tree_entry_get_prev(s->tree, te);
+ }
+ if (n > 0)
+ s->selected = n - 1;
+ break;
case 'k':
case KEY_UP:
if (s->selected > 0) {
@@ -6158,7 +6186,8 @@ input_ref_view(struct tog_view **new_view, struct tog_view *view, int ch)
const struct got_error *err = NULL;
struct tog_ref_view_state *s = &view->state.ref;
struct tog_view *log_view, *tree_view;
- int begin_x = 0;
+ struct tog_reflist_entry *re;
+ int begin_x = 0, n;
switch (ch) {
case 'i':
@@ -6203,6 +6232,24 @@ input_ref_view(struct tog_view **new_view, struct tog_view *view, int ch)
} else
*new_view = tree_view;
break;
+ case 'g':
+ case KEY_HOME:
+ s->selected = 0;
+ s->first_displayed_entry = TAILQ_FIRST(&s->refs);
+ break;
+ case 'G':
+ case KEY_END:
+ s->selected = 0;
+ re = TAILQ_LAST(&s->refs, tog_reflist_head);
+ for (n = 0; n < view->nlines - 1; n++) {
+ if (re == NULL)
+ break;
+ s->first_displayed_entry = re;
+ re = TAILQ_PREV(re, tog_reflist_head, entry);
+ }
+ if (n > 0)
+ s->selected = n - 1;
+ break;
case 'k':
case KEY_UP:
if (s->selected > 0) {