Option to disable cd to current tab dir.

Summary: Adding option to disable cd to current tab dir.

Test Plan:
1. Start unpatched version of Terminology.
2. Change some Behaviour options.
3. Close unpatched version of Terminology.
4. Start patched version of Terminology.
5. cd /usr/bin
6. Open new tab and verify that previous behaviour persists, new tab working directory is /usr/bin
7. Go to Settings Behaviour and uncheck "Start in the same directory..." checkbox.
8. Optn new tab and verify that new tab working directory is ~ (or any other directory from which the Terminology was launched).
9. Restart Terminology.
10. Go to Settings Behaviour and verify that options persisted.

Reviewers: #terminology, billiob

Subscribers: godfath3r, #terminology

Projects: #terminology

Differential Revision: https://phab.enlightenment.org/D3495
This commit is contained in:
Stanislav Baiduzhyi 2015-12-26 11:59:08 +01:00 committed by Boris Faure
parent 2f3d2a9447
commit 33d20a1f98
4 changed files with 50 additions and 20 deletions

View File

@ -7,7 +7,7 @@
#include "col.h"
#include "utils.h"
#define CONF_VER 6
#define CONF_VER 7
#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
@ -165,6 +165,8 @@ config_init(void)
(edd_base, Config, "mv_always_show", mv_always_show, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC
(edd_base, Config, "ty_escapes", ty_escapes, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC
(edd_base, Config, "changedir_to_current", changedir_to_current, EET_T_UCHAR);
}
void
@ -265,6 +267,7 @@ config_sync(const Config *config_src, Config *config)
config->notabs = config_src->notabs;
config->mv_always_show = config_src->mv_always_show;
config->ty_escapes = config_src->ty_escapes;
config->changedir_to_current = config_src->changedir_to_current;
}
static void
@ -480,6 +483,7 @@ config_new(void)
config->notabs = EINA_FALSE;
config->mv_always_show = EINA_FALSE;
config->ty_escapes = EINA_TRUE;
config->changedir_to_current = EINA_TRUE;
for (j = 0; j < 4; j++)
{
for (i = 0; i < 12; i++)
@ -549,7 +553,10 @@ config_load(const char *key)
case 5:
config->ty_escapes = EINA_TRUE;
/*pass through*/
case CONF_VER: /* 6 */
case 6:
config->changedir_to_current = EINA_TRUE;
/*pass through*/
case CONF_VER: /* 7 */
config->version = CONF_VER;
break;
default:
@ -645,6 +652,7 @@ config_fork(Config *config)
CPY(notabs);
CPY(mv_always_show);
CPY(ty_escapes);
CPY(changedir_to_current);
EINA_LIST_FOREACH(config->keys, l, key)
{

View File

@ -76,6 +76,7 @@ struct _Config
Eina_Bool notabs;
Eina_Bool mv_always_show;
Eina_Bool ty_escapes;
Eina_Bool changedir_to_current;
Config_Color colors[(4 * 12)];
Eina_List *keys;

View File

@ -43,6 +43,7 @@ CB(gravatar, 0);
CB(notabs, 1);
CB(mv_always_show, 0);
CB(ty_escapes, 0);
CB(changedir_to_current, 0);
#undef CB
@ -193,6 +194,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
CX(_("Show tabs"), notabs, 1);
CX(_("Always show miniview"), mv_always_show, 0);
CX(_("Enable special Terminology escape codes"), ty_escapes, 0);
CX(_("Open new terminals in current working directory"), changedir_to_current, 0);
#undef CX

View File

@ -952,16 +952,22 @@ _win_split(Term_Container *tc, Term_Container *child,
{
Term *tm_new, *tm;
Term_Container *tc_split, *tc_solo_new;
char buf[PATH_MAX], *wdir = NULL;
char *wdir = NULL;
Evas_Object *base;
Evas_Object *o;
if (from)
tm = from;
else
tm = tc->focused_term_get(tc);
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
// copy the current path to wdir if we should change the directory,
// passing wdir NULL otherwise:
if (wn->config->changedir_to_current)
{
if (from)
tm = from;
else
tm = tc->focused_term_get(tc);
char buf[PATH_MAX];
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
}
tm_new = term_new(wn, wn->config,
cmd, wn->config->login_shell, wdir,
80, 24, EINA_FALSE);
@ -1438,16 +1444,22 @@ _split_split(Term_Container *tc, Term_Container *child,
if (_term_container_is_splittable(tc, is_horizontal))
{
Term *tm_new, *tm;
char buf[PATH_MAX], *wdir = NULL;
char *wdir = NULL;
Term_Container *tc_split, *tc_solo_new;
Evas_Object *obj_split;
if (from)
tm = from;
else
tm = child->focused_term_get(child);
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
// copy the current path to wdir if we should change the directory,
// passing wdir NULL otherwise:
if (wn->config->changedir_to_current)
{
if (from)
tm = from;
else
tm = child->focused_term_get(child);
char buf[PATH_MAX];
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
}
tm_new = term_new(wn, wn->config,
cmd, wn->config->login_shell, wdir,
80, 24, EINA_FALSE);
@ -2326,11 +2338,18 @@ _tab_new_cb(void *data,
*tc_new, *tc_parent, *tc_old;
Term *tm, *tm_new;
Win *wn = tc->wn;
char buf[PATH_MAX], *wdir = NULL;
char *wdir = NULL;
// copy the current path to wdir if we should change the directory,
// passing wdir NULL otherwise:
if (wn->config->changedir_to_current)
{
char buf[PATH_MAX];
tm = tc->focused_term_get(tc);
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
}
tm = tc->focused_term_get(tc);
if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
wdir = buf;
tm_new = term_new(wn, wn->config,
NULL, wn->config->login_shell, wdir,
80, 24, EINA_FALSE);