rename_hovered, adjustments to makefile & makedir and its associated config

This commit is contained in:
nova
2026-06-01 23:46:38 +02:00
parent 20fee198ae
commit 87bfdd1b86
2 changed files with 33 additions and 12 deletions

View File

@@ -15,6 +15,9 @@
/* }}} */ /* }}} */
static const char clipboard_cmd[] = "echo ^ | xsel -ib --trim"; /*used in yank_text*/ 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[] = { static const mimetype mimetype_default_cmd[] = {
/* mimetype shell command /* 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_btm_current_dir_size[] = "sum of dir,";
static const char ui_open_with_text[] = "open "SETTINGS_COMMAND_REPLACE_STR" with:"; 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_rename_text[] = "rename "SETTINGS_COMMAND_REPLACE_STR" to:";
static const char ui_mkdir_text[] = "mkdir:"; static const char ui_makefile_text[] = "makedir:";
static const char ui_touch_text[] = "touch:"; static const char ui_makedir_text[] = "makefile:";
static const char ui_delete_text[] = "delete: "SETTINGS_COMMAND_REPLACE_STR; static const char ui_delete_text[] = "delete:";
/* {{{ */ /* {{{ */
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding); 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; static const char size_unit_count = (sizeof(size_unit) / sizeof(size_unit[0])) - 1;
#else #else
static const char clipboard_cmd[]; 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 mimetype mimetype_default_cmd[];
static const extension file_extension_default_cmd[]; static const extension file_extension_default_cmd[];
static const binding key_binding[]; 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[];
static const char size_unit_count; static const char size_unit_count;
static const char ui_open_with_text[]; 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_rename_text[];
static const char ui_mkdir_text[];
static const char ui_touch_text[];
static const char ui_delete_text[]; static const char ui_delete_text[];
#endif #endif
/* }}} */ /* }}} */

View File

@@ -284,7 +284,22 @@ void open_with(){
TODO; TODO;
} }
void rename_hovered(){ 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(){ void delete(){
TODO; TODO;
@@ -293,9 +308,9 @@ void makedir(){
wclear(win_b); wclear(win_b);
file tmp; file tmp;
tmp.file_name = malloc(INPUT_BUFFER_SIZE); tmp.file_name = malloc(INPUT_BUFFER_SIZE);
mvwprintw(win_b, 0, 0, ui_mkdir_text); mvwprintw(win_b, 0, 0, ui_makedir_text);
if (read_string(win_b, 0, strlen(ui_mkdir_text)+1, tmp.file_name) == 0) { if (read_string(win_b, 0, strlen(ui_makedir_text)+1, tmp.file_name) == 0) {
char *cmd = parse_cmd("mkdir ", &tmp); char *cmd = parse_cmd(makedir_cmd, &tmp);
system(cmd); system(cmd);
free(cmd); free(cmd);
} }
@@ -306,9 +321,9 @@ void makefile(){
wclear(win_b); wclear(win_b);
file tmp; file tmp;
tmp.file_name = malloc(INPUT_BUFFER_SIZE); tmp.file_name = malloc(INPUT_BUFFER_SIZE);
mvwprintw(win_b, 0, 0, ui_touch_text); mvwprintw(win_b, 0, 0, ui_makefile_text);
if (read_string(win_b, 0, strlen(ui_touch_text)+1, tmp.file_name) == 0) { if (read_string(win_b, 0, strlen(ui_makefile_text)+1, tmp.file_name) == 0) {
char *cmd = parse_cmd("touch ", &tmp); char *cmd = parse_cmd(makefile_cmd, &tmp);
system(cmd); system(cmd);
free(cmd); free(cmd);
} }