allow backspace to cycle views backwards in tog
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
diff --git a/tog/tog.1 b/tog/tog.1
index 53ede1f..3f2551b 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -62,6 +62,9 @@ Quit the view which is in focus.
.It Cm Tab
Switch focus to the next view.
Cycles through all open views.
+.It Cm Backspace
+Switch focus to the previous view.
+Cycles through all open views.
.El
.Pp
Global options must precede the command name, and are as follows:
@@ -130,7 +133,7 @@ are as follows:
.Bl -tag -width Ds
.It Cm Down-arrow, j, Page-down, Space
Scroll down.
-.It Cm Up-arrow, k, Page-up, Backspace
+.It Cm Up-arrow, k, Page-up
Scroll up.
.El
.It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
@@ -142,7 +145,7 @@ are as follows:
.Bl -tag -width Ds
.It Cm Down-arrow, j, Page-down, Space
Move the selection cursor down.
-.It Cm Up-arrow, k, Page-up, Backspace
+.It Cm Up-arrow, k, Page-up
Move the selection cursor up.
.It Cm Enter
Switch to the
@@ -199,7 +202,7 @@ view for the currently selected file.
Switch to the
.Cm log
view for the currently selected tree entry.
-.It Cm Backspace
+.It Cm Left-arrow
Move back to the parent directory.
.It Cm i
Show the object IDs for all objects displayed in the
diff --git a/tog/tog.c b/tog/tog.c
index a69b40e..d99b301 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -343,7 +343,7 @@ view_input(struct tog_view **new, struct tog_view **dead,
struct tog_view_list_head *views)
{
const struct got_error *err = NULL;
- struct tog_view *next;
+ struct tog_view *next, *prev;
int ch;
*new = NULL;
@@ -362,6 +362,13 @@ view_input(struct tog_view **new, struct tog_view **dead,
else
*focus = TAILQ_FIRST(views);
break;
+ case KEY_BACKSPACE:
+ prev = TAILQ_PREV(view, tog_view_list_head, entry);
+ if (prev)
+ *focus = prev;
+ else
+ *focus = TAILQ_LAST(views, tog_view_list_head);
+ break;
case 'q':
err = view->input(new, dead, view, ch);
*dead = view;
@@ -1438,7 +1445,6 @@ input_diff_view(struct tog_view **new, struct tog_view **dead,
s->first_displayed_line--;
break;
case KEY_PPAGE:
- case KEY_BACKSPACE:
i = 0;
while (i++ < view->nlines - 1 &&
s->first_displayed_line > 1)
@@ -2019,7 +2025,6 @@ input_blame_view(struct tog_view **new_view, struct tog_view **dead_view,
s->first_displayed_line--;
break;
case KEY_PPAGE:
- case KEY_BACKSPACE:
if (s->first_displayed_line == 1) {
s->selected_line = 1;
break;
@@ -2687,7 +2692,7 @@ input_tree_view(struct tog_view **new_view, struct tog_view **dead_view,
case '\r':
if (s->selected_entry == NULL) {
struct tog_parent_tree *parent;
- case KEY_BACKSPACE:
+ case KEY_LEFT:
/* user selected '..' */
if (s->tree == s->root)
break;