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
This commit is contained in:
godfath3r 2015-08-05 12:40:54 +03:00 committed by Boris Faure
parent 423d06fed3
commit eea13ce939
1 changed files with 55 additions and 29 deletions

View File

@ -910,6 +910,26 @@ _win_set_title(Term_Container *tc, Term_Container *child EINA_UNUSED,
elm_win_title_set(wn->win, title);
}
Eina_Bool
_win_term_is_splittable(Term *tm, Eina_Bool is_horizontal)
{
int grid_w = 0, grid_h = 0, c_w = 0, c_h = 0;
evas_object_geometry_get(tm->bg, NULL, NULL, &grid_w, &grid_h);
evas_object_textgrid_cell_size_get(termio_textgrid_get(tm->termio),
&c_w, &c_h);
if (is_horizontal)
{
if (c_h * 2 > grid_h)
return EINA_FALSE;
}
else
{
if (c_w * 2 > grid_w)
return EINA_FALSE;
}
return EINA_TRUE;
}
static void
_win_split(Term_Container *tc, Term_Container *child, const char *cmd,
Eina_Bool is_horizontal)
@ -925,6 +945,8 @@ _win_split(Term_Container *tc, Term_Container *child, const char *cmd,
wn = (Win*) tc;
tm = tc->focused_term_get(tc);
if (_win_term_is_splittable(tm, is_horizontal))
{
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
tm_new = term_new(wn, wn->config,
@ -941,6 +963,7 @@ _win_split(Term_Container *tc, Term_Container *child, const char *cmd,
tc_split->is_focused = tc->is_focused;
tc->swallow(tc, NULL, tc_split);
}
}
static void
@ -1399,6 +1422,8 @@ _split_split(Term_Container *tc, Term_Container *child,
wn = tc->wn;
tm = child->focused_term_get(child);
if (_win_term_is_splittable(tm, is_horizontal))
{
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
tm_new = term_new(wn, wn->config,
@ -1420,6 +1445,7 @@ _split_split(Term_Container *tc, Term_Container *child,
tc->swallow(tc, child, tc_split);
evas_object_show(obj_split);
}
}
static Term_Container *