From 11e52cb5d877520de730f56d9725c93fcc7bf3c5 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Tue, 28 Nov 2017 21:56:34 +0000 Subject: Tweak config option names & capitalisation --- files/imv_config | 63 +++++++++++++++++++++++++++++++++++--------------------- src/binds.c | 4 ++++ src/imv.c | 56 ++++++++++++++++++++++++------------------------- 3 files changed, 71 insertions(+), 52 deletions(-) diff --git a/files/imv_config b/files/imv_config index 75d84d2..49fffdf 100644 --- a/files/imv_config +++ b/files/imv_config @@ -8,8 +8,8 @@ # Start with overlay visible # overlay = true -# Use nearest_neighbour interpolation for pixel art -# sampling = nearest_neighbour +# Method used for upscaling images. Can be 'linear' or 'nearest_neighbour' +# upscaling_method = linear # Recurse into subdirectories when opening a path # recursive = true @@ -21,58 +21,73 @@ # list_at_exit = true # Scaling mode, one of: none, shrink, and full -# scaling = none +# scaling_mode = none # Background, either a hex colour code or 'checks' # background = 000000 # Change to the next image automatically after 3 seconds -# slideshow = 3 +# slideshow_duration = 3 # Font to use for the overlay # overlay_font = Monospace:24 # Disable imv's builtin binds so they don't conflict with the ones in this config -default_binds = false +suppress_default_binds = true [binds] -Q = quit +# Some keys have special names: +# < -> Less +# > -> Greater +# [ -> LeftSquareBracket +# ] -> RightSquareBracket +# = -> Equals +# Left arrow key -> Left +# Up arrow key -> Up +# Right arrow key -> Right +# Down arrow key -> Down + +# Keys can have the modifiers 'Ctrl+' 'Meta+' and 'Shift+' in front of them, +# in that order. Keys with special names, or with a modifier are enclosed in +# '<' and '>'. + +q = quit # Image navigation = select_rel -1 = select_rel -1 = select_rel 1 = select_rel 1 -GG = select_abs 0 - = select_abs -1 +gg = select_abs 0 + = select_abs -1 # Panning -J = pan 0 -50 -K = pan 0 50 -H = pan 50 0 -L = pan -50 0 +j = pan 0 -50 +k = pan 0 50 +h = pan 50 0 +l = pan -50 0 # Zooming = zoom 1 -I = zoom 1 +i = zoom 1 = zoom -1 -O = zoom -1 +o = zoom -1 # Other commands -X = remove -F = fullscreen -D = overlay -P = exec echo $imv_path -C = center -S = scaling_mode next -A = zoom actual -R = reset +x = remove +f = fullscreen +d = overlay +p = exec echo $imv_path +c = center +s = scaling_mode next +a = zoom actual +r = reset # Gif playback . = next_frame = toggle_playing # Slideshow control -T = slideshow_duration +1 - = slideshow_duration -1 +t = slideshow_duration +1 + = slideshow_duration -1 diff --git a/src/binds.c b/src/binds.c index e0426e6..384d6ee 100644 --- a/src/binds.c +++ b/src/binds.c @@ -188,6 +188,7 @@ static int print_event(char *buf, size_t len, const SDL_Event *event) /* Try plain old character input */ const char *keyname = SDL_GetKeyName(kevent->keysym.sym); + char singlekey[2] = {0}; /* Because '<' and '>' have special meaning in our syntax, and '=', '[', and * ']' are restricted within ini files, we rename these. */ @@ -201,6 +202,9 @@ static int print_event(char *buf, size_t len, const SDL_Event *event) keyname = "LeftSquareBracket"; } else if(!strcmp(keyname, "]")) { keyname = "RightSquareBracket"; + } else if(isalpha(*keyname)) { + singlekey[0] = tolower(*keyname); + keyname = &singlekey[0]; } return snprintf(buf, len, "%s%s", prefix, keyname); diff --git a/src/imv.c b/src/imv.c index efad1f7..2e1119d 100644 --- a/src/imv.c +++ b/src/imv.c @@ -183,36 +183,36 @@ struct imv *imv_create(void) imv_command_alias(imv->commands, "n", "select_rel 1"); imv_command_alias(imv->commands, "p", "select_rel -1"); - add_bind(imv, "", "quit"); + add_bind(imv, "", "quit"); add_bind(imv, "", "select_rel -1"); - add_bind(imv, "<[>", "select_rel -1"); + add_bind(imv, "", "select_rel -1"); add_bind(imv, "", "select_rel 1"); - add_bind(imv, "<]>", "select_rel 1"); - add_bind(imv, "", "select_abs 0"); - add_bind(imv, "", "select_abs -1"); - add_bind(imv, "", "pan 0 -50"); - add_bind(imv, "", "pan 0 50"); - add_bind(imv, "", "pan 50 0"); - add_bind(imv, "", "pan -50 0"); - add_bind(imv, "", "remove"); - add_bind(imv, "", "fullscreen"); - add_bind(imv, "", "overlay"); - add_bind(imv, "

", "exec echo $imv_path"); + add_bind(imv, "", "select_rel 1"); + add_bind(imv, "", "select_abs 0"); + add_bind(imv, "", "select_abs -1"); + add_bind(imv, "", "pan 0 -50"); + add_bind(imv, "", "pan 0 50"); + add_bind(imv, "", "pan 50 0"); + add_bind(imv, "", "pan -50 0"); + add_bind(imv, "", "remove"); + add_bind(imv, "", "fullscreen"); + add_bind(imv, "", "overlay"); + add_bind(imv, "

", "exec echo $imv_path"); add_bind(imv, "", "zoom 1"); add_bind(imv, "", "zoom 1"); add_bind(imv, "<+>", "zoom 1"); - add_bind(imv, "", "zoom 1"); + add_bind(imv, "", "zoom 1"); add_bind(imv, "", "zoom -1"); add_bind(imv, "<->", "zoom -1"); - add_bind(imv, "", "zoom -1"); - add_bind(imv, "", "center"); - add_bind(imv, "", "scaling_mode next"); - add_bind(imv, "", "zoom actual"); - add_bind(imv, "", "reset"); + add_bind(imv, "", "zoom -1"); + add_bind(imv, "", "center"); + add_bind(imv, "", "scaling_mode next"); + add_bind(imv, "", "zoom actual"); + add_bind(imv, "", "reset"); add_bind(imv, "<.>", "next_frame"); add_bind(imv, "", "toggle_playing"); - add_bind(imv, "", "slideshow_duration +1"); - add_bind(imv, "", "slideshow_duration -1"); + add_bind(imv, "", "slideshow_duration +1"); + add_bind(imv, "", "slideshow_duration -1"); return imv; } @@ -290,7 +290,7 @@ static bool parse_slideshow_duration(struct imv *imv, const char *duration) } } if (imv->slideshow_image_duration == ULONG_MAX) { - fprintf(stderr, "Wrong slideshow delay '%s'. Aborting.\n", optarg); + fprintf(stderr, "Wrong slideshow duration '%s'. Aborting.\n", optarg); return false; } return true; @@ -893,7 +893,7 @@ static int handle_ini_value(void *user, const char *section, const char *name, return 1; } - if(!strcmp(name, "sampling")) { + if(!strcmp(name, "upscaling_method")) { imv->nearest_neighbour = !strcmp(value, "nearest_neighbour"); return 1; } @@ -913,7 +913,7 @@ static int handle_ini_value(void *user, const char *section, const char *name, return 1; } - if(!strcmp(name, "scaling")) { + if(!strcmp(name, "scaling_mode")) { if(!strcmp(value, "none")) { imv->scaling_mode = SCALING_NONE; } else if(!strcmp(value, "shrink")) { @@ -931,7 +931,7 @@ static int handle_ini_value(void *user, const char *section, const char *name, return 1; } - if(!strcmp(name, "slideshow")) { + if(!strcmp(name, "slideshow_duration")) { if(!parse_slideshow_duration(imv, value)) { return false; } @@ -944,9 +944,9 @@ static int handle_ini_value(void *user, const char *section, const char *name, return 1; } - if(!strcmp(name, "default_binds")) { - const bool default_binds = parse_bool(value); - if(!default_binds) { + if(!strcmp(name, "suppress_default_binds")) { + const bool suppress_default_binds = parse_bool(value); + if(suppress_default_binds) { /* clear out any default binds if requested */ imv_binds_clear(imv->binds); } -- cgit v1.2.3