summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgodfath3r <galatsanosp@gmail.com>2015-08-05 12:40:54 +0300
committerBoris Faure <billiob@gmail.com>2015-08-05 21:55:56 +0200
commiteea13ce939d49265772a35a0c1dfe73473b44506 (patch)
tree024dad79b323ed1f529ed61b9f4b91a92c64b26d /src
parent423d06fed38cdbfb10b5a45fe048bae0217ad1ec (diff)
Don't split terminal endlessly.
Summary: Previously terminology would split the terminal as many times as user hit split button/shortcut. Now splitting is limited to only when there are at least 2 cells left. (horizontally or vertically) Also Fixes T2638 Reviewers: billiob Maniphest Tasks: T2638 Differential Revision: https://phab.enlightenment.org/D2915
Diffstat (limited to 'src')
-rw-r--r--src/bin/win.c88
1 files changed, 57 insertions, 31 deletions
diff --git a/src/bin/win.c b/src/bin/win.c
index 0225953..35a3887 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -910,6 +910,26 @@ _win_set_title(Term_Container *tc, Term_Container *child EINA_UNUSED,
910 elm_win_title_set(wn->win, title); 910 elm_win_title_set(wn->win, title);
911} 911}
912 912
913Eina_Bool
914_win_term_is_splittable(Term *tm, Eina_Bool is_horizontal)
915{
916 int grid_w = 0, grid_h = 0, c_w = 0, c_h = 0;
917 evas_object_geometry_get(tm->bg, NULL, NULL, &grid_w, &grid_h);
918 evas_object_textgrid_cell_size_get(termio_textgrid_get(tm->termio),
919 &c_w, &c_h);
920 if (is_horizontal)
921 {
922 if (c_h * 2 > grid_h)
923 return EINA_FALSE;
924 }
925 else
926 {
927 if (c_w * 2 > grid_w)
928 return EINA_FALSE;
929 }
930 return EINA_TRUE;
931}
932
913static void 933static void
914_win_split(Term_Container *tc, Term_Container *child, const char *cmd, 934_win_split(Term_Container *tc, Term_Container *child, const char *cmd,
915 Eina_Bool is_horizontal) 935 Eina_Bool is_horizontal)
@@ -925,22 +945,25 @@ _win_split(Term_Container *tc, Term_Container *child, const char *cmd,
925 wn = (Win*) tc; 945 wn = (Win*) tc;
926 946
927 tm = tc->focused_term_get(tc); 947 tm = tc->focused_term_get(tc);
928 if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) 948 if (_win_term_is_splittable(tm, is_horizontal))
929 wdir = buf; 949 {
930 tm_new = term_new(wn, wn->config, 950 if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
931 cmd, wn->config->login_shell, wdir, 951 wdir = buf;
932 80, 24, EINA_FALSE); 952 tm_new = term_new(wn, wn->config,
933 tc_solo_new = _solo_new(tm_new, wn); 953 cmd, wn->config->login_shell, wdir,
934 evas_object_data_set(tm_new->termio, "sizedone", tm_new->termio); 954 80, 24, EINA_FALSE);
935 955 tc_solo_new = _solo_new(tm_new, wn);
936 base = win_base_get(wn); 956 evas_object_data_set(tm_new->termio, "sizedone", tm_new->termio);
937 o = child->get_evas_object(child); 957
938 edje_object_part_unswallow(base, o); 958 base = win_base_get(wn);
959 o = child->get_evas_object(child);
960 edje_object_part_unswallow(base, o);
939 961
940 tc_split = _split_new(child, tc_solo_new, is_horizontal); 962 tc_split = _split_new(child, tc_solo_new, is_horizontal);
941 963
942 tc_split->is_focused = tc->is_focused; 964 tc_split->is_focused = tc->is_focused;
943 tc->swallow(tc, NULL, tc_split); 965 tc->swallow(tc, NULL, tc_split);
966 }
944} 967}
945 968
946static void 969static void
@@ -1399,27 +1422,30 @@ _split_split(Term_Container *tc, Term_Container *child,
1399 wn = tc->wn; 1422 wn = tc->wn;
1400 1423
1401 tm = child->focused_term_get(child); 1424 tm = child->focused_term_get(child);
1402 if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) 1425 if (_win_term_is_splittable(tm, is_horizontal))
1403 wdir = buf; 1426 {
1404 tm_new = term_new(wn, wn->config, 1427 if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
1405 cmd, wn->config->login_shell, wdir, 1428 wdir = buf;
1406 80, 24, EINA_FALSE); 1429 tm_new = term_new(wn, wn->config,
1407 tc_solo_new = _solo_new(tm_new, wn); 1430 cmd, wn->config->login_shell, wdir,
1408 evas_object_data_set(tm_new->termio, "sizedone", tm_new->termio); 1431 80, 24, EINA_FALSE);
1409 1432 tc_solo_new = _solo_new(tm_new, wn);
1410 if (child == split->tc1) 1433 evas_object_data_set(tm_new->termio, "sizedone", tm_new->termio);
1411 elm_object_part_content_unset(split->panes, PANES_TOP); 1434
1412 else 1435 if (child == split->tc1)
1413 elm_object_part_content_unset(split->panes, PANES_BOTTOM); 1436 elm_object_part_content_unset(split->panes, PANES_TOP);
1437 else
1438 elm_object_part_content_unset(split->panes, PANES_BOTTOM);
1414 1439
1415 tc_split = _split_new(child, tc_solo_new, is_horizontal); 1440 tc_split = _split_new(child, tc_solo_new, is_horizontal);
1416 1441
1417 obj_split = tc_split->get_evas_object(tc_split); 1442 obj_split = tc_split->get_evas_object(tc_split);
1418 1443
1419 tc_split->is_focused = tc->is_focused; 1444 tc_split->is_focused = tc->is_focused;
1420 tc->swallow(tc, child, tc_split); 1445 tc->swallow(tc, child, tc_split);
1421 1446
1422 evas_object_show(obj_split); 1447 evas_object_show(obj_split);
1448 }
1423} 1449}
1424 1450
1425static Term_Container * 1451static Term_Container *