diff options
author | Bert Münnich <be.muennich@gmail.com> | 2014-01-31 13:21:23 +0100 |
---|---|---|
committer | Bert Münnich <be.muennich@gmail.com> | 2014-01-31 13:21:23 +0100 |
commit | f6510b0a04e9351f0cea740d2237ebe293125f4c (patch) | |
tree | 3fc2429d9e2c7bd2f0bd96ff7d682fac7ca58068 | |
parent | d5b2d377a44db7408c90e5e15e35458bcc0f340c (diff) | |
parent | 2d703c30a2372c6b9955f5c08fb6b727cbd3cee0 (diff) |
Merged pull request #129
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | commands.c | 7 | ||||
-rw-r--r-- | commands.h | 1 | ||||
-rw-r--r-- | config.def.h | 4 | ||||
-rw-r--r-- | exec/key-handler | 6 | ||||
-rw-r--r-- | main.c | 19 | ||||
-rw-r--r-- | sxiv.1 | 5 |
8 files changed, 33 insertions, 16 deletions
@@ -1,4 +1,4 @@ -VERSION = git-20140115 +VERSION = git-20140131 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man @@ -96,6 +96,8 @@ of small previews is displayed, making it easy to choose an image to open. 0-9 Prefix the next command with a number (denoted via [count]) + Ctrl-x Send the next key to the external key-handler + g Go to first image G Go to the last image, or image number [count] @@ -144,6 +146,9 @@ of small previews is displayed, making it easy to choose an image to open. ? Rotate image by 180 degrees |,_ Flip image horizontally/vertically + {,} Decrease/increase gamma + Ctrl-g Reset gamma + s Toggle slideshow or set delay to [count] seconds a Toggle anti-aliasing @@ -52,6 +52,7 @@ extern int filecnt, fileidx; extern int alternate; extern int prefix; +extern bool extprefix; const int ss_delays[] = { 1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600 @@ -119,6 +120,12 @@ cmdreturn_t it_toggle_bar(arg_t a) return CMD_DIRTY; } +cmdreturn_t it_prefix_external(arg_t a) +{ + extprefix = true; + return CMD_OK; +} + cmdreturn_t t_reload_all(arg_t a) { if (mode == MODE_THUMB) { @@ -50,6 +50,7 @@ cmdreturn_t it_quit(arg_t); cmdreturn_t it_switch_mode(arg_t); cmdreturn_t it_toggle_fullscreen(arg_t); cmdreturn_t it_toggle_bar(arg_t); +cmdreturn_t it_prefix_external(arg_t); cmdreturn_t t_reload_all(arg_t); cmdreturn_t it_reload_image(arg_t); cmdreturn_t it_remove_image(arg_t); diff --git a/config.def.h b/config.def.h index 6c03bc1..8c2c7ed 100644 --- a/config.def.h +++ b/config.def.h @@ -85,6 +85,8 @@ static const keymap_t keys[] = { { 0, XK_f, it_toggle_fullscreen, (arg_t) None }, { 0, XK_b, it_toggle_bar, (arg_t) None }, + { ControlMask, XK_x, it_prefix_external, (arg_t) None }, + { 0, XK_r, it_reload_image, (arg_t) None }, { 0, XK_R, t_reload_all, (arg_t) None }, { 0, XK_D, it_remove_image, (arg_t) None }, @@ -155,7 +157,7 @@ static const keymap_t keys[] = { { 0, XK_braceleft, i_change_gamma, (arg_t) -1 }, { 0, XK_braceright, i_change_gamma, (arg_t) +1 }, - { ControlMask, XK_G, i_change_gamma, (arg_t) 0 }, + { ControlMask, XK_g, i_change_gamma, (arg_t) 0 }, }; /* mouse button mappings for image mode: */ diff --git a/exec/key-handler b/exec/key-handler index f4de310..184f373 100644 --- a/exec/key-handler +++ b/exec/key-handler @@ -1,9 +1,9 @@ #!/bin/sh # Example for $XDG_CONFIG_HOME/sxiv/exec/key-handler -# Called by sxiv(1) whenever an unbound key combo is used, -# with the key combo as its first argument and the path of the current image -# as its second argument. +# Called by sxiv(1) after the external prefix key (C-x by default) is pressed. +# The next key combo is passed as its first argument and the path of the +# current image as its second argument. # sxiv(1) blocks until this script terminates. It then checks if the image # has been modified and reloads it. @@ -75,6 +75,7 @@ int filecnt, fileidx; int alternate; int prefix; +bool extprefix; bool resized = false; @@ -522,16 +523,16 @@ void on_keypress(XKeyEvent *kev) if (IsModifierKey(ksym)) return; - - if ((ksym == XK_Escape && MODMASK(kev->state) == 0) || - (key >= '0' && key <= '9')) - { + if (ksym == XK_Escape && MODMASK(kev->state) == 0) { + extprefix = False; + } else if (extprefix) { + run_key_handler(XKeysymToString(ksym), kev->state & ~sh); + extprefix = False; + } else if (key >= '0' && key <= '9') { /* number prefix for commands */ - prefix = ksym == XK_Escape ? 0 : prefix * 10 + (int) (key - '0'); + prefix = prefix * 10 + (int) (key - '0'); return; - } - - for (i = 0; i < ARRLEN(keys); i++) { + } else for (i = 0; i < ARRLEN(keys); i++) { if (keys[i].ksym == ksym && MODMASK(keys[i].mask | sh) == MODMASK(kev->state) && keys[i].cmd != NULL) @@ -545,8 +546,6 @@ void on_keypress(XKeyEvent *kev) break; } } - if (i == ARRLEN(keys)) - run_key_handler(XKeysymToString(ksym), kev->state & ~sh); prefix = 0; } @@ -125,6 +125,9 @@ Toggle fullscreen mode. .B b Toggle visibility of info bar on bottom of window. .TP +.B Ctrl-x +Send the next key to the external key-handler. +.TP .B A Toggle visibility of alpha-channel, i.e. image transparency. .TP @@ -303,7 +306,7 @@ Decrease gamma. .B } Increase gamma. .TP -.B Ctrl-G +.B Ctrl-g Reset gamma. .SS Miscellaneous .TP |