diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-09-11 21:40:45 +0100 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-09-11 21:40:45 +0100 |
commit | e1c0a947cc845c71dd844db44016d07922cfcefa (patch) | |
tree | f952b7ac97712807e1d2b696987a00afdaf7ddf8 /Src/Zle/zle_keymap.c | |
parent | 560a23033d2d0e029bbbcda0366053d8d87a37d9 (diff) | |
download | zsh-e1c0a947cc845c71dd844db44016d07922cfcefa.tar.gz zsh-e1c0a947cc845c71dd844db44016d07922cfcefa.tar.xz zsh-e1c0a947cc845c71dd844db44016d07922cfcefa.zip |
Read full multibyte string early for self-insert
Diffstat (limited to 'Src/Zle/zle_keymap.c')
-rw-r--r-- | Src/Zle/zle_keymap.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 5b4189faa..069580f8a 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1501,6 +1501,20 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp) * they wait till a key is pressed for the movement anyway */ timeout = !(!virangeflag && !region_active && f && f->widget && f->widget->flags & ZLE_VIOPER); +#ifdef MULTIBYTE_SUPPORT + if ((f == Th(z_selfinsert) || f == Th(z_selfinsertunmeta)) && + !lastchar_wide_valid) { + int len; + VARARR(char, mbc, MB_CUR_MAX); + ZLE_INT_T inchar = getrestchar(lastchar, mbc, &len); + if (inchar != WEOF && len) { + char *ptr = mbc; + while (len--) + addkeybuf(STOUC(*ptr++)); + lastlen = keybuflen; + } + } +#endif } if (!ispfx) break; @@ -1521,6 +1535,20 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp) return keybuf; } +/**/ +static void +addkeybuf(int c) +{ + if(keybuflen + 3 > keybufsz) + keybuf = realloc(keybuf, keybufsz *= 2); + if(imeta(c)) { + keybuf[keybuflen++] = Meta; + keybuf[keybuflen++] = c ^ 32; + } else + keybuf[keybuflen++] = c; + keybuf[keybuflen] = 0; +} + /* * Add a (possibly metafied) byte to the key input so far. * This handles individual bytes of a multibyte string separately; @@ -1542,14 +1570,7 @@ getkeybuf(int w) if(c < 0) return EOF; - if(keybuflen + 3 > keybufsz) - keybuf = realloc(keybuf, keybufsz *= 2); - if(imeta(c)) { - keybuf[keybuflen++] = Meta; - keybuf[keybuflen++] = c ^ 32; - } else - keybuf[keybuflen++] = c; - keybuf[keybuflen] = 0; + addkeybuf(c); return c; } |