aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--README.md9
-rw-r--r--commands.c7
-rw-r--r--commands.h1
-rw-r--r--config.def.h10
-rw-r--r--exec/key-handler6
-rw-r--r--main.c29
-rw-r--r--sxiv.15
8 files changed, 33 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 6ba746a..fa9d000 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = git-20140115
+VERSION = git-20140131
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
diff --git a/README.md b/README.md
index b30bb35..8939411 100644
--- a/README.md
+++ b/README.md
@@ -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]
@@ -113,10 +115,6 @@ of small previews is displayed, making it easy to choose an image to open.
N Go [count] marked images forward
P Go [count] marked images backward
- Ctrl-x KEY Execute $XDG_CONFIG_HOME/sxiv/exec/key-handler with
- KEY and the path of the current image as arguments,
- unless KEY is Escape, which cancels Ctrl-x.
-
*Thumbnail mode:*
h,j,k,l Move selection left/down/up/right [count] times
@@ -148,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
diff --git a/commands.c b/commands.c
index 4e8770c..22ac788 100644
--- a/commands.c
+++ b/commands.c
@@ -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) {
diff --git a/commands.h b/commands.h
index 5be721c..aebd253 100644
--- a/commands.h
+++ b/commands.h
@@ -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 1fa8de7..8c2c7ed 100644
--- a/config.def.h
+++ b/config.def.h
@@ -77,12 +77,6 @@ static const bool RENDER_WHITE_ALPHA = false;
#endif
#ifdef _MAPPINGS_CONFIG
-/* the prefix key: when pressed, the next key combo is passed to the external
- * key handler
- */
-#define PREFIX_KEYMASK ControlMask
-#define PREFIX_KEYSYM XK_x
-
/* keyboard mappings for image and thumbnail mode: */
static const keymap_t keys[] = {
/* modifiers key function argument */
@@ -91,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 },
@@ -161,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 db1fe2f..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) when you press the prefix key (C-x by default) followed by
-# a key combo. The key combo is passed 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.
diff --git a/main.c b/main.c
index 5d1ef41..f95b4f4 100644
--- a/main.c
+++ b/main.c
@@ -75,6 +75,7 @@ int filecnt, fileidx;
int alternate;
int prefix;
+bool extprefix;
bool resized = false;
@@ -504,7 +505,6 @@ void run_key_handler(const char *key, unsigned int mask)
void on_keypress(XKeyEvent *kev)
{
- static bool seen_prefix_key = false;
int i;
unsigned int sh;
KeySym ksym, shksym;
@@ -523,27 +523,16 @@ void on_keypress(XKeyEvent *kev)
if (IsModifierKey(ksym))
return;
-
- if (seen_prefix_key) {
- seen_prefix_key = false;
- if (!(MODMASK(kev->state) == 0 && ksym == XK_Escape))
- run_key_handler(XKeysymToString(ksym), kev->state & ~sh);
- return;
- } else if (MODMASK(kev->state) == PREFIX_KEYMASK && ksym == PREFIX_KEYSYM) {
- seen_prefix_key = true;
- prefix = 0;
- 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)
diff --git a/sxiv.1 b/sxiv.1
index f6d47f2..983e338 100644
--- a/sxiv.1
+++ b/sxiv.1
@@ -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