]> git.mdlowis.com Git - projs/tide.git/commitdiff
Refactored keybinding processing code
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 30 Nov 2016 00:22:47 +0000 (19:22 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 30 Nov 2016 00:22:47 +0000 (19:22 -0500)
xedit.c
xpick [deleted file]

diff --git a/xedit.c b/xedit.c
index a89cd2fdd6e207647a30fa6951b0241355ce7f20..ad998ae6564958ddf0ff8085c06222125d1de16e 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -157,8 +157,6 @@ static KeyBinding Bindings[] = {
     { ModCtrl, 'o',        open_file    },
     //{ ModCtrl, 'p',        find_ctag    },
     //{ ModCtrl, 'g',        goto_ctag    },
-
-    { 0, 0, NULL } // End the table
 };
 
 /* External Commands
@@ -231,18 +229,16 @@ static void key_handler(int mods, Rune key) {
     /* handle the proper line endings */
     if (key == '\r') key = '\n';
     if (key == '\n' && currview()->buffer.crlf) key = RUNE_CRLF;
-    /* handle the key */
-    KeyBinding* bindings = Bindings;
+    /* search for a key binding entry */
     uint32_t mkey = tolower(key);
-    while (bindings->key) {
-        int keymods = bindings->mods;
-        if ((mkey == bindings->key) && (keymods == ModAny || keymods == mods)) {
-            bindings->action();
+    for (int i = 0; i < nelem(Bindings); i++) {
+        int keymods = Bindings[i].mods;
+        if ((mkey == Bindings[i].key) && (keymods == ModAny || keymods == mods)) {
+            Bindings[i].action();
             return;
         }
-        bindings++;
     }
-    /* fallback to just inserting the rune if it doesnt fall in the private use area.
+    /* fallback to just inserting the rune if it doesn't fall in the private use area.
      * the private use area is used to encode special keys */
     if (key < 0xE000 || key > 0xF8FF)
         view_insert(currview(), key);
diff --git a/xpick b/xpick
deleted file mode 100755 (executable)
index a0917fb..0000000
Binary files a/xpick and /dev/null differ