]> git.mdlowis.com Git - archive/afm.git/commitdiff
here's to the new cd. just like the old cd.
authora bellenir <a@bellenir.com>
Wed, 23 Jul 2014 23:50:35 +0000 (23:50 +0000)
committera bellenir <a@bellenir.com>
Wed, 23 Jul 2014 23:50:35 +0000 (23:50 +0000)
source/input.c
source/screen.c
source/workdir.c

index 26979c6af206f7b10908bf672e1ee26de29e2151..c615c97524751ca9fbd849060439fbced7cd5115 100644 (file)
@@ -13,7 +13,7 @@ void input_handle_key(char ch) {
                   break;
         case 'j': workdir_next(state_get_focused_frame()->workdir); break;
         case 'k': workdir_prev(state_get_focused_frame()->workdir); break;
-        //case 'e': workdir_cd(state_get_focused_frame()->workdir); break;
+        case 'e': workdir_cd(state_get_focused_frame()->workdir); break;
         case 'n': screen_open();
                   break;
         case 'c': screen_close();
index 89aed2bc2089a5b0a801527e209f2afdc10e2d88..44262a1bdf987610ca5395fb2d83b1c8f1869d05 100644 (file)
@@ -1,12 +1,18 @@
-#include "screen.h"
-#include "state.h"
-#include "aardvark.h"
-#include "workdir.h"
+/* external libraries */
 #include <ncurses.h>
 #include <unistd.h>
+#include <stdio.h>
+
+/* internal libraries */
 #include "vec.h"
 #include "mem.h"
 
+/* internal headers */
+#include "screen.h"
+#include "state.h"
+#include "aardvark.h"
+#include "workdir.h"
+
 static void screen_place_windows(void);
 static frame_t* screen_frame_new(void);
 static void screen_frame_free(void* p_frame);
index 80d54e44a2177075d67f9838a225f6cc8f654b71..7977a512d035753560024a5f4d8fc38ce663711f 100644 (file)
@@ -76,10 +76,9 @@ char* workdir_cd_up(WorkDir_T* wd){
        } else {
                newpath = mem_allocate(sizeof(char)*last_slash, NULL);
                strncpy(newpath, wd->path, last_slash);
-               newpath[last_slash-1]=0;
+               newpath[last_slash] = 0;
        }
-       mem_release(wd->path);
-       wd->path = newpath;
+       return newpath;
 }
 
 //go down a directory: append '/subdir' to path
@@ -94,14 +93,14 @@ char* workdir_cd_down(WorkDir_T* wd){
 }
 
 void workdir_cd(WorkDir_T* wd) {
-       char* newpath  = (wd->idx == 0) ? workdir_cd_up(wd) : workdir_cd_down(wd);
+       char* newpath = (wd->idx == 0) ? workdir_cd_up(wd) : workdir_cd_down(wd);
        if(is_dir(newpath)){
-               mem_release(wd->path);
+               //TODO: this segfaults: mem_release(wd->path);
                wd->path = newpath;
                wd->idx = 0;
                wd->top_index = 0;
        }
-    //TODO: refresh file list
+       workdir_ls(wd);
 }
 
 void workdir_ls(WorkDir_T* wd){