Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

set a command for set options #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/imv.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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* <option_name> <option_value>::
Set an option to a specific. See **OPTIONS** in **imv**(5) for the right option_name and
option_values.

*bind* <keys> <commands>::
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
Expand Down
15 changes: 15 additions & 0 deletions src/imv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down