diff --git a/config.h b/config.h index da24941..9bcc4bc 100644 --- a/config.h +++ b/config.h @@ -18,8 +18,14 @@ static mimetype mimetype_default_cmd[] = { static binding key_binding[] = { /*key action */ + /*you cannot add bindings that include other bindings in its entirety + * possible: mk, mf + * not possible: gg, ggg + * trying to use ggg will always fail as it will execute gg first instead, resetting the input buffer, thus never + * reaching ggg */ { "q", quit_program }, { " ", toggle_selection }, /* on hovered file/directory */ + { "u", update }, /* executes the entire backend and redrawing of the screen */ { "h", move_right }, /* moves one dir up */ { "t", move_down }, @@ -34,6 +40,9 @@ static binding key_binding[] = { { "gg", jump_top }, { "G", jump_bottom }, + { "mk", makedir }, + { "mf", makefile }, + { "a", toggle_hidden_files }, }; static unsigned long binding_count = sizeof(key_binding) / sizeof(binding); diff --git a/interactions.c b/interactions.c index fcbf583..db5da34 100644 --- a/interactions.c +++ b/interactions.c @@ -355,7 +355,54 @@ void delete(){ } void makedir(){ - mkdir("mk", 755); /*magic number from default permissions as created by mkdir*/ + btm_buffer = "create dir: "; + status = STATUS_UPDATE_SCREEN_0; + werase(win_b); + mvwin(win_b, terminal_height-6, 0); + wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/ + render_pass(); + + unsigned long local_width; + unsigned long local_height; + getmaxyx(win_b, local_height, local_width); + + /* TODO(2025-07-03T01:19:55) fix fixed buffer size */ + char *str = malloc(255); + memset(str, ' ', 255); + int err = read_string(win_b, local_height - 1, 0, str); + if (!err) { + btm_buffer = concat(btm_buffer, str); + mkdir(str, 755); /*magic number from default permissions as created by mkdir*/ + } + free(str); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); +} +void makefile(){ + btm_buffer = "create file: "; + status = STATUS_UPDATE_SCREEN_0; + werase(win_b); + mvwin(win_b, terminal_height-6, 0); + wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/ + render_pass(); + + unsigned long local_width; + unsigned long local_height; + getmaxyx(win_b, local_height, local_width); + + /* TODO(2025-07-03T01:19:49) fix fixed buffer size */ + char *str = malloc(255); + memset(str, ' ', 255); + int err = read_string(win_b, local_height - 1, 0, str); + if (!err) { + btm_buffer = concat(btm_buffer, str); + FILE *fp; + fp = fopen(str, "w"); + fclose(fp); + } + free(str); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); } +void update() { + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); +} diff --git a/interactions.h b/interactions.h index 2eee957..eb93591 100644 --- a/interactions.h +++ b/interactions.h @@ -20,3 +20,5 @@ void open_with(); void rename_hovered(); void delete(); void makedir(); +void makefile(); +void update();