raster pushed a commit to branch master.
commit 4dd17b80aa90bb55c4b48272c93c6a12dff8ec42
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date: Thu Apr 18 23:56:12 2013 +0900
alt + 1,2,3,...8,9,0 switch TO terminal tab # 1, 2, ... 8, 9, 10
---
TODO | 1 -
src/bin/main.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/termio.c | 60 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 1 deletion(-)
diff --git a/TODO b/TODO
index 70593af..835746c 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,6 @@ make it a first-class terminal:
[ ] VT100-compatibilyt: pass all of http://invisible-island.net/vttest/ tests!
[ ] tabs: reordering
-[ ] tabs: key bindings for each tab ex) alt + 1, alt + 2, ...
[ ] splits need to size only by steps in font size (elm feature)
[ ] better info in tyls -m
[ ] tyls -b needs doing
diff --git a/src/bin/main.c b/src/bin/main.c
index 5280744..aeafc79 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -1407,6 +1407,78 @@ _cb_icon(void *data, Evas_Object *obj __UNUSED__, void
*event __UNUSED__)
elm_win_icon_name_set(term->wn->win, termio_icon_name_get(term->term));
}
+static void
+_tab_go(Term *term, int tnum)
+{
+ Term *term2;
+ Split *sp = _split_find(term->wn->win, term->term);;
+ if (!sp) return;
+
+ term2 = eina_list_nth(sp->terms, tnum);
+ if ((!term2) || (term2 == term)) return;
+ _sel_go(sp, term2);
+}
+
+static void
+_cb_tab_1(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 0);
+}
+
+static void
+_cb_tab_2(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 1);
+}
+
+static void
+_cb_tab_3(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 2);
+}
+
+static void
+_cb_tab_4(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 3);
+}
+
+static void
+_cb_tab_5(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 4);
+}
+
+static void
+_cb_tab_6(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 5);
+}
+
+static void
+_cb_tab_7(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 6);
+}
+
+static void
+_cb_tab_8(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 7);
+}
+
+static void
+_cb_tab_9(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 8);
+}
+
+static void
+_cb_tab_0(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+{
+ _tab_go(data, 9);
+}
+
static Eina_Bool
_cb_cmd_focus(void *data)
{
@@ -2077,6 +2149,16 @@ main_term_new(Win *wn, Config *config, const char *cmd,
evas_object_smart_callback_add(o, "split,v", _cb_split_v, term);
evas_object_smart_callback_add(o, "title,change", _cb_title, term);
evas_object_smart_callback_add(o, "icon,change", _cb_icon, term);
+ evas_object_smart_callback_add(o, "tab,1", _cb_tab_1, term);
+ evas_object_smart_callback_add(o, "tab,2", _cb_tab_2, term);
+ evas_object_smart_callback_add(o, "tab,3", _cb_tab_3, term);
+ evas_object_smart_callback_add(o, "tab,4", _cb_tab_4, term);
+ evas_object_smart_callback_add(o, "tab,5", _cb_tab_5, term);
+ evas_object_smart_callback_add(o, "tab,6", _cb_tab_6, term);
+ evas_object_smart_callback_add(o, "tab,7", _cb_tab_7, term);
+ evas_object_smart_callback_add(o, "tab,8", _cb_tab_8, term);
+ evas_object_smart_callback_add(o, "tab,9", _cb_tab_9, term);
+ evas_object_smart_callback_add(o, "tab,0", _cb_tab_0, term);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 4df0dc9..db4af00 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1464,6 +1464,66 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__,
Evas_Object *obj __UNUSED__,
_paste_selection(data, ELM_SEL_TYPE_PRIMARY);
goto end;
}
+ else if (!strcmp(ev->keyname, "1"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,1", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "2"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,2", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "3"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,3", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "4"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,4", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "5"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,5", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "6"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,6", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "7"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,7", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "8"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,8", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "9"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,9", NULL);
+ goto end;
+ }
+ else if (!strcmp(ev->keyname, "0"))
+ {
+ _compose_seq_reset(sd);
+ evas_object_smart_callback_call(data, "tab,0", NULL);
+ goto end;
+ }
}
if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
(evas_key_modifier_is_set(ev->modifiers, "Control")) &&
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter