fe

terminal file explorer and picker

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

commit b0cea28277733ea9961cb79bf12ed834409f3105
parent 81fb92d0c864b29bc5f67ab3fa8324e6bc53a598
Author: Jul <jul@9o.is>
Date:   Tue, 20 Jan 2026 04:35:53 -0500

initialize options_t from config.h

Diffstat:
Mconfig.def.h | 15+++++++++------
Mfe.c | 4++--
Moptions.c | 11-----------
Moptions.h | 1-
4 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,6 +1,7 @@ #include "tty.h" #include "tty_interface.h" #include "actions.h" +#include "options.h" #define TTY_COLOR_BLACK 0 #define TTY_COLOR_RED 1 @@ -19,14 +20,16 @@ #define COLOR_EXEC TTY_COLOR_GREEN #define COLOR_REGULAR TTY_COLOR_NORMAL -#define DEFAULT_TTY "/dev/tty" -#define DEFAULT_NUM_FILES 25 #define KEYTIMEOUT 25 -#define SORT_DIR 0; -#define SORT_ICASE 0; -#define SORT_MTIME 0; -#define SHOW_HIDDEN 0; +static const options_t default_options = { + .num_files = 25, + .tty_filename = "/dev/tty", + .sort_dir = 0, + .sort_icase = 0, + .sort_mtime = 0, + .show_hidden = 0, +}; typedef struct { const char *key; diff --git a/fe.c b/fe.c @@ -8,9 +8,10 @@ #include "entries.h" #include "options.h" #include "tty_interface.h" +#include "config.h" int main(int argc, char *argv[]) { - options_t options; + options_t options = default_options; options_parse(&options, argc, argv); entries_t entries; @@ -31,4 +32,3 @@ int main(int argc, char *argv[]) { entries_destroy(&entries); return ret; } - diff --git a/options.c b/options.c @@ -4,7 +4,6 @@ #include <string.h> #include <limits.h> #include "options.h" -#include "config.h" static const char *usage_str = "" @@ -37,15 +36,6 @@ static struct option longopts[] = { }; void options_parse(options_t *options, int argc, char *argv[]) { - options->tty_filename = DEFAULT_TTY; - options->num_files = DEFAULT_NUM_FILES; - options->sort_dir = SORT_DIR; - options->sort_mtime = SORT_MTIME; - options->sort_icase = SORT_ICASE; - options->show_hidden = SHOW_HIDDEN; - options->run = NULL; - options->path = NULL; - int c; while ((c = getopt_long(argc, argv, "vhadmr:i:n:t:", longopts, NULL)) != -1) { switch (c) { @@ -98,4 +88,3 @@ void options_parse(options_t *options, int argc, char *argv[]) { options->path = argv[optind]; } } - diff --git a/options.h b/options.h @@ -12,7 +12,6 @@ typedef struct { int show_hidden; } options_t; -void options_init(options_t *options); void options_parse(options_t *options, int argc, char *argv[]); #endif