fe

terminal file explorer and picker

git clone https://9o.is/git/fe.git

commit 326424f91c594e3dc3db420161f324aa40637fd6
parent fe5d65495e34b3260b21dd2e73dbed2f24a6bf30
Author: Jul <jul@9o.is>
Date:   Sun, 18 Jan 2026 10:47:55 -0500

set const for argv keybinding actions

Diffstat:
Mtty_interface.c | 36++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/tty_interface.c b/tty_interface.c @@ -76,12 +76,12 @@ static void draw(tty_interface_t *state) { tty_flush(tty); } -static void action_ignore(tty_interface_t *state, char *argv) { +static void action_ignore(tty_interface_t *state, const char *argv) { (void)state; (void)argv; } -static void action_select(tty_interface_t *state, char *argv) { +static void action_select(tty_interface_t *state, const char *argv) { (void)argv; int done = entries_select(state->entries); @@ -106,25 +106,25 @@ static void action_select(tty_interface_t *state, char *argv) { } } -static void action_parent(tty_interface_t *state, char *argv) { +static void action_parent(tty_interface_t *state, const char *argv) { (void)argv; entries_parent(state->entries); draw(state); } -static void action_prev(tty_interface_t *state, char *argv) { +static void action_prev(tty_interface_t *state, const char *argv) { (void)argv; entries_prev(state->entries); draw(state); } -static void action_next(tty_interface_t *state, char *argv) { +static void action_next(tty_interface_t *state, const char *argv) { (void)argv; entries_next(state->entries); draw(state); } -static void action_halfpageup(tty_interface_t *state, char *argv) { +static void action_halfpageup(tty_interface_t *state, const char *argv) { (void)argv; for (size_t i = 0; i < (state->options->num_files / 2) && state->entries->selection > 0; i++) entries_prev(state->entries); @@ -132,7 +132,7 @@ static void action_halfpageup(tty_interface_t *state, char *argv) { draw(state); } -static void action_halfpagedown(tty_interface_t *state, char *argv) { +static void action_halfpagedown(tty_interface_t *state, const char *argv) { (void)argv; for (size_t i = 0; i < (state->options->num_files / 2) && state->entries->selection < state->entries->size - 1; i++) entries_next(state->entries); @@ -140,7 +140,7 @@ static void action_halfpagedown(tty_interface_t *state, char *argv) { draw(state); } -static void action_pageup(tty_interface_t *state, char *argv) { +static void action_pageup(tty_interface_t *state, const char *argv) { (void)argv; for (size_t i = 0; i < state->options->num_files && state->entries->selection > 0; i++) entries_prev(state->entries); @@ -148,7 +148,7 @@ static void action_pageup(tty_interface_t *state, char *argv) { draw(state); } -static void action_pagedown(tty_interface_t *state, char *argv) { +static void action_pagedown(tty_interface_t *state, const char *argv) { (void)argv; for (size_t i = 0; i < state->options->num_files && state->entries->selection < state->entries->size - 1; i++) entries_next(state->entries); @@ -156,31 +156,31 @@ static void action_pagedown(tty_interface_t *state, char *argv) { draw(state); } -static void action_first(tty_interface_t *state, char *argv) { +static void action_first(tty_interface_t *state, const char *argv) { (void)argv; entries_position(state->entries, 0); draw(state); } -static void action_last(tty_interface_t *state, char *argv) { +static void action_last(tty_interface_t *state, const char *argv) { (void)argv; entries_position(state->entries, state->entries->size - 1); draw(state); } -static void action_home(tty_interface_t *state, char *argv) { +static void action_home(tty_interface_t *state, const char *argv) { (void)argv; entries_setpath(state->entries, getenv("HOME")); draw(state); } -static void action_togglehidden(tty_interface_t *state, char *argv) { +static void action_togglehidden(tty_interface_t *state, const char *argv) { (void)argv; entries_togglehidden(); draw(state); } -static void action_run(tty_interface_t *state, char *argv) { +static void action_run(tty_interface_t *state, const char *argv) { (void)argv; const struct entry *entry = entries_item(state->entries, state->entries->selection); @@ -204,7 +204,7 @@ static void action_run(tty_interface_t *state, char *argv) { draw(state); } -static void action_setpath(tty_interface_t *state, char *argv) { +static void action_setpath(tty_interface_t *state, const char *argv) { size_t input_len = strlen(argv) + PATH_MAX; char *input = malloc(input_len); @@ -226,7 +226,7 @@ static void action_setpath(tty_interface_t *state, char *argv) { draw(state); } -static void action_exit(tty_interface_t *state, char *argv) { +static void action_exit(tty_interface_t *state, const char *argv) { (void)argv; clear(state); tty_close(state->tty); @@ -251,8 +251,8 @@ void tty_interface_init(tty_interface_t *state, tty_t *tty, entries_t *entries, typedef struct { const char *key; - void (*action)(tty_interface_t *, char *); - char *argv; + void (*action)(tty_interface_t *, const char *); + const char *argv; } keybinding_t; #define KEY(key) ((const char[]){key, '\0'})