Krolyxon
Commit f6510b0

Branches

Refs →

nsxivf6510b0

Merged pull request #129

Author
Bert Münnich
Date
2014-01-31 13:21 +0100
Parents
d5b2d37 2d703c3
Commit
f6510b0a04e9351f0cea740d2237ebe293125f4c

+33 −16

8 files changed

  1. M Makefile +1 −1
  2. M README.md +5 −0
  3. M commands.c +7 −0
  4. M commands.h +1 −0
  5. M config.def.h +3 −1
  6. M exec/key-handler +3 −3
  7. M main.c +9 −10
  8. M sxiv.1 +4 −1
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20140115
1+VERSION = git-20140131
22
33 PREFIX = /usr/local
44 MANPREFIX = $(PREFIX)/share/man
M README.md View
@@ -96,6 +96,8 @@ of small previews is displayed, making it easy to choose an image to open.
9696
9797 0-9 Prefix the next command with a number (denoted via [count])
9898
99+ Ctrl-x Send the next key to the external key-handler
100+
99101 g Go to first image
100102 G Go to the last image, or image number [count]
101103
@@ -144,6 +146,9 @@ of small previews is displayed, making it easy to choose an image to open.
144146 ? Rotate image by 180 degrees
145147 |,_ Flip image horizontally/vertically
146148
149+ {,} Decrease/increase gamma
150+ Ctrl-g Reset gamma
151+
147152 s Toggle slideshow or set delay to [count] seconds
148153
149154 a Toggle anti-aliasing
M commands.c View
@@ -52,6 +52,7 @@ extern int filecnt, fileidx;
5252 extern int alternate;
5353
5454 extern int prefix;
55+extern bool extprefix;
5556
5657 const int ss_delays[] = {
5758 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)
119120 return CMD_DIRTY;
120121 }
121122
123+cmdreturn_t it_prefix_external(arg_t a)
124+{
125+ extprefix = true;
126+ return CMD_OK;
127+}
128+
122129 cmdreturn_t t_reload_all(arg_t a)
123130 {
124131 if (mode == MODE_THUMB) {
M commands.h View
@@ -50,6 +50,7 @@ cmdreturn_t it_quit(arg_t);
5050 cmdreturn_t it_switch_mode(arg_t);
5151 cmdreturn_t it_toggle_fullscreen(arg_t);
5252 cmdreturn_t it_toggle_bar(arg_t);
53+cmdreturn_t it_prefix_external(arg_t);
5354 cmdreturn_t t_reload_all(arg_t);
5455 cmdreturn_t it_reload_image(arg_t);
5556 cmdreturn_t it_remove_image(arg_t);
M config.def.h View
@@ -85,6 +85,8 @@ static const keymap_t keys[] = {
8585 { 0, XK_f, it_toggle_fullscreen, (arg_t) None },
8686 { 0, XK_b, it_toggle_bar, (arg_t) None },
8787
88+ { ControlMask, XK_x, it_prefix_external, (arg_t) None },
89+
8890 { 0, XK_r, it_reload_image, (arg_t) None },
8991 { 0, XK_R, t_reload_all, (arg_t) None },
9092 { 0, XK_D, it_remove_image, (arg_t) None },
@@ -155,7 +157,7 @@ static const keymap_t keys[] = {
155157
156158 { 0, XK_braceleft, i_change_gamma, (arg_t) -1 },
157159 { 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 },
159161 };
160162
161163 /* mouse button mappings for image mode: */
M exec/key-handler View
@@ -1,9 +1,9 @@
11 #!/bin/sh
22
33 # 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.
77 # sxiv(1) blocks until this script terminates. It then checks if the image
88 # has been modified and reloads it.
99
M main.c View
@@ -75,6 +75,7 @@ int filecnt, fileidx;
7575 int alternate;
7676
7777 int prefix;
78+bool extprefix;
7879
7980 bool resized = false;
8081
@@ -522,16 +523,16 @@ void on_keypress(XKeyEvent *kev)
522523
523524 if (IsModifierKey(ksym))
524525 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') {
529532 /* number prefix for commands */
530− prefix = ksym == XK_Escape ? 0 : prefix * 10 + (int) (key - '0');
533+ prefix = prefix * 10 + (int) (key - '0');
531534 return;
532− }
533−
534− for (i = 0; i < ARRLEN(keys); i++) {
535+ } else for (i = 0; i < ARRLEN(keys); i++) {
535536 if (keys[i].ksym == ksym &&
536537 MODMASK(keys[i].mask | sh) == MODMASK(kev->state) &&
537538 keys[i].cmd != NULL)
@@ -545,8 +546,6 @@ void on_keypress(XKeyEvent *kev)
545546 break;
546547 }
547548 }
548− if (i == ARRLEN(keys))
549− run_key_handler(XKeysymToString(ksym), kev->state & ~sh);
550549 prefix = 0;
551550 }
552551
M sxiv.1 View
@@ -125,6 +125,9 @@ Toggle fullscreen mode.
125125 .B b
126126 Toggle visibility of info bar on bottom of window.
127127 .TP
128+.B Ctrl-x
129+Send the next key to the external key-handler.
130+.TP
128131 .B A
129132 Toggle visibility of alpha-channel, i.e. image transparency.
130133 .TP
@@ -303,7 +306,7 @@ Decrease gamma.
303306 .B }
304307 Increase gamma.
305308 .TP
306−.B Ctrl-G
309+.B Ctrl-g
307310 Reset gamma.
308311 .SS Miscellaneous
309312 .TP