aboutsummaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-09-13 17:49:38 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-10-05 15:54:30 +0200
commita76057df97157dc76959bcd40649f5953aebc9d3 (patch)
tree75df46b238edacc60ede00ee5821d47cb814b316 /editor.c
parentfa950307aeb2a060be72fc73e0017e5497cb4ace (diff)
downloadvis-a76057df97157dc76959bcd40649f5953aebc9d3.tar.gz
vis-a76057df97157dc76959bcd40649f5953aebc9d3.tar.xz
vis: rework input handling using libtermkey
Key bindings are now specified as symbolic key strings, this will eventually allow run time configurable key mappings. This introduces a bulid time dependency on libtermkey which can be found at: http://www.leonerd.org.uk/code/libtermkey/
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/editor.c b/editor.c
index e06e946..70cc162 100644
--- a/editor.c
+++ b/editor.c
@@ -230,6 +230,27 @@ void editor_suspend(Editor *ed) {
ed->ui->suspend(ed->ui);
}
+bool editor_mode_map(Mode *mode, const char *name, KeyBinding *binding) {
+ return map_put(mode->bindings, name, binding);
+}
+
+bool editor_mode_bindings(Mode *mode, KeyBinding **bindings) {
+ if (!mode->bindings)
+ mode->bindings = map_new();
+ if (!mode->bindings)
+ return false;
+ bool success = true;
+ for (KeyBinding *kb = *bindings; kb->key; kb++) {
+ if (!editor_mode_map(mode, kb->key, kb))
+ success = false;
+ }
+ return success;
+}
+
+bool editor_mode_unmap(Mode *mode, const char *name) {
+ return map_delete(mode->bindings, name);
+}
+
static void window_free(Win *win) {
if (!win)
return;