aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-07-11 00:01:29 +0200
committerBoris Faure <billiob@gmail.com>2017-07-11 00:04:31 +0200
commitfd4ef6ec1f76f9e98cc9c8cc81a39640ecf801f8 (patch)
tree5bcfed2d5e2abeb79fe6a64c95bc4f37989bb12d
parentconstify (diff)
downloadterminology-fd4ef6ec1f76f9e98cc9c8cc81a39640ecf801f8.tar.gz
win: add binding (Alt+Up/Down/Left/Right) to move around panes
-rw-r--r--README4
-rw-r--r--man/terminology.116
-rw-r--r--src/bin/config.c14
-rw-r--r--src/bin/keyin.c48
-rw-r--r--src/bin/term_container.h4
-rw-r--r--src/bin/win.c269
-rw-r--r--src/bin/win.h5
7 files changed, 326 insertions, 34 deletions
diff --git a/README b/README
index 2c84cb1..36a82ae 100644
--- a/README
+++ b/README
@@ -63,6 +63,10 @@ Ctrl+Shift+v = paste current clipboard selection
Alt+Home = Enter command mode (enter commands to control terminology itself)
Alt+Return = Paste primary selection
Alt+w = Copy selection to primary
+Alt+Up = Focus the terminal above
+Alt+Down = Focus the terminal below
+Alt+Left = Focus the terminal on the left
+Alt+Right = Focus the terminal on the right
Ctrl+Alt+Equal = Font size up 1
Ctrl+Alt+Minus = Font size down 1
Ctrl+Alt+0 = Reset font size
diff --git a/man/terminology.1 b/man/terminology.1
index 8550683..ba4eac8 100644
--- a/man/terminology.1
+++ b/man/terminology.1
@@ -292,6 +292,22 @@ Paste primary selection.
Copy selection to primary.
.
.TP
+.B Alt+Up
+Focus the terminal above
+.
+.TP
+.B Alt+Down
+Focus the terminal down
+.
+.TP
+.B Alt+Left
+Focus the terminal on the left
+.
+.TP
+.B Alt+Right
+Focus the terminal on the right
+.
+.TP
.B Ctrl+Shift+c
Copy current selection to clipboard.
.
diff --git a/src/bin/config.c b/src/bin/config.c
index a80e434..72e6a7f 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -7,7 +7,7 @@
#include "col.h"
#include "utils.h"
-#define CONF_VER 15
+#define CONF_VER 16
#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
@@ -336,6 +336,10 @@ _add_default_keys(Config *config)
ADD_KB("Home", 0, 1, 0, 0, "cmd_box");
ADD_KB("w", 0, 1, 0, 0, "copy_primary");
ADD_KB("Return", 0, 1, 0, 0, "paste_primary");
+ ADD_KB("Up", 0, 1, 0, 0, "term_up");
+ ADD_KB("Down", 0, 1, 0, 0, "term_down");
+ ADD_KB("Left", 0, 1, 0, 0, "term_left");
+ ADD_KB("Right", 0, 1, 0, 0, "term_right");
/* Ctrl-Shift- */
ADD_KB("Prior", 1, 0, 1, 0, "split_h");
@@ -619,7 +623,13 @@ config_load(const char *key)
case 14:
config->disable_focus_visuals = EINA_FALSE;
/*pass through*/
- case CONF_VER: /* 15 */
+ case 15:
+ _add_key(config, "Up", 0, 1, 0, 0, "term_up");
+ _add_key(config, "Down", 0, 1, 0, 0, "term_down");
+ _add_key(config, "Left", 0, 1, 0, 0, "term_left");
+ _add_key(config, "Right", 0, 1, 0, 0, "term_right");
+ /*pass through*/
+ case CONF_VER: /* 16 */
config->version = CONF_VER;
break;
default:
diff --git a/src/bin/keyin.c b/src/bin/keyin.c
index 15ec8a0..900d289 100644
--- a/src/bin/keyin.c
+++ b/src/bin/keyin.c
@@ -367,6 +367,46 @@ cb_term_next(Evas_Object *termio_obj)
}
static Eina_Bool
+cb_term_up(Evas_Object *termio_obj)
+{
+ Term *term = termio_term_get(termio_obj);
+ if (!term)
+ return EINA_FALSE;
+ term_up(term);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+cb_term_down(Evas_Object *termio_obj)
+{
+ Term *term = termio_term_get(termio_obj);
+ if (!term)
+ return EINA_FALSE;
+ term_down(term);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+cb_term_left(Evas_Object *termio_obj)
+{
+ Term *term = termio_term_get(termio_obj);
+ if (!term)
+ return EINA_FALSE;
+ term_left(term);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+cb_term_right(Evas_Object *termio_obj)
+{
+ Term *term = termio_term_get(termio_obj);
+ if (!term)
+ return EINA_FALSE;
+ term_right(term);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
cb_term_new(Evas_Object *termio_obj)
{
char path[PATH_MAX], cwd[PATH_MAX], *cmd;
@@ -645,8 +685,12 @@ static Shortcut_Action _actions[] =
{"paste_clipboard", gettext_noop("Paste Clipboard buffer (ctrl+c/v)"), cb_paste_clipboard},
{"group", gettext_noop("Splits/Tabs"), NULL},
- {"term_prev", gettext_noop("Focus to the previous terminal"), cb_term_prev},
- {"term_next", gettext_noop("Focus to the next terminal"), cb_term_next},
+ {"term_prev", gettext_noop("Focus the previous terminal"), cb_term_prev},
+ {"term_next", gettext_noop("Focus the next terminal"), cb_term_next},
+ {"term_up", gettext_noop("Focus the terminal above"), cb_term_up},
+ {"term_down", gettext_noop("Focus the terminal below"), cb_term_down},
+ {"term_left", gettext_noop("Focus the terminal on the left"), cb_term_left},
+ {"term_right", gettext_noop("Focus the terminal on the right"), cb_term_right},
{"split_h", gettext_noop("Split horizontally (new below)"), cb_split_h},
{"split_v", gettext_noop("Split vertically (new on right)"), cb_split_v},
{"tab_new", gettext_noop("Create a new \"tab\""), cb_tab_new},
diff --git a/src/bin/term_container.h b/src/bin/term_container.h
index 40b7090..1f392e8 100644
--- a/src/bin/term_container.h
+++ b/src/bin/term_container.h
@@ -39,6 +39,10 @@ struct _Term_Container {
Term *(*term_next)(const Term_Container *tc, const Term_Container *child);
Term *(*term_prev)(const Term_Container *tc, const Term_Container *child);
+ Term *(*term_up)(const Term_Container *tc, const Term_Container *child);
+ Term *(*term_down)(const Term_Container *tc, const Term_Container *child);
+ Term *(*term_left)(const Term_Container *tc, const Term_Container *child);
+ Term *(*term_right)(const Term_Container *tc, const Term_Container *child);
Term *(*term_first)(const Term_Container *tc);
Term *(*term_last)(const Term_Container *tc);
Term *(*focused_term_get)(const Term_Container *tc);
diff --git a/src/bin/win.c b/src/bin/win.c
index ce048d2..0c8893e 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -297,6 +297,34 @@ _solo_term_prev(const Term_Container *tc,
}
static Term *
+_solo_term_up(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_up(tc->parent, tc);
+}
+
+static Term *
+_solo_term_down(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_down(tc->parent, tc);
+}
+
+static Term *
+_solo_term_left(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_left(tc->parent, tc);
+}
+
+static Term *
+_solo_term_right(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_right(tc->parent, tc);
+}
+
+static Term *
_solo_term_first(const Term_Container *tc)
{
Solo *solo;
@@ -449,6 +477,10 @@ _solo_new(Term *term, Win *wn)
tc = (Term_Container*)solo;
tc->term_next = _solo_term_next;
tc->term_prev = _solo_term_prev;
+ tc->term_up = _solo_term_up;
+ tc->term_down = _solo_term_down;
+ tc->term_left = _solo_term_left;
+ tc->term_right = _solo_term_right;
tc->term_first = _solo_term_first;
tc->term_last = _solo_term_last;
tc->focused_term_get = _solo_focused_term_get;
@@ -786,6 +818,34 @@ _win_term_prev(const Term_Container *_tc EINA_UNUSED,
}
static Term *
+_win_term_up(const Term_Container *_tc EINA_UNUSED,
+ const Term_Container *child EINA_UNUSED)
+{
+ return NULL;
+}
+
+static Term *
+_win_term_down(const Term_Container *_tc EINA_UNUSED,
+ const Term_Container *child EINA_UNUSED)
+{
+ return NULL;
+}
+
+static Term *
+_win_term_left(const Term_Container *_tc EINA_UNUSED,
+ const Term_Container *child EINA_UNUSED)
+{
+ return NULL;
+}
+
+static Term *
+_win_term_right(const Term_Container *_tc EINA_UNUSED,
+ const Term_Container *child EINA_UNUSED)
+{
+ return NULL;
+}
+
+static Term *
_win_term_first(const Term_Container *tc)
{
Win *wn;
@@ -1060,6 +1120,10 @@ win_new(const char *name, const char *role, const char *title,
tc = (Term_Container*) wn;
tc->term_next = _win_term_next;
tc->term_prev = _win_term_prev;
+ tc->term_up = _win_term_up;
+ tc->term_down = _win_term_down;
+ tc->term_left = _win_term_left;
+ tc->term_right = _win_term_right;
tc->term_first = _win_term_first;
tc->term_last = _win_term_last;
tc->focused_term_get = _win_focused_term_get;
@@ -1174,6 +1238,66 @@ _split_term_prev(const Term_Container *tc, const Term_Container *child)
}
static Term *
+_split_term_up(const Term_Container *tc,
+ const Term_Container *child)
+{
+ Split *split;
+
+ assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
+ split = (Split*) tc;
+
+ if (child == split->tc2 && split->is_horizontal)
+ return split->tc1->term_last(split->tc1);
+ else
+ return tc->parent->term_up(tc->parent, tc);
+}
+
+static Term *
+_split_term_down(const Term_Container *tc,
+ const Term_Container *child)
+{
+ Split *split;
+
+ assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
+ split = (Split*) tc;
+
+ if (child == split->tc1 && split->is_horizontal)
+ return split->tc2->term_first(split->tc2);
+ else
+ return tc->parent->term_down(tc->parent, tc);
+}
+
+static Term *
+_split_term_left(const Term_Container *tc,
+ const Term_Container *child)
+{
+ Split *split;
+
+ assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
+ split = (Split*) tc;
+
+ if (child == split->tc2 && !split->is_horizontal)
+ return split->tc1->term_last(split->tc1);
+ else
+ return tc->parent->term_left(tc->parent, tc);
+}
+
+static Term *
+_split_term_right(const Term_Container *tc,
+ const Term_Container *child)
+{
+ Split *split;
+
+ assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
+ split = (Split*) tc;
+
+ if (child == split->tc1 && !split->is_horizontal)
+ return split->tc2->term_first(split->tc2);
+ else
+ return tc->parent->term_right(tc->parent, tc);
+}
+
+static Term *
_split_term_first(const Term_Container *tc)
{
Split *split;
@@ -1545,6 +1669,10 @@ _split_new(Term_Container *tc1, Term_Container *tc2,
tc = (Term_Container*)split;
tc->term_next = _split_term_next;
tc->term_prev = _split_term_prev;
+ tc->term_up = _split_term_up;
+ tc->term_down = _split_term_down;
+ tc->term_left = _split_term_left;
+ tc->term_right = _split_term_right;
tc->term_first = _split_term_first;
tc->term_last = _split_term_last;
tc->focused_term_get = _split_focused_term_get;
@@ -2331,6 +2459,34 @@ _tabs_term_prev(const Term_Container *tc, const Term_Container *child)
}
static Term *
+_tabs_term_up(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_up(tc->parent, tc);
+}
+
+static Term *
+_tabs_term_down(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_down(tc->parent, tc);
+}
+
+static Term *
+_tabs_term_left(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_left(tc->parent, tc);
+}
+
+static Term *
+_tabs_term_right(const Term_Container *tc,
+ const Term_Container *_child EINA_UNUSED)
+{
+ return tc->parent->term_right(tc->parent, tc);
+}
+
+static Term *
_tabs_term_first(const Term_Container *tc)
{
Tabs *tabs;
@@ -2804,6 +2960,10 @@ _tabs_new(Term_Container *child, Term_Container *parent)
tc = (Term_Container*)tabs;
tc->term_next = _tabs_term_next;
tc->term_prev = _tabs_term_prev;
+ tc->term_up = _tabs_term_up;
+ tc->term_down = _tabs_term_down;
+ tc->term_left = _tabs_term_left;
+ tc->term_right = _tabs_term_right;
tc->term_first = _tabs_term_first;
tc->term_last = _tabs_term_last;
tc->focused_term_get = _tabs_focused_term_get;
@@ -2975,62 +3135,111 @@ term_unfocus(Term *term)
tc->unfocus(tc, tc);
}
-Term *
-term_prev_get(const Term *term)
-{
- Term_Container *tc = term->container;
-
- return tc->term_prev(tc, tc);
-}
+enum term_to_direction {
+ TERM_TO_PREV,
+ TERM_TO_NEXT,
+ TERM_TO_UP,
+ TERM_TO_DOWN,
+ TERM_TO_LEFT,
+ TERM_TO_RIGHT,
+};
-void term_prev(Term *term)
+static void
+term_go_to(Term *from, enum term_to_direction dir)
{
Term *new_term, *focused_term;
- Win *wn = term->wn;
+ Win *wn = from->wn;
Term_Container *tc;
tc = (Term_Container *) wn;
focused_term = tc->focused_term_get(tc);
if (!focused_term)
- focused_term = term;
+ focused_term = from;
tc = focused_term->container;
- new_term = tc->term_prev(tc, tc);
+
+ switch (dir)
+ {
+ case TERM_TO_PREV:
+ new_term = tc->term_prev(tc, tc);
+ break;
+ case TERM_TO_NEXT:
+ new_term = tc->term_next(tc, tc);
+ break;
+ case TERM_TO_UP:
+ new_term = tc->term_up(tc, tc);
+ break;
+ case TERM_TO_DOWN:
+ new_term = tc->term_down(tc, tc);
+ break;
+ case TERM_TO_LEFT:
+ new_term = tc->term_left(tc, tc);
+ break;
+ case TERM_TO_RIGHT:
+ new_term = tc->term_right(tc, tc);
+ break;
+ }
+
if (new_term && new_term != focused_term)
_term_focus(new_term);
/* TODO: get rid of it? */
- _term_miniview_check(term);
+ _term_miniview_check(from);
}
-Term *
-term_next_get(const Term *term)
+void
+term_prev(Term *term)
{
- Term_Container *tc = term->container;
+ term_go_to(term, TERM_TO_PREV);
+}
- return tc->term_next(tc, tc);
+void
+term_next(Term *term)
+{
+ term_go_to(term, TERM_TO_NEXT);
}
-void term_next(Term *term)
+void
+term_up(Term *term)
{
- Term *new_term, *focused_term;
- Win *wn = term->wn;
- Term_Container *tc;
+ term_go_to(term, TERM_TO_UP);
+}
- tc = (Term_Container*) wn;
+void
+term_down(Term *term)
+{
+ term_go_to(term, TERM_TO_DOWN);
+}
- focused_term = tc->focused_term_get(tc);
- if (!focused_term)
- focused_term = term;
- tc = focused_term->container;
- new_term = tc->term_next(tc, tc);
- if (new_term && new_term != focused_term)
- _term_focus(new_term);
+void
+term_left(Term *term)
+{
+ term_go_to(term, TERM_TO_LEFT);
+}
- /* TODO: get rid of it? */
- _term_miniview_check(term);
+void
+term_right(Term *term)
+{
+ term_go_to(term, TERM_TO_RIGHT);
+}
+
+Term *
+term_prev_get(const Term *term)
+{
+ Term_Container *tc = term->container;
+
+ return tc->term_prev(tc, tc);
+}
+
+Term *
+term_next_get(const Term *term)
+{
+ Term_Container *tc = term->container;
+
+ return tc->term_next(tc, tc);
}
+
static void
_cb_popmedia_del(void *data,
Evas *_e EINA_UNUSED,
diff --git a/src/bin/win.h b/src/bin/win.h
index 27ca09e..5096175 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -54,6 +54,11 @@ void term_next(Term *term);
void term_prev(Term *term);
Win * term_win_get(const Term *term);
+void term_up(Term *term);
+void term_down(Term *term);
+void term_left(Term *term);
+void term_right(Term *term);
+
void
win_font_size_set(Win *wn, int new_size);