diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Src/Modules/zpty.c | 24 | ||||
-rw-r--r-- | Test/X03zlebindkey.ztst | 45 | ||||
-rw-r--r-- | Test/comptest | 2 |
4 files changed, 70 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index aab214f2f..d1db73e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-12-10 Peter Stephenson <p.stephenson@samsung.com> + + * 37378: Src/Modules/zpty.c, Test/X03zlebindkey.ztst, + Test/comptest: New bindkey tests; also fix Meta bug with pattern + match on zpty -r. + 2015-12-09 Peter Stephenson <p.stephenson@samsung.com> * 37364: Src/builtin.c, Src/text.c, Test/C02cond.ztst: "test" diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 02708a915..63ff7578c 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -614,14 +614,23 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch) break; } if (cmd->read != -1 || (ret = read(cmd->fd, buf + used, 1)) == 1) { + int readchar; if (cmd->read != -1) { ret = 1; - buf[used] = (char) cmd->read; + readchar = cmd->read; cmd->read = -1; - } + } else + readchar = STOUC(buf[used]); + if (imeta(readchar)) { + buf[used++] = Meta; + buf[used++] = (char) (readchar ^ 32); + } else + buf[used++] = (char) readchar; seen = 1; - if (++used == blen) { + if (used >= blen-1) { if (!*args) { + buf[used] = '\0'; + unmetafy(buf, &used); write_loop(1, buf, used); used = 0; } else { @@ -633,7 +642,8 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch) buf[used] = '\0'; if (!prog) { - if (ret <= 0 || (*args && buf[used - 1] == '\n')) + if (ret <= 0 || (*args && buf[used - 1] == '\n' && + (used < 2 || buf[used-2] != Meta))) break; } else { if (ret < 0 @@ -666,9 +676,11 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch) return 1; } if (*args) - setsparam(*args, ztrdup(metafy(buf, used, META_HREALLOC))); - else if (used) + setsparam(*args, ztrdup(buf)); + else if (used) { + unmetafy(buf, &used); write_loop(1, buf, used); + } if (seen && (!prog || matchok || !mustmatch)) return 0; diff --git a/Test/X03zlebindkey.ztst b/Test/X03zlebindkey.ztst new file mode 100644 index 000000000..70c42f9c2 --- /dev/null +++ b/Test/X03zlebindkey.ztst @@ -0,0 +1,45 @@ +# Tests of the vi mode of ZLE + +%prep + mb_ok= + langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8 + $(locale -a 2>/dev/null | egrep 'utf8|UTF-8')) + for LANG in $langs; do + if [[ é = ? ]]; then + ZSH_TEST_LANG=$LANG + mb_ok=1 + break; + fi + done + if [[ $OSTYPE = cygwin ]]; then + ZTST_unimplemented="the zsh/zpty module does not work on Cygwin" + elif ( zmodload zsh/zpty 2>/dev/null ); then + . $ZTST_srcdir/comptest + comptestinit -z $ZTST_testdir/../Src/zsh + else + ZTST_unimplemented="the zsh/zpty module is not available" + fi + +%test + + zpty_run 'bindkey -s "\C-xy" foo' + zletest $'\C-xy' + zpty_run 'bindkey -r "\C-xy"' +0:bindkey -s +>BUFFER: foo +>CURSOR: 3 + + if [[ -z $mb_ok ]]; then + ZTST_skip="bindkey multibyte test skipped" + else + zpty_run 'alias unbind="bindkey -r ホ"' + zpty_run 'bindkey -s ホ bar' + zletest 'ホ' + zpty_run unbind + zletest 'ホ' + fi +0:bindkey -s multibyte characters +>BUFFER: bar +>CURSOR: 3 +>BUFFER: ホ +>CURSOR: 1 diff --git a/Test/comptest b/Test/comptest index f10739abe..166d0b404 100644 --- a/Test/comptest +++ b/Test/comptest @@ -27,7 +27,7 @@ comptestinit () { } comptesteval \ -"export LC_ALL=C" \ +"export LC_ALL=${ZSH_TEST_LANG:-C}" \ "emulate -R zsh" \ "export ZDOTDIR=$ZTST_testdir" \ "module_path=( $module_path )" \ |