From 632b5909af96861c881865afae8638a2fd072668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 14 Oct 2015 23:00:47 +0200 Subject: vis: introduce special keys which allow mappings to editor actions Key bindings in vis are always recursive, hence mapping ~ to ~l will cause an infinite loop. Instead vis supports special editor "keys" which map to internal editor functions. As an example one can thus map ~ to l or even Furthermore this makes it possible to completely unmap core editor features such as operators, the corresponding funtionality is still available via its corresponding special key. --- editor.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'editor.c') diff --git a/editor.c b/editor.c index c07eed7..4484b0a 100644 --- a/editor.c +++ b/editor.c @@ -252,6 +252,14 @@ bool editor_mode_unmap(Mode *mode, const char *name) { return map_delete(mode->bindings, name); } +bool editor_action_register(Editor *ed, KeyAction *action) { + if (!ed->actions) + ed->actions = map_new(); + if (!ed->actions) + return false; + return map_put(ed->actions, action->name, action); +} + static void window_free(Win *win) { if (!win) return; @@ -430,6 +438,7 @@ void editor_free(Editor *ed) { ed->ui->free(ed->ui); map_free(ed->cmds); map_free(ed->options); + map_free(ed->actions); buffer_release(&ed->buffer_repeat); free(ed); } -- cgit v1.2.3