From 35b7e991e2d9c53380bd103461b74438d61503c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 12 Sep 2014 16:43:49 +0200 Subject: Add a global keypress hook before any keybindings are checked If the registered function returns false, completely ignore the key. --- vis.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vis.c') 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) { -- cgit v1.2.3