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;
Evas_Object *o;
Config *config;
char buf[PATH_MAX], *wdir = NULL;
if (!sp->term) return;
@ -242,8 +243,9 @@ _split_split(Split *sp, Eina_Bool horizontal)
sp2->parent = sp;
sp2->wn = sp->wn;
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,
NULL, EINA_FALSE, NULL,
NULL, EINA_FALSE, wdir,
80, 24, EINA_FALSE);
sp2->terms = eina_list_append(sp2->terms, sp2->term);
_term_resize_track_start(sp2);
@ -310,14 +312,16 @@ main_new(Evas_Object *win, Evas_Object *term)
Split *sp = _split_find(win, term);
Config *config;
int w, h;
char buf[PATH_MAX], *wdir = NULL;
if (!sp) return;
_term_resize_track_stop(sp);
evas_object_hide(sp->term->bg);
config = config_fork(sp->term->config);
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,
NULL, EINA_FALSE, NULL,
NULL, EINA_FALSE, wdir,
w, h, EINA_FALSE);
sp->terms = eina_list_append(sp->terms, sp->term);
_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];
Termio *sd = evas_object_smart_data_get(obj);
pid_t pid;
ssize_t siz;
if (!sd) return EINA_FALSE;
pid = termpty_pid_get(sd->pty);
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",
procpath, strerror(errno));
return EINA_FALSE;
}
buf[siz] = 0;
return EINA_TRUE;
}