raster pushed a commit to branch master.

commit fc60732d6498d19da983a98dfc181ab8b260edba
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Mon Apr 15 13:32:33 2013 +0900

    use cwd of term when creating new ones with splits and tabs.
---
 src/bin/main.c   | 8 ++++++--
 src/bin/termio.c | 5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 7006a15..89d9c8d 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -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);
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 121be37..4df0dc9 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -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;
 }
 

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to