commit e4526bf56efa8d234d206abac903deccceed4f17 from: Christian Weisgerber date: Fri Sep 03 21:40:14 2021 UTC tog: add support for navigating to first/last line of tree and ref views ok stsp commit - 376d7c6217310146ba605e4994521c6fde62fc18 commit + e4526bf56efa8d234d206abac903deccceed4f17 blob - e1460641f9ff41fe9c556f72f3433b6b500e9dc9 blob + 6782772927c2e0682e87d5728b008b4502aff17b --- tog/tog.1 +++ 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 blob - 676aa5bfd38d46389ada9f6d333fc7b1eab64913 blob + 6571f119993519e742623ae6d665fcc1cc098ad3 --- tog/tog.c +++ tog/tog.c @@ -5396,7 +5396,8 @@ input_tree_view(struct tog_view **new_view, struct tog 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': @@ -5441,7 +5442,34 @@ input_tree_view(struct tog_view **new_view, struct tog view->focus_child = 1; } 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_ 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_ } 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) {