about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2010-02-20 18:31:44 +0000
committerMarco Peereboom <marco@conformal.com>2010-02-20 18:31:44 +0000
commit5066150d51d6efb20fcd5af5555e3ab798d73b6a (patch)
tree6257bbfca4e33c9aed63af3ef6a0589c4f4ea049
parenta7fb10a5dfd2003537e6fa7ad34cbd064dd2b7f9 (diff)
downloadxombrero-5066150d51d6efb20fcd5af5555e3ab798d73b6a.tar.gz
Add tabnext and tabprevious
-rw-r--r--xxxterm.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/xxxterm.c b/xxxterm.c
index d3f7ef2..715e830 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -114,6 +114,8 @@ struct karg {
 #define XT_MOVE_RIGHT		(9)
 #define XT_MOVE_FARRIGHT	(10)
 
+#define XT_TAB_PREV		(-2)
+#define XT_TAB_NEXT		(-1)
 #define XT_TAB_INVALID		(0)
 #define XT_TAB_NEW		(1)
 #define XT_TAB_DELETE		(2)
@@ -282,7 +284,7 @@ tabaction(struct tab *t, struct karg *args)
 	DNPRINTF(XT_D_TAB, "tabaction: %p %d %d\n", t, args->i, t->focus_wv);
 
 	if (t == NULL)
-		return (0);
+		return (XT_CB_PASSTHROUGH);
 
 	switch (args->i) {
 	case XT_TAB_NEW:
@@ -314,6 +316,27 @@ movetab(struct tab *t, struct karg *args)
 
 	DNPRINTF(XT_D_TAB, "movetab: %p %d\n", t, args->i);
 
+	if (t == NULL)
+		return (XT_CB_PASSTHROUGH);
+
+	if (args->i == XT_TAB_INVALID)
+		return (XT_CB_PASSTHROUGH);
+
+
+	if (args->i < XT_TAB_INVALID) {
+		/* next or previous tab */
+		if (TAILQ_EMPTY(&tabs))
+			return (XT_CB_PASSTHROUGH);
+
+		if (args->i == XT_TAB_NEXT)
+			gtk_notebook_next_page(GTK_NOTEBOOK(notebook));
+		else
+			gtk_notebook_prev_page(GTK_NOTEBOOK(notebook));
+
+		return (XT_CB_HANDLED);
+	}
+
+	/* jump to tab */
 	x = args->i - 1;
 	if (t->tab_id == x) {
 		DNPRINTF(XT_D_TAB, "movetab: do nothing\n");
@@ -322,7 +345,8 @@ movetab(struct tab *t, struct karg *args)
 
 	TAILQ_FOREACH(tt, &tabs, entry) {
 		if (tt->tab_id == x) {
-			gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), x);
+			gtk_notebook_set_current_page(
+			    GTK_NOTEBOOK(notebook), x);
 			DNPRINTF(XT_D_TAB, "movetab: going to %d\n", x);
 			if (tt->focus_wv)
 				gtk_widget_grab_focus(GTK_WIDGET(tt->wv));
@@ -399,6 +423,8 @@ struct cmd {
 	{ "quit",		0,	quit,			{0} },
 	{ "tabnew",		1,	tabaction,		{.i = XT_TAB_NEW} },
 	{ "tabclose",		0,	tabaction,		{.i = XT_TAB_DELETE} },
+	{ "tabprevious",	0,	movetab,		{.i = XT_TAB_PREV} },
+	{ "tabnext",		0,	movetab,		{.i = XT_TAB_NEXT} },
 };
 
 void