aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-12 16:43:49 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-12 17:38:45 +0200
commit35b7e991e2d9c53380bd103461b74438d61503c1 (patch)
treee59c516df1ca5cdb3b6a97d62310d46ad70fc1c8 /vis.c
parentad1cea9e79f191d6efb8ba7ba183c94c63e56e37 (diff)
downloadvis-35b7e991e2d9c53380bd103461b74438d61503c1.tar.gz
vis-35b7e991e2d9c53380bd103461b74438d61503c1.tar.xz
Add a global keypress hook before any keybindings are checked
If the registered function returns false, completely ignore the key.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/vis.c b/vis.c
index 70b6049..6697237 100644
--- a/vis.c
+++ b/vis.c
@@ -76,6 +76,8 @@ typedef struct {
char *name; /* is used to match against argv[0] to enable this config */
Mode *mode; /* default mode in which the editor should start in */
void (*statusbar)(EditorWin*); /* routine which is called whenever the cursor is moved within a window */
+ bool (*keypress)(Key*); /* called before any other keybindings are checked,
+ * return value decides whether key should be ignored */
} Config;
typedef struct {
@@ -1189,6 +1191,9 @@ int main(int argc, char *argv[]) {
}
key = getkey();
+ if (config->keypress && !config->keypress(&key))
+ continue;
+
KeyBinding *action = keybinding(mode, key_mod ? key_mod : &key, key_mod ? &key : NULL);
if (!action && key_mod) {