fe

terminal file explorer and picker

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

commit bf204e6751b7ab7abafe7383f0a28c94ac8d4aee
parent 479ba5841cc02cab5f945c605aabe6552b085327
Author: Jul <jul@9o.is>
Date:   Sun, 18 Jan 2026 10:30:28 -0500

set const where appropriate

Diffstat:
Mentries.c | 6+++---
Mentries.h | 2+-
Mtty.c | 4++--
Mtty.h | 4++--
Mtty_interface.c | 10+++++-----
5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/entries.c b/entries.c @@ -147,7 +147,7 @@ int dentfill(char *path, struct entry **dents) { return n; } -int dentfind(struct entry *dents, int n, char *cwd, char *path) { +int dentfind(struct entry *dents, int n, char *cwd, const char *path) { char tmp[PATH_MAX]; int i; @@ -211,14 +211,14 @@ void set_path(entries_t *entries, char *path) { } } -void truncate_at_newline(char *buffer) { +void truncate_at_newline(const char *buffer) { char *newline_pos = strchr(buffer, '\n'); if (newline_pos != NULL) { *newline_pos = '\0'; } } -void entries_init(entries_t *entries, options_t *options) { +void entries_init(entries_t *entries, const options_t *options) { strcpy(entries->path, ""); entries->dents = NULL; entries->size = 0; diff --git a/entries.h b/entries.h @@ -21,7 +21,7 @@ typedef struct { size_t selection; } entries_t; -void entries_init(entries_t *entries, options_t *options); +void entries_init(entries_t *entries, const options_t *options); void entries_init_path(entries_t *entries, const char *path); void entries_init_stdinpath(entries_t *entries); void entries_destroy(entries_t *entries); diff --git a/tty.c b/tty.c @@ -192,11 +192,11 @@ void tty_flush(tty_t *tty) { fflush(tty->fout); } -size_t tty_getwidth(tty_t *tty) { +size_t tty_getwidth(const tty_t *tty) { return tty->maxwidth; } -size_t tty_getheight(tty_t *tty) { +size_t tty_getheight(const tty_t *tty) { return tty->maxheight; } diff --git a/tty.h b/tty.h @@ -57,8 +57,8 @@ void tty_printf(tty_t *tty, const char *fmt, ...); void tty_putc(tty_t *tty, char c); void tty_flush(tty_t *tty); -size_t tty_getwidth(tty_t *tty); -size_t tty_getheight(tty_t *tty); +size_t tty_getwidth(const tty_t *tty); +size_t tty_getheight(const tty_t *tty); void tty_hide_cursor(tty_t *tty); void tty_unhide_cursor(tty_t *tty); diff --git a/tty_interface.c b/tty_interface.c @@ -27,7 +27,7 @@ static void clear(tty_interface_t *state) { static void draw(tty_interface_t *state) { tty_t *tty = state->tty; entries_t *entries = state->entries; - options_t *options = state->options; + const options_t *options = state->options; unsigned int num_header = 1; unsigned int num_footer = 1; @@ -90,7 +90,7 @@ static void action_select(tty_interface_t *state, char *argv) { } else { clear(state); tty_close(state->tty); - struct entry *selection = entries_selected(state->entries); + const struct entry *selection = entries_selected(state->entries); if (state->options->run == NULL) { printf("%s/%s\n", state->entries->path, selection->name); @@ -183,7 +183,7 @@ static void action_togglehidden(tty_interface_t *state, char *argv) { static void action_run(tty_interface_t *state, char *argv) { (void)argv; - struct entry *entry = entries_item(state->entries, state->entries->selection); + const struct entry *entry = entries_item(state->entries, state->entries->selection); if (!entry) return; size_t input_len = strlen(argv) + PATH_MAX; @@ -330,7 +330,7 @@ int tty_interface_run(tty_interface_t *state) { draw(state); } - char s[2] = {tty_getchar(state->tty), '\0'}; + const char s[2] = {tty_getchar(state->tty), '\0'}; handle_input(state, s, 0); if (state->ambiguous_key_pending == 1) @@ -342,7 +342,7 @@ int tty_interface_run(tty_interface_t *state) { } while (tty_input_ready(state->tty, state->ambiguous_key_pending ? KEYTIMEOUT : 0, 0)); if (state->ambiguous_key_pending) { - char s[1] = ""; + const char s[1] = ""; handle_input(state, s, 1); if (state->exit >= 0)