aboutsummaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
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;