vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit dd8e316f829133cba5c413db5686842e5bc40363 parent ff07c8c1023fb8ade79748104f37c47d0ab5ec33 Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 12 Sep 2014 16:43:49 +0200 Add a global keypress hook before any keybindings are checked If the registered function returns false, completely ignore the key. Diffstat:
| M | vis.c | | | 5 | +++++ |
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git 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) {