diff options
| -rw-r--r-- | src/fm.c | 24 | ||||
| -rw-r--r-- | src/fm.h | 3 | ||||
| -rw-r--r-- | src/keys.c | 3 |
3 files changed, 30 insertions, 0 deletions
@@ -4,6 +4,7 @@ #include "err.h" #include "log.h" #include "process.h" +#include "utils.h" #include "wm.h" #include <curses.h> #include <dirent.h> @@ -491,3 +492,26 @@ draw_status_bar(window *bar_win, const char *cwd, char permission[11]) permission); wattroff(bar_win->win, COLOR_PAIR(COLOR_PAIR_FM_STATUS_BAR)); } + +int +new_dir(fm_info *info) +{ + const char *cwd = info->cwd; + char buf[PATH_MAX] = {0}; + if (get_input("Directory name: ", buf) != 0) { + return -1; + } + + char *path; + if (asprintf(&path, "%s/%s", cwd, buf) < 0) + return -1; + + if (mkdir(path, 0755) != 0) { + return -1; + } + + free(path); + need_redraw = true; + fm_getdir(info->cur, info->cwd); + return 0; +} @@ -45,6 +45,7 @@ extern bool need_redraw; #define ENV_EDITOR 1 #define ENV_SF 2 +extern char *enveditor; extern window *status_window; file_list *fm_getdir(file_list *list, const char *path); @@ -67,4 +68,6 @@ void create_status_bar_win(terminal *t); void draw_status_bar(window *bar_win, const char *cwd, char permission[11]); void get_permission(mode_t mode, char *str); +int new_dir(fm_info *info); + #endif /* SF_FM_H */ @@ -60,6 +60,9 @@ handling_keys(int ch, fm_info *i) return; } break; + case '+': + new_dir(i); + break; default: return; } |
