diff options
Diffstat (limited to 'Src/Zle/zle_keymap.c')
-rw-r--r-- | Src/Zle/zle_keymap.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index ec8dd031e..5012917f5 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -745,7 +745,7 @@ bin_bindkey(char *name, char **argv, Options ops, UNUSED(int func)) static struct opn { char o; char selp; - int (*func) _((char *, char *, Keymap, char **, Options, char)); + int (*func) (char *, char *, Keymap, char **, Options, char); int min, max; } const opns[] = { { 'l', 0, bin_bindkey_lsmaps, 0, -1 }, @@ -1315,7 +1315,7 @@ default_bindings(void) Keymap vismap = newkeymap(NULL, "visual"); Keymap smap = newkeymap(NULL, ".safe"); Keymap vimaps[2], vilmaps[2], kptr; - char buf[3], *ed; + char buf[3]; int i; /* vi insert mode and emacs mode: * @@ -1445,20 +1445,14 @@ default_bindings(void) } /* Put the keymaps in the right namespace. The "main" keymap * - * will be linked to the "emacs" keymap, except that if VISUAL * - * or EDITOR contain the string "vi" then it will be linked to * - * the "viins" keymap. */ + * will be linked to the "emacs" keymap. */ linkkeymap(vmap, "viins", 0); linkkeymap(emap, "emacs", 0); linkkeymap(amap, "vicmd", 0); linkkeymap(oppmap, "viopp", 0); linkkeymap(vismap, "visual", 0); linkkeymap(smap, ".safe", 1); - if (((ed = zgetenv("VISUAL")) && strstr(ed, "vi")) || - ((ed = zgetenv("EDITOR")) && strstr(ed, "vi"))) - linkkeymap(vmap, "main", 0); - else - linkkeymap(emap, "main", 0); + linkkeymap(emap, "main", 0); /* the .safe map cannot be modified or deleted */ smap->flags |= KM_IMMUTABLE; @@ -1586,7 +1580,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp) Thingy func = t_undefinedkey; char *str = NULL; int lastlen = 0, lastc = lastchar; - int timeout = 0, csi = 0, startcsi; + int timeout = 0, csi = 0; keybuflen = 0; keybuf[0] = 0; @@ -1640,22 +1634,23 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp) /* CSI key sequences have a well defined structure so if we currently * have an incomplete one, loop so the rest of it will be included in * the key sequence if that arrives within the timeout. */ - if (keybuflen >= 3 && !csi) { - startcsi = keybuflen - 3; - csi = keybuf[startcsi] == '\033' && keybuf[keybuflen - 2] == '['; - } + if (!csi && keybuflen >= 3 && keybuf[keybuflen - 3] == '\033' && + keybuf[keybuflen - 2] == '[') + csi = keybuflen - 1; if (csi) { - csi = keybuf[keybuflen - 2] != Meta && keybuf[keybuflen - 1] >= 0x20 - && keybuf[keybuflen - 1] <= 0x3f; + if (keybuf[keybuflen - 2] == Meta || keybuf[keybuflen - 1] < 0x20 + || keybuf[keybuflen - 1] > 0x3f) { /* If we reach the end of a valid CSI sequence and the matched key * binding is for part of the CSI introduction, select instead the * undefined-key widget and consume the full sequence from the * input buffer. */ - if (!csi && keybuf[keybuflen - 1] >= 0x40 && - keybuf[keybuflen - 1] <= 0x7e && lastlen > startcsi && - lastlen <= startcsi + 2) { - func = t_undefinedkey; - lastlen = keybuflen; + if (keybuf[keybuflen - 1] >= 0x40 && + keybuf[keybuflen - 1] <= 0x7e && lastlen > csi - 2 && + lastlen <= csi) { + func = t_undefinedkey; + lastlen = keybuflen; + } + csi = 0; } } |