Commit 4deef56fe9fdbfef7d2ecd12947ff515a0daae78

Christian Weisgerber 2021-09-02T17:40:11

tog: add support for navigating to first/last line of blame view ok tracey stsp

diff --git a/tog/tog.1 b/tog/tog.1
index 58534fe..e146064 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -286,6 +286,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 line of the file.
+.It Cm End, G
+Move the selection cursor to the last line of the file.
 .It Cm Enter
 Open a
 .Cm diff
diff --git a/tog/tog.c b/tog/tog.c
index b9c4abb..676aa5b 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -4532,6 +4532,22 @@ input_blame_view(struct tog_view **new_view, struct tog_view *view, int ch)
 	case 'q':
 		s->done = 1;
 		break;
+	case 'g':
+	case KEY_HOME:
+		s->selected_line = 1;
+		s->first_displayed_line = 1;
+		break;
+	case 'G':
+	case KEY_END:
+		if (s->blame.nlines < view->nlines - 2) {
+			s->selected_line = s->blame.nlines;
+			s->first_displayed_line = 1;
+		} else {
+			s->selected_line = view->nlines - 2;
+			s->first_displayed_line = s->blame.nlines -
+			    (view->nlines - 3);
+		}
+		break;
 	case 'k':
 	case KEY_UP:
 		if (s->selected_line > 1)