use cwd of term when creating new ones with splits and tabs.

This commit is contained in:
Carsten Haitzler 2013-04-15 13:32:33 +09:00
parent f005e70d4a
commit fc60732d64
2 changed files with 9 additions and 4 deletions

View File

@ -214,6 +214,7 @@ _split_split(Split *sp, Eina_Bool horizontal)
Split *sp2; Split *sp2;
Evas_Object *o; Evas_Object *o;
Config *config; Config *config;
char buf[PATH_MAX], *wdir = NULL;
if (!sp->term) return; if (!sp->term) return;
@ -242,8 +243,9 @@ _split_split(Split *sp, Eina_Bool horizontal)
sp2->parent = sp; sp2->parent = sp;
sp2->wn = sp->wn; sp2->wn = sp->wn;
config = config_fork(sp->term->config); config = config_fork(sp->term->config);
if (termio_cwd_get(sp->term->term, buf, sizeof(buf))) wdir = buf;
sp2->term = main_term_new(sp->wn, config, sp2->term = main_term_new(sp->wn, config,
NULL, EINA_FALSE, NULL, NULL, EINA_FALSE, wdir,
80, 24, EINA_FALSE); 80, 24, EINA_FALSE);
sp2->terms = eina_list_append(sp2->terms, sp2->term); sp2->terms = eina_list_append(sp2->terms, sp2->term);
_term_resize_track_start(sp2); _term_resize_track_start(sp2);
@ -310,14 +312,16 @@ main_new(Evas_Object *win, Evas_Object *term)
Split *sp = _split_find(win, term); Split *sp = _split_find(win, term);
Config *config; Config *config;
int w, h; int w, h;
char buf[PATH_MAX], *wdir = NULL;
if (!sp) return; if (!sp) return;
_term_resize_track_stop(sp); _term_resize_track_stop(sp);
evas_object_hide(sp->term->bg); evas_object_hide(sp->term->bg);
config = config_fork(sp->term->config); config = config_fork(sp->term->config);
termio_size_get(sp->term->term, &w, &h); termio_size_get(sp->term->term, &w, &h);
if (termio_cwd_get(sp->term->term, buf, sizeof(buf))) wdir = buf;
sp->term = main_term_new(sp->wn, config, sp->term = main_term_new(sp->wn, config,
NULL, EINA_FALSE, NULL, NULL, EINA_FALSE, wdir,
w, h, EINA_FALSE); w, h, EINA_FALSE);
sp->terms = eina_list_append(sp->terms, sp->term); sp->terms = eina_list_append(sp->terms, sp->term);
_term_resize_track_start(sp); _term_resize_track_start(sp);

View File

@ -3555,18 +3555,19 @@ termio_cwd_get(const Evas_Object *obj, char *buf, size_t size)
char procpath[PATH_MAX]; char procpath[PATH_MAX];
Termio *sd = evas_object_smart_data_get(obj); Termio *sd = evas_object_smart_data_get(obj);
pid_t pid; pid_t pid;
ssize_t siz;
if (!sd) return EINA_FALSE; if (!sd) return EINA_FALSE;
pid = termpty_pid_get(sd->pty); pid = termpty_pid_get(sd->pty);
snprintf(procpath, sizeof(procpath), "/proc/%d/cwd", pid); snprintf(procpath, sizeof(procpath), "/proc/%d/cwd", pid);
if (readlink(procpath, buf, size) < 1) if ((siz = readlink(procpath, buf, size)) < 1)
{ {
ERR("Could not load working directory %s: %s", ERR("Could not load working directory %s: %s",
procpath, strerror(errno)); procpath, strerror(errno));
return EINA_FALSE; return EINA_FALSE;
} }
buf[siz] = 0;
return EINA_TRUE; return EINA_TRUE;
} }