From 3881a748f13fe98ecf47df19ca6de4d25b985364 Mon Sep 17 00:00:00 2001 From: Andreas Stallinger Date: Wed, 22 Jul 2020 17:54:30 +0200 Subject: [PATCH] set a command for set options command for background could be removed --- doc/imv.1.txt | 4 ++++ src/imv.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/doc/imv.1.txt b/doc/imv.1.txt index 1eda54f..384abee 100644 --- a/doc/imv.1.txt +++ b/doc/imv.1.txt @@ -154,6 +154,10 @@ Commands can be entered by pressing *:*. imv supports the following commands: Set the background color. 'checks' for a chequerboard pattern, or specify a 6-digit hexadecimal color code. Aliased to 'bg'. +*set* :: + Set an option to a specific. See **OPTIONS** in **imv**(5) for the right option_name and + option_values. + *bind* :: Binds an action to a set of key inputs. Uses the same syntax as the config file, but without an equals sign between the keys and the commands. For diff --git a/src/imv.c b/src/imv.c index 17b82b9..ae56cb3 100644 --- a/src/imv.c +++ b/src/imv.c @@ -194,6 +194,7 @@ static void command_set_scaling_mode(struct list *args, const char *argstr, void static void command_set_upscaling_method(struct list *args, const char *argstr, void *data); static void command_set_slideshow_duration(struct list *args, const char *argstr, void *data); static void command_set_background(struct list *args, const char *argstr, void *data); +static void command_set_option(struct list *args, const char *argstr, void *data); static void command_bind(struct list *args, const char *argstr, void *data); static bool setup_window(struct imv *imv); @@ -305,6 +306,7 @@ static bool add_bind(struct imv *imv, const char *keys, const char *commands) break; } commands = next_command; + } list_deep_free(list); @@ -495,6 +497,7 @@ struct imv *imv_create(void) imv_command_register(imv->commands, "quit", &command_quit); imv_command_register(imv->commands, "pan", &command_pan); + imv_command_register(imv->commands, "set", &command_set_option); imv_command_register(imv->commands, "next", &command_next); imv_command_register(imv->commands, "prev", &command_prev); imv_command_register(imv->commands, "goto", &command_goto); @@ -1447,6 +1450,18 @@ static void command_pan(struct list *args, const char *argstr, void *data) imv_viewport_move(imv->view, x, y, imv->current_image); } +static void command_set_option(struct list *args, const char *argstr, void *data) +{ + (void)argstr; + struct imv *imv = data; + if (args->len != 3 ) { + imv_log(IMV_ERROR, "set command needs 2 arguments"); + } + + handle_ini_value(imv, "options", args->items[1], args->items[2]); + imv->need_redraw = true; +} + static void command_next(struct list *args, const char *argstr, void *data) { (void)argstr;