summaryrefslogtreecommitdiff
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
parent6f1a2dd45201c3b8432a1e84ca9fd144bdff8483 (diff)
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
63Alt+Home = Enter command mode (enter commands to control terminology itself) 63Alt+Home = Enter command mode (enter commands to control terminology itself)
64Alt+Return = Paste primary selection 64Alt+Return = Paste primary selection
65Alt+w = Copy selection to primary 65Alt+w = Copy selection to primary
66Alt+Up = Focus the terminal above
67Alt+Down = Focus the terminal below
68Alt+Left = Focus the terminal on the left
69Alt+Right = Focus the terminal on the right
66Ctrl+Alt+Equal = Font size up 1 70Ctrl+Alt+Equal = Font size up 1
67Ctrl+Alt+Minus = Font size down 1 71Ctrl+Alt+Minus = Font size down 1
68Ctrl+Alt+0 = Reset font size 72Ctrl+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.
292Copy selection to primary. 292Copy selection to primary.
293. 293.
294.TP 294.TP
295.B Alt+Up
296Focus the terminal above
297.
298.TP
299.B Alt+Down
300Focus the terminal down
301.
302.TP
303.B Alt+Left
304Focus the terminal on the left
305.
306.TP
307.B Alt+Right
308Focus the terminal on the right
309.
310.TP
295.B Ctrl+Shift+c 311.B Ctrl+Shift+c
296Copy current selection to clipboard. 312Copy current selection to clipboard.
297. 313.
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 @@
7#include "col.h" 7#include "col.h"
8#include "utils.h" 8#include "utils.h"
9 9
10#define CONF_VER 15 10#define CONF_VER 16
11 11
12#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;} 12#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
13 13
@@ -336,6 +336,10 @@ _add_default_keys(Config *config)
336 ADD_KB("Home", 0, 1, 0, 0, "cmd_box"); 336 ADD_KB("Home", 0, 1, 0, 0, "cmd_box");
337 ADD_KB("w", 0, 1, 0, 0, "copy_primary"); 337 ADD_KB("w", 0, 1, 0, 0, "copy_primary");
338 ADD_KB("Return", 0, 1, 0, 0, "paste_primary"); 338 ADD_KB("Return", 0, 1, 0, 0, "paste_primary");
339 ADD_KB("Up", 0, 1, 0, 0, "term_up");
340 ADD_KB("Down", 0, 1, 0, 0, "term_down");
341 ADD_KB("Left", 0, 1, 0, 0, "term_left");
342 ADD_KB("Right", 0, 1, 0, 0, "term_right");
339 343
340 /* Ctrl-Shift- */ 344 /* Ctrl-Shift- */
341 ADD_KB("Prior", 1, 0, 1, 0, "split_h"); 345 ADD_KB("Prior", 1, 0, 1, 0, "split_h");
@@ -619,7 +623,13 @@ config_load(const char *key)
619 case 14: 623 case 14:
620 config->disable_focus_visuals = EINA_FALSE; 624 config->disable_focus_visuals = EINA_FALSE;
621 /*pass through*/ 625 /*pass through*/
622 case CONF_VER: /* 15 */ 626 case 15:
627 _add_key(config, "Up", 0, 1, 0, 0, "term_up");
628 _add_key(config, "Down", 0, 1, 0, 0, "term_down");
629 _add_key(config, "Left", 0, 1, 0, 0, "term_left");
630 _add_key(config, "Right", 0, 1, 0, 0, "term_right");
631 /*pass through*/
632 case CONF_VER: /* 16 */
623 config->version = CONF_VER; 633 config->version = CONF_VER;
624 break; 634 break;
625 default: 635 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)
367} 367}
368 368
369static Eina_Bool 369static Eina_Bool
370cb_term_up(Evas_Object *termio_obj)
371{
372 Term *term = termio_term_get(termio_obj);
373 if (!term)
374 return EINA_FALSE;
375 term_up(term);
376 return EINA_TRUE;
377}
378
379static Eina_Bool
380cb_term_down(Evas_Object *termio_obj)
381{
382 Term *term = termio_term_get(termio_obj);
383 if (!term)
384 return EINA_FALSE;
385 term_down(term);
386 return EINA_TRUE;
387}
388
389static Eina_Bool
390cb_term_left(Evas_Object *termio_obj)
391{
392 Term *term = termio_term_get(termio_obj);
393 if (!term)
394 return EINA_FALSE;
395 term_left(term);
396 return EINA_TRUE;
397}
398
399static Eina_Bool
400cb_term_right(Evas_Object *termio_obj)
401{
402 Term *term = termio_term_get(termio_obj);
403 if (!term)
404 return EINA_FALSE;
405 term_right(term);
406 return EINA_TRUE;
407}
408
409static Eina_Bool
370cb_term_new(Evas_Object *termio_obj) 410cb_term_new(Evas_Object *termio_obj)
371{ 411{
372 char path[PATH_MAX], cwd[PATH_MAX], *cmd; 412 char path[PATH_MAX], cwd[PATH_MAX], *cmd;
@@ -645,8 +685,12 @@ static Shortcut_Action _actions[] =
645 {"paste_clipboard", gettext_noop("Paste Clipboard buffer (ctrl+c/v)"), cb_paste_clipboard}, 685 {"paste_clipboard", gettext_noop("Paste Clipboard buffer (ctrl+c/v)"), cb_paste_clipboard},
646 686
647 {"group", gettext_noop("Splits/Tabs"), NULL}, 687 {"group", gettext_noop("Splits/Tabs"), NULL},
648 {"term_prev", gettext_noop("Focus to the previous terminal"), cb_term_prev}, 688 {"term_prev", gettext_noop("Focus the previous terminal"), cb_term_prev},
649 {"term_next", gettext_noop("Focus to the next terminal"), cb_term_next}, 689 {"term_next", gettext_noop("Focus the next terminal"), cb_term_next},
690 {"term_up", gettext_noop("Focus the terminal above"), cb_term_up},
691 {"term_down", gettext_noop("Focus the terminal below"), cb_term_down},
692 {"term_left", gettext_noop("Focus the terminal on the left"), cb_term_left},
693 {"term_right", gettext_noop("Focus the terminal on the right"), cb_term_right},
650 {"split_h", gettext_noop("Split horizontally (new below)"), cb_split_h}, 694 {"split_h", gettext_noop("Split horizontally (new below)"), cb_split_h},
651 {"split_v", gettext_noop("Split vertically (new on right)"), cb_split_v}, 695 {"split_v", gettext_noop("Split vertically (new on right)"), cb_split_v},
652 {"tab_new", gettext_noop("Create a new \"tab\""), cb_tab_new}, 696 {"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 {
39 39
40 Term *(*term_next)(const Term_Container *tc, const Term_Container *child); 40 Term *(*term_next)(const Term_Container *tc, const Term_Container *child);
41 Term *(*term_prev)(const Term_Container *tc, const Term_Container *child); 41 Term *(*term_prev)(const Term_Container *tc, const Term_Container *child);
42 Term *(*term_up)(const Term_Container *tc, const Term_Container *child);
43 Term *(*term_down)(const Term_Container *tc, const Term_Container *child);
44 Term *(*term_left)(const Term_Container *tc, const Term_Container *child);
45 Term *(*term_right)(const Term_Container *tc, const Term_Container *child);
42 Term *(*term_first)(const Term_Container *tc); 46 Term *(*term_first)(const Term_Container *tc);
43 Term *(*term_last)(const Term_Container *tc); 47 Term *(*term_last)(const Term_Container *tc);
44 Term *(*focused_term_get)(const Term_Container *tc); 48 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,
297} 297}
298 298
299static Term * 299static Term *
300_solo_term_up(const Term_Container *tc,
301 const Term_Container *_child EINA_UNUSED)
302{
303 return tc->parent->term_up(tc->parent, tc);
304}
305
306static Term *
307_solo_term_down(const Term_Container *tc,
308 const Term_Container *_child EINA_UNUSED)
309{
310 return tc->parent->term_down(tc->parent, tc);
311}
312
313static Term *
314_solo_term_left(const Term_Container *tc,
315 const Term_Container *_child EINA_UNUSED)
316{
317 return tc->parent->term_left(tc->parent, tc);
318}
319
320static Term *
321_solo_term_right(const Term_Container *tc,
322 const Term_Container *_child EINA_UNUSED)
323{
324 return tc->parent->term_right(tc->parent, tc);
325}
326
327static Term *
300_solo_term_first(const Term_Container *tc) 328_solo_term_first(const Term_Container *tc)
301{ 329{
302 Solo *solo; 330 Solo *solo;
@@ -449,6 +477,10 @@ _solo_new(Term *term, Win *wn)
449 tc = (Term_Container*)solo; 477 tc = (Term_Container*)solo;
450 tc->term_next = _solo_term_next; 478 tc->term_next = _solo_term_next;
451 tc->term_prev = _solo_term_prev; 479 tc->term_prev = _solo_term_prev;
480 tc->term_up = _solo_term_up;
481 tc->term_down = _solo_term_down;
482 tc->term_left = _solo_term_left;
483 tc->term_right = _solo_term_right;
452 tc->term_first = _solo_term_first; 484 tc->term_first = _solo_term_first;
453 tc->term_last = _solo_term_last; 485 tc->term_last = _solo_term_last;
454 tc->focused_term_get = _solo_focused_term_get; 486 tc->focused_term_get = _solo_focused_term_get;
@@ -786,6 +818,34 @@ _win_term_prev(const Term_Container *_tc EINA_UNUSED,
786} 818}
787 819
788static Term * 820static Term *
821_win_term_up(const Term_Container *_tc EINA_UNUSED,
822 const Term_Container *child EINA_UNUSED)
823{
824 return NULL;
825}
826
827static Term *
828_win_term_down(const Term_Container *_tc EINA_UNUSED,
829 const Term_Container *child EINA_UNUSED)
830{
831 return NULL;
832}
833
834static Term *
835_win_term_left(const Term_Container *_tc EINA_UNUSED,
836 const Term_Container *child EINA_UNUSED)
837{
838 return NULL;
839}
840
841static Term *
842_win_term_right(const Term_Container *_tc EINA_UNUSED,
843 const Term_Container *child EINA_UNUSED)
844{
845 return NULL;
846}
847
848static Term *
789_win_term_first(const Term_Container *tc) 849_win_term_first(const Term_Container *tc)
790{ 850{
791 Win *wn; 851 Win *wn;
@@ -1060,6 +1120,10 @@ win_new(const char *name, const char *role, const char *title,
1060 tc = (Term_Container*) wn; 1120 tc = (Term_Container*) wn;
1061 tc->term_next = _win_term_next; 1121 tc->term_next = _win_term_next;
1062 tc->term_prev = _win_term_prev; 1122 tc->term_prev = _win_term_prev;
1123 tc->term_up = _win_term_up;
1124 tc->term_down = _win_term_down;
1125 tc->term_left = _win_term_left;
1126 tc->term_right = _win_term_right;
1063 tc->term_first = _win_term_first; 1127 tc->term_first = _win_term_first;
1064 tc->term_last = _win_term_last; 1128 tc->term_last = _win_term_last;
1065 tc->focused_term_get = _win_focused_term_get; 1129 tc->focused_term_get = _win_focused_term_get;
@@ -1174,6 +1238,66 @@ _split_term_prev(const Term_Container *tc, const Term_Container *child)
1174} 1238}
1175 1239
1176static Term * 1240static Term *
1241_split_term_up(const Term_Container *tc,
1242 const Term_Container *child)
1243{
1244 Split *split;
1245
1246 assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
1247 split = (Split*) tc;
1248
1249 if (child == split->tc2 && split->is_horizontal)
1250 return split->tc1->term_last(split->tc1);
1251 else
1252 return tc->parent->term_up(tc->parent, tc);
1253}
1254
1255static Term *
1256_split_term_down(const Term_Container *tc,
1257 const Term_Container *child)
1258{
1259 Split *split;
1260
1261 assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
1262 split = (Split*) tc;
1263
1264 if (child == split->tc1 && split->is_horizontal)
1265 return split->tc2->term_first(split->tc2);
1266 else
1267 return tc->parent->term_down(tc->parent, tc);
1268}
1269
1270static Term *
1271_split_term_left(const Term_Container *tc,
1272 const Term_Container *child)
1273{
1274 Split *split;
1275
1276 assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
1277 split = (Split*) tc;
1278
1279 if (child == split->tc2 && !split->is_horizontal)
1280 return split->tc1->term_last(split->tc1);
1281 else
1282 return tc->parent->term_left(tc->parent, tc);
1283}
1284
1285static Term *
1286_split_term_right(const Term_Container *tc,
1287 const Term_Container *child)
1288{
1289 Split *split;
1290
1291 assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
1292 split = (Split*) tc;
1293
1294 if (child == split->tc1 && !split->is_horizontal)
1295 return split->tc2->term_first(split->tc2);
1296 else
1297 return tc->parent->term_right(tc->parent, tc);
1298}
1299
1300static Term *
1177_split_term_first(const Term_Container *tc) 1301_split_term_first(const Term_Container *tc)
1178{ 1302{
1179 Split *split; 1303 Split *split;
@@ -1545,6 +1669,10 @@ _split_new(Term_Container *tc1, Term_Container *tc2,
1545 tc = (Term_Container*)split; 1669 tc = (Term_Container*)split;
1546 tc->term_next = _split_term_next; 1670 tc->term_next = _split_term_next;
1547 tc->term_prev = _split_term_prev; 1671 tc->term_prev = _split_term_prev;
1672 tc->term_up = _split_term_up;
1673 tc->term_down = _split_term_down;
1674 tc->term_left = _split_term_left;
1675 tc->term_right = _split_term_right;
1548 tc->term_first = _split_term_first; 1676 tc->term_first = _split_term_first;
1549 tc->term_last = _split_term_last; 1677 tc->term_last = _split_term_last;
1550 tc->focused_term_get = _split_focused_term_get; 1678 tc->focused_term_get = _split_focused_term_get;
@@ -2331,6 +2459,34 @@ _tabs_term_prev(const Term_Container *tc, const Term_Container *child)
2331} 2459}
2332 2460
2333static Term * 2461static Term *
2462_tabs_term_up(const Term_Container *tc,
2463 const Term_Container *_child EINA_UNUSED)
2464{
2465 return tc->parent->term_up(tc->parent, tc);
2466}
2467
2468static Term *
2469_tabs_term_down(const Term_Container *tc,
2470 const Term_Container *_child EINA_UNUSED)
2471{
2472 return tc->parent->term_down(tc->parent, tc);
2473}
2474
2475static Term *
2476_tabs_term_left(const Term_Container *tc,
2477 const Term_Container *_child EINA_UNUSED)
2478{
2479 return tc->parent->term_left(tc->parent, tc);
2480}
2481
2482static Term *
2483_tabs_term_right(const Term_Container *tc,
2484 const Term_Container *_child EINA_UNUSED)
2485{
2486 return tc->parent->term_right(tc->parent, tc);
2487}
2488
2489static Term *
2334_tabs_term_first(const Term_Container *tc) 2490_tabs_term_first(const Term_Container *tc)
2335{ 2491{
2336 Tabs *tabs; 2492 Tabs *tabs;
@@ -2804,6 +2960,10 @@ _tabs_new(Term_Container *child, Term_Container *parent)
2804 tc = (Term_Container*)tabs; 2960 tc = (Term_Container*)tabs;
2805 tc->term_next = _tabs_term_next; 2961 tc->term_next = _tabs_term_next;
2806 tc->term_prev = _tabs_term_prev; 2962 tc->term_prev = _tabs_term_prev;
2963 tc->term_up = _tabs_term_up;
2964 tc->term_down = _tabs_term_down;
2965 tc->term_left = _tabs_term_left;
2966 tc->term_right = _tabs_term_right;
2807 tc->term_first = _tabs_term_first; 2967 tc->term_first = _tabs_term_first;
2808 tc->term_last = _tabs_term_last; 2968 tc->term_last = _tabs_term_last;
2809 tc->focused_term_get = _tabs_focused_term_get; 2969 tc->focused_term_get = _tabs_focused_term_get;
@@ -2975,62 +3135,111 @@ term_unfocus(Term *term)
2975 tc->unfocus(tc, tc); 3135 tc->unfocus(tc, tc);
2976} 3136}
2977 3137
2978Term * 3138enum term_to_direction {
2979term_prev_get(const Term *term) 3139 TERM_TO_PREV,
2980{ 3140 TERM_TO_NEXT,
2981 Term_Container *tc = term->container; 3141 TERM_TO_UP,
2982 3142 TERM_TO_DOWN,
2983 return tc->term_prev(tc, tc); 3143 TERM_TO_LEFT,
2984} 3144 TERM_TO_RIGHT,
3145};
2985 3146
2986void term_prev(Term *term) 3147static void
3148term_go_to(Term *from, enum term_to_direction dir)
2987{ 3149{
2988 Term *new_term, *focused_term; 3150 Term *new_term, *focused_term;
2989 Win *wn = term->wn; 3151 Win *wn = from->wn;
2990 Term_Container *tc; 3152 Term_Container *tc;
2991 3153
2992 tc = (Term_Container *) wn; 3154 tc = (Term_Container *) wn;
2993 3155
2994 focused_term = tc->focused_term_get(tc); 3156 focused_term = tc->focused_term_get(tc);
2995 if (!focused_term) 3157 if (!focused_term)
2996 focused_term = term; 3158 focused_term = from;
2997 tc = focused_term->container; 3159 tc = focused_term->container;
2998 new_term = tc->term_prev(tc, tc); 3160
3161 switch (dir)
3162 {
3163 case TERM_TO_PREV:
3164 new_term = tc->term_prev(tc, tc);
3165 break;
3166 case TERM_TO_NEXT:
3167 new_term = tc->term_next(tc, tc);
3168 break;
3169 case TERM_TO_UP:
3170 new_term = tc->term_up(tc, tc);
3171 break;
3172 case TERM_TO_DOWN:
3173 new_term = tc->term_down(tc, tc);
3174 break;
3175 case TERM_TO_LEFT:
3176 new_term = tc->term_left(tc, tc);
3177 break;
3178 case TERM_TO_RIGHT:
3179 new_term = tc->term_right(tc, tc);
3180 break;
3181 }
3182
2999 if (new_term && new_term != focused_term) 3183 if (new_term && new_term != focused_term)
3000 _term_focus(new_term); 3184 _term_focus(new_term);
3001 3185
3002 /* TODO: get rid of it? */ 3186 /* TODO: get rid of it? */
3003 _term_miniview_check(term); 3187 _term_miniview_check(from);
3004} 3188}
3005 3189
3006Term * 3190void
3007term_next_get(const Term *term) 3191term_prev(Term *term)
3008{ 3192{
3009 Term_Container *tc = term->container; 3193 term_go_to(term, TERM_TO_PREV);
3194}
3010 3195
3011 return tc->term_next(tc, tc); 3196void
3197term_next(Term *term)
3198{
3199 term_go_to(term, TERM_TO_NEXT);
3012} 3200}
3013 3201
3014void term_next(Term *term) 3202void
3203term_up(Term *term)
3015{ 3204{
3016 Term *new_term, *focused_term; 3205 term_go_to(term, TERM_TO_UP);
3017 Win *wn = term->wn; 3206}
3018 Term_Container *tc;
3019 3207
3020 tc = (Term_Container*) wn; 3208void
3209term_down(Term *term)
3210{
3211 term_go_to(term, TERM_TO_DOWN);
3212}
3021 3213
3022 focused_term = tc->focused_term_get(tc); 3214void
3023 if (!focused_term) 3215term_left(Term *term)
3024 focused_term = term; 3216{
3025 tc = focused_term->container; 3217 term_go_to(term, TERM_TO_LEFT);
3026 new_term = tc->term_next(tc, tc); 3218}
3027 if (new_term && new_term != focused_term)
3028 _term_focus(new_term);
3029 3219
3030 /* TODO: get rid of it? */ 3220void
3031 _term_miniview_check(term); 3221term_right(Term *term)
3222{
3223 term_go_to(term, TERM_TO_RIGHT);
3224}
3225
3226Term *
3227term_prev_get(const Term *term)
3228{
3229 Term_Container *tc = term->container;
3230
3231 return tc->term_prev(tc, tc);
3232}
3233
3234Term *
3235term_next_get(const Term *term)
3236{
3237 Term_Container *tc = term->container;
3238
3239 return tc->term_next(tc, tc);
3032} 3240}
3033 3241
3242
3034static void 3243static void
3035_cb_popmedia_del(void *data, 3244_cb_popmedia_del(void *data,
3036 Evas *_e EINA_UNUSED, 3245 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);
54void term_prev(Term *term); 54void term_prev(Term *term);
55Win * term_win_get(const Term *term); 55Win * term_win_get(const Term *term);
56 56
57void term_up(Term *term);
58void term_down(Term *term);
59void term_left(Term *term);
60void term_right(Term *term);
61
57void 62void
58win_font_size_set(Win *wn, int new_size); 63win_font_size_set(Win *wn, int new_size);
59 64