Commit 48fcc5120f87139d1a23de231cfabc056bde12cd

Stefan Sperling 2018-08-18T12:58:37

allow switching between open tog views with TAB

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) {