From 85e60bbf7495ad343e511ce1b83e0a1b58a7d8c4 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 26 Jan 2013 13:06:58 +0000 Subject: [PATCH] add keybinds to split terms. SVN revision: 83358 --- README | 7 +++++-- src/bin/main.c | 25 ++++++++++++++++++++++++ src/bin/termio.c | 50 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/README b/README index c7b82f8e..d0679bee 100644 --- a/README +++ b/README @@ -52,8 +52,11 @@ Shift+Keypad-Plus = Font size up 1 Shift+Keypad-Minus = Font size down 1 Shift+Keypad-Multiply = Reset font size to 10 Shift+Keypad-Divide = Copy highlight to Clipboard (same as ctrl+c in gui apps) -Ctrl+PgUp = reserved later for multi-terms -Ctrl+PgDn = reserved later for multi-terms +Ctrl+PgUp = switch focus to previous terminal inside a window +Ctrl+PgDn = switch focus to next terminal inside a window +Ctrl+t = create new terminal on top of current inside window (tabs) (not implemented) +Ctrl+Shift+PgUp = split terminal horizontally (1 term above the other) +Ctrl+Shift+PgDn = split terminal vertically (1 term to the left of the other) Alt+Home = Enter command mode (enter commands to control terminology itself) Command mode commands currently understood: diff --git a/src/bin/main.c b/src/bin/main.c index 9fd43e9d..c8f57157 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -857,6 +857,28 @@ _cb_next(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) if (term2) _term_focus(term2); } +static void +_cb_new(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + Term *term = data; +} + +static void +_cb_split_h(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + Term *term = data; + + main_split_h(term->wn->win, term->term); +} + +static void +_cb_split_v(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + Term *term = data; + + main_split_v(term->wn->win, term->term); +} + static Eina_Bool _cb_cmd_focus(void *data) { @@ -1267,6 +1289,9 @@ main_term_new(Win *wn, Config *config, const char *cmd, evas_object_smart_callback_add(o, "command", _cb_command, term); evas_object_smart_callback_add(o, "prev", _cb_prev, term); evas_object_smart_callback_add(o, "next", _cb_next, term); + evas_object_smart_callback_add(o, "new", _cb_new, term); + evas_object_smart_callback_add(o, "split,h", _cb_split_h, term); + evas_object_smart_callback_add(o, "split,v", _cb_split_v, 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 2f81b6ec..871778ca 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -978,6 +978,41 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, } } } + if ((!evas_key_modifier_is_set(ev->modifiers, "Alt")) && + (evas_key_modifier_is_set(ev->modifiers, "Control")) && + (!evas_key_modifier_is_set(ev->modifiers, "Shift"))) + { + if (!strcmp(ev->keyname, "Prior")) + { + evas_object_smart_callback_call(data, "prev", NULL); + goto end; + } + else if (!strcmp(ev->keyname, "Next")) + { + evas_object_smart_callback_call(data, "next", NULL); + goto end; + } + else if (!strcmp(ev->keyname, "t")) + { + evas_object_smart_callback_call(data, "new", NULL); + goto end; + } + } + if ((!evas_key_modifier_is_set(ev->modifiers, "Alt")) && + (evas_key_modifier_is_set(ev->modifiers, "Control")) && + (evas_key_modifier_is_set(ev->modifiers, "Shift"))) + { + if (!strcmp(ev->keyname, "Prior")) + { + evas_object_smart_callback_call(data, "split,h", NULL); + goto end; + } + else if (!strcmp(ev->keyname, "Next")) + { + evas_object_smart_callback_call(data, "split,v", NULL); + goto end; + } + } if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) && (!evas_key_modifier_is_set(ev->modifiers, "Shift")) && (!evas_key_modifier_is_set(ev->modifiers, "Control")) && @@ -1010,21 +1045,6 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, goto end; } } - if ((!evas_key_modifier_is_set(ev->modifiers, "Alt")) && - (evas_key_modifier_is_set(ev->modifiers, "Control")) && - (!evas_key_modifier_is_set(ev->modifiers, "Shift"))) - { - if (!strcmp(ev->keyname, "Prior")) - { - evas_object_smart_callback_call(data, "prev", NULL); - goto end; - } - else if (!strcmp(ev->keyname, "Next")) - { - evas_object_smart_callback_call(data, "next", NULL); - goto end; - } - } if (sd->jump_on_keypress) { if (!_is_modifier(ev->key))