nsxivf6510b0
Merged pull request #129
+33 −16
8 files changed
- M Makefile +1 −1
- M README.md +5 −0
- M commands.c +7 −0
- M commands.h +1 −0
- M config.def.h +3 −1
- M exec/key-handler +3 −3
- M main.c +9 −10
- M sxiv.1 +4 −1
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20140115 | |
| 1 | + | VERSION = git-20140131 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX = /usr/local | |
| 4 | 4 | MANPREFIX = $(PREFIX)/share/man | |
| @@ -96,6 +96,8 @@ of small previews is displayed, making it easy to choose an image to open. | |||
| 96 | 96 | ||
| 97 | 97 | 0-9 Prefix the next command with a number (denoted via [count]) | |
| 98 | 98 | ||
| 99 | + | Ctrl-x Send the next key to the external key-handler | |
| 100 | + | ||
| 99 | 101 | g Go to first image | |
| 100 | 102 | G Go to the last image, or image number [count] | |
| 101 | 103 | ||
| @@ -144,6 +146,9 @@ of small previews is displayed, making it easy to choose an image to open. | |||
| 144 | 146 | ? Rotate image by 180 degrees | |
| 145 | 147 | |,_ Flip image horizontally/vertically | |
| 146 | 148 | ||
| 149 | + | {,} Decrease/increase gamma | |
| 150 | + | Ctrl-g Reset gamma | |
| 151 | + | ||
| 147 | 152 | s Toggle slideshow or set delay to [count] seconds | |
| 148 | 153 | ||
| 149 | 154 | a Toggle anti-aliasing | |
| @@ -52,6 +52,7 @@ extern int filecnt, fileidx; | |||
| 52 | 52 | extern int alternate; | |
| 53 | 53 | ||
| 54 | 54 | extern int prefix; | |
| 55 | + | extern bool extprefix; | |
| 55 | 56 | ||
| 56 | 57 | const int ss_delays[] = { | |
| 57 | 58 | 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) | |||
| 119 | 120 | return CMD_DIRTY; | |
| 120 | 121 | } | |
| 121 | 122 | ||
| 123 | + | cmdreturn_t it_prefix_external(arg_t a) | |
| 124 | + | { | |
| 125 | + | extprefix = true; | |
| 126 | + | return CMD_OK; | |
| 127 | + | } | |
| 128 | + | ||
| 122 | 129 | cmdreturn_t t_reload_all(arg_t a) | |
| 123 | 130 | { | |
| 124 | 131 | if (mode == MODE_THUMB) { | |
| @@ -50,6 +50,7 @@ cmdreturn_t it_quit(arg_t); | |||
| 50 | 50 | cmdreturn_t it_switch_mode(arg_t); | |
| 51 | 51 | cmdreturn_t it_toggle_fullscreen(arg_t); | |
| 52 | 52 | cmdreturn_t it_toggle_bar(arg_t); | |
| 53 | + | cmdreturn_t it_prefix_external(arg_t); | |
| 53 | 54 | cmdreturn_t t_reload_all(arg_t); | |
| 54 | 55 | cmdreturn_t it_reload_image(arg_t); | |
| 55 | 56 | cmdreturn_t it_remove_image(arg_t); | |
| @@ -85,6 +85,8 @@ static const keymap_t keys[] = { | |||
| 85 | 85 | { 0, XK_f, it_toggle_fullscreen, (arg_t) None }, | |
| 86 | 86 | { 0, XK_b, it_toggle_bar, (arg_t) None }, | |
| 87 | 87 | ||
| 88 | + | { ControlMask, XK_x, it_prefix_external, (arg_t) None }, | |
| 89 | + | ||
| 88 | 90 | { 0, XK_r, it_reload_image, (arg_t) None }, | |
| 89 | 91 | { 0, XK_R, t_reload_all, (arg_t) None }, | |
| 90 | 92 | { 0, XK_D, it_remove_image, (arg_t) None }, | |
| @@ -155,7 +157,7 @@ static const keymap_t keys[] = { | |||
| 155 | 157 | ||
| 156 | 158 | { 0, XK_braceleft, i_change_gamma, (arg_t) -1 }, | |
| 157 | 159 | { 0, XK_braceright, i_change_gamma, (arg_t) +1 }, | |
| 158 | − | { ControlMask, XK_G, i_change_gamma, (arg_t) 0 }, | |
| 160 | + | { ControlMask, XK_g, i_change_gamma, (arg_t) 0 }, | |
| 159 | 161 | }; | |
| 160 | 162 | ||
| 161 | 163 | /* mouse button mappings for image mode: */ | |
| @@ -1,9 +1,9 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | 3 | # Example for $XDG_CONFIG_HOME/sxiv/exec/key-handler | |
| 4 | − | # Called by sxiv(1) whenever an unbound key combo is used, | |
| 5 | − | # with the key combo as its first argument and the path of the current image | |
| 6 | − | # as its second argument. | |
| 4 | + | # Called by sxiv(1) after the external prefix key (C-x by default) is pressed. | |
| 5 | + | # The next key combo is passed as its first argument and the path of the | |
| 6 | + | # current image as its second argument. | |
| 7 | 7 | # sxiv(1) blocks until this script terminates. It then checks if the image | |
| 8 | 8 | # has been modified and reloads it. | |
| 9 | 9 | ||
| @@ -75,6 +75,7 @@ int filecnt, fileidx; | |||
| 75 | 75 | int alternate; | |
| 76 | 76 | ||
| 77 | 77 | int prefix; | |
| 78 | + | bool extprefix; | |
| 78 | 79 | ||
| 79 | 80 | bool resized = false; | |
| 80 | 81 | ||
| @@ -522,16 +523,16 @@ void on_keypress(XKeyEvent *kev) | |||
| 522 | 523 | ||
| 523 | 524 | if (IsModifierKey(ksym)) | |
| 524 | 525 | return; | |
| 525 | − | ||
| 526 | − | if ((ksym == XK_Escape && MODMASK(kev->state) == 0) || | |
| 527 | − | (key >= '0' && key <= '9')) | |
| 528 | − | { | |
| 526 | + | if (ksym == XK_Escape && MODMASK(kev->state) == 0) { | |
| 527 | + | extprefix = False; | |
| 528 | + | } else if (extprefix) { | |
| 529 | + | run_key_handler(XKeysymToString(ksym), kev->state & ~sh); | |
| 530 | + | extprefix = False; | |
| 531 | + | } else if (key >= '0' && key <= '9') { | |
| 529 | 532 | /* number prefix for commands */ | |
| 530 | − | prefix = ksym == XK_Escape ? 0 : prefix * 10 + (int) (key - '0'); | |
| 533 | + | prefix = prefix * 10 + (int) (key - '0'); | |
| 531 | 534 | return; | |
| 532 | − | } | |
| 533 | − | ||
| 534 | − | for (i = 0; i < ARRLEN(keys); i++) { | |
| 535 | + | } else for (i = 0; i < ARRLEN(keys); i++) { | |
| 535 | 536 | if (keys[i].ksym == ksym && | |
| 536 | 537 | MODMASK(keys[i].mask | sh) == MODMASK(kev->state) && | |
| 537 | 538 | keys[i].cmd != NULL) | |
| @@ -545,8 +546,6 @@ void on_keypress(XKeyEvent *kev) | |||
| 545 | 546 | break; | |
| 546 | 547 | } | |
| 547 | 548 | } | |
| 548 | − | if (i == ARRLEN(keys)) | |
| 549 | − | run_key_handler(XKeysymToString(ksym), kev->state & ~sh); | |
| 550 | 549 | prefix = 0; | |
| 551 | 550 | } | |
| 552 | 551 | ||
| @@ -125,6 +125,9 @@ Toggle fullscreen mode. | |||
| 125 | 125 | .B b | |
| 126 | 126 | Toggle visibility of info bar on bottom of window. | |
| 127 | 127 | .TP | |
| 128 | + | .B Ctrl-x | |
| 129 | + | Send the next key to the external key-handler. | |
| 130 | + | .TP | |
| 128 | 131 | .B A | |
| 129 | 132 | Toggle visibility of alpha-channel, i.e. image transparency. | |
| 130 | 133 | .TP | |
| @@ -303,7 +306,7 @@ Decrease gamma. | |||
| 303 | 306 | .B } | |
| 304 | 307 | Increase gamma. | |
| 305 | 308 | .TP | |
| 306 | − | .B Ctrl-G | |
| 309 | + | .B Ctrl-g | |
| 307 | 310 | Reset gamma. | |
| 308 | 311 | .SS Miscellaneous | |
| 309 | 312 | .TP | |