allow switching between open tog views with TAB
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
diff --git a/tog/tog.c b/tog/tog.c
index cab4c27..96401a7 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -338,9 +338,12 @@ view_resize(struct tog_view *view)
}
static const struct got_error *
-view_input(struct tog_view **new, struct tog_view **dead, struct tog_view *view)
+view_input(struct tog_view **new, struct tog_view **dead,
+ struct tog_view **focus, struct tog_view *view,
+ struct tog_view_list_head *views)
{
const struct got_error *err = NULL;
+ struct tog_view *next;
int ch;
*new = NULL;
@@ -352,6 +355,13 @@ view_input(struct tog_view **new, struct tog_view **dead, struct tog_view *view)
switch (ch) {
case ERR:
break;
+ case '\t':
+ next = TAILQ_NEXT(view, entry);
+ if (next)
+ *focus = next;
+ else
+ *focus = TAILQ_FIRST(views);
+ break;
case 'q':
err = view->input(new, dead, view, ch);
*dead = view;
@@ -384,7 +394,7 @@ view_loop(struct tog_view *view)
err = view_show(view);
if (err)
break;
- err = view_input(&new_view, &dead_view, view);
+ err = view_input(&new_view, &dead_view, &view, view, &views);
if (err)
break;
if (new_view) {