diff --git a/config.h b/config.h index 1743379..145feb2 100644 --- a/config.h +++ b/config.h @@ -15,6 +15,9 @@ /* }}} */ static const char clipboard_cmd[] = "echo ^ | xsel -ib --trim"; /*used in yank_text*/ +static const char rename_cmd[] = "mv"; /* as used in rename_hovered, makedir and makefile */ +static const char makefile_cmd[] = "touch"; /*as of now both only do ``rename_cmd new_name``*/ +static const char makedir_cmd[] = "mkdir"; static const mimetype mimetype_default_cmd[] = { /* mimetype shell command @@ -120,9 +123,9 @@ static const char ui_btm_text_storage_left[] = "total free"; static const char ui_btm_current_dir_size[] = "sum of dir,"; static const char ui_open_with_text[] = "open "SETTINGS_COMMAND_REPLACE_STR" with:"; static const char ui_rename_text[] = "rename "SETTINGS_COMMAND_REPLACE_STR" to:"; -static const char ui_mkdir_text[] = "mkdir:"; -static const char ui_touch_text[] = "touch:"; -static const char ui_delete_text[] = "delete: "SETTINGS_COMMAND_REPLACE_STR; +static const char ui_makefile_text[] = "makedir:"; +static const char ui_makedir_text[] = "makefile:"; +static const char ui_delete_text[] = "delete:"; /* {{{ */ static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding); @@ -131,6 +134,9 @@ static const unsigned long file_extension_default_count = sizeof(file_extension_ static const char size_unit_count = (sizeof(size_unit) / sizeof(size_unit[0])) - 1; #else static const char clipboard_cmd[]; +static const char rename_cmd[]; +static const char makefile_cmd[]; +static const char makedir_cmd[]; static const mimetype mimetype_default_cmd[]; static const extension file_extension_default_cmd[]; static const binding key_binding[]; @@ -140,9 +146,9 @@ static const unsigned long file_extension_default_count; static const char size_unit[]; static const char size_unit_count; static const char ui_open_with_text[]; +static const char ui_makedir_text[]; +static const char ui_makefile_text[]; static const char ui_rename_text[]; -static const char ui_mkdir_text[]; -static const char ui_touch_text[]; static const char ui_delete_text[]; #endif /* }}} */ diff --git a/interactions.c b/interactions.c index 49d06e2..0d4b501 100644 --- a/interactions.c +++ b/interactions.c @@ -284,7 +284,22 @@ void open_with(){ TODO; } void rename_hovered(){ - TODO; + wclear(win_b); + file tmp; + tmp.file_name = malloc(INPUT_BUFFER_SIZE); + char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file); + mvwprintw(win_b, 0, 0, parsed_ui_text); + if (read_string(win_b, 0, strlen(parsed_ui_text)+1, tmp.file_name) == 0) { + char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file); + char *cmd1 = parse_cmd(cmd0, &tmp); + system(cmd1); + free(cmd0); + free(cmd1); + } + free(parsed_ui_text); + free(tmp.file_name); + status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY); + } void delete(){ TODO; @@ -293,9 +308,9 @@ void makedir(){ wclear(win_b); file tmp; tmp.file_name = malloc(INPUT_BUFFER_SIZE); - mvwprintw(win_b, 0, 0, ui_mkdir_text); - if (read_string(win_b, 0, strlen(ui_mkdir_text)+1, tmp.file_name) == 0) { - char *cmd = parse_cmd("mkdir ", &tmp); + mvwprintw(win_b, 0, 0, ui_makedir_text); + if (read_string(win_b, 0, strlen(ui_makedir_text)+1, tmp.file_name) == 0) { + char *cmd = parse_cmd(makedir_cmd, &tmp); system(cmd); free(cmd); } @@ -306,9 +321,9 @@ void makefile(){ wclear(win_b); file tmp; tmp.file_name = malloc(INPUT_BUFFER_SIZE); - mvwprintw(win_b, 0, 0, ui_touch_text); - if (read_string(win_b, 0, strlen(ui_touch_text)+1, tmp.file_name) == 0) { - char *cmd = parse_cmd("touch ", &tmp); + mvwprintw(win_b, 0, 0, ui_makefile_text); + if (read_string(win_b, 0, strlen(ui_makefile_text)+1, tmp.file_name) == 0) { + char *cmd = parse_cmd(makefile_cmd, &tmp); system(cmd); free(cmd); }