summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-13 21:36:00 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-13 21:47:56 -0700
commit1446525ac78b25932db12e4e690184b137fc6aa8 (patch)
tree46434c9363d4acf7610abaa7f863f660ecaa35b4 /src/main.c
parent2f4011b4c5ec416d78d6da304315708a42e39798 (diff)
til_args,*_fb: introduce --title= and wire up to til_fb_t
For meta-demo use cases like alphazed is experimenting with, it's desirable to change the window title from "rototiller" to "alphazed" or whatever if in windowed mode. This adds a way to do that in the obvious fashion... --title="alphazed" etc.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 44bb735..eda0b4e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -70,6 +70,7 @@ typedef struct setup_t {
til_settings_t *video_settings;
til_setup_t *video_setup;
unsigned seed;
+ const char *title;
} setup_t;
/* FIXME: this is unnecessarily copy-pasta, i think modules should just be made
@@ -207,6 +208,10 @@ static int setup_from_args(til_args_t *args, setup_t *res_setup, const char **re
assert(args);
assert(res_setup);
+ setup.title = strdup(args->title ? : "rototiller");
+ if (!setup.title)
+ goto _err;
+
if (args->seed) {
r = parse_seed(args->seed, &setup.seed);
if (r < 0)
@@ -245,6 +250,7 @@ static int setup_from_args(til_args_t *args, setup_t *res_setup, const char **re
return changes;
_err:
+ free((void *)setup.title);
til_settings_free(setup.module_settings);
til_settings_free(setup.video_settings);
@@ -308,7 +314,7 @@ _out:
static int print_help(void)
{
- printf("Run without any flags or partial settings for interactive mode.\n"
+ printf("\nRun without any flags or partial settings for interactive mode.\n"
"\n"
"Supported flags:\n");
@@ -387,7 +393,7 @@ int main(int argc, const char *argv[])
exit_if(!(rototiller.module = til_lookup_module(til_settings_get_value_by_idx(setup.module_settings, 0, NULL))),
"unable to lookup module from settings \"%s\"", til_settings_get_value_by_idx(setup.module_settings, 0, NULL));
- exit_if((r = til_fb_new(fb_ops, setup.video_setup, NUM_FB_PAGES, &rototiller.fb)) < 0,
+ exit_if((r = til_fb_new(fb_ops, setup.title, setup.video_setup, NUM_FB_PAGES, &rototiller.fb)) < 0,
"unable to create fb: %s", strerror(-r));
exit_if(!(rototiller.stream = til_stream_new()),
© All Rights Reserved