diff options
author | András Mohari <andras.mohari@gmail.com> | 2014-01-31 14:17:52 +0100 |
---|---|---|
committer | András Mohari <andras.mohari@gmail.com> | 2014-01-31 14:17:52 +0100 |
commit | 54d7b7f20fc80460fb6160badb6d90e6505a4194 (patch) | |
tree | 0b0aab780889e9e26296f2231469f19bccfbf3aa /main.c | |
parent | d5b2d377a44db7408c90e5e15e35458bcc0f340c (diff) | |
download | nsxiv-54d7b7f20fc80460fb6160badb6d90e6505a4194.tar.zst |
Use a prefix key to execute the key handler
The default prefix key is C-x, and can be changed in config.def.h. The
first key pressed after the prefix key will be passed the external key
handler, unless the key is Escape, which is used to cancel the prefix.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -504,6 +504,7 @@ 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,6 +524,17 @@ 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')) { @@ -545,8 +557,6 @@ void on_keypress(XKeyEvent *kev) break; } } - if (i == ARRLEN(keys)) - run_key_handler(XKeysymToString(ksym), kev->state & ~sh); prefix = 0; } |