mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
37378: New bindkey tests.
Also fix Meta bug on pattern match in zpty -r.
This commit is contained in:
parent
67877f6055
commit
a5233fd01e
4 changed files with 70 additions and 7 deletions
|
@ -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>
|
2015-12-09 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
* 37364: Src/builtin.c, Src/text.c, Test/C02cond.ztst: "test"
|
* 37364: Src/builtin.c, Src/text.c, Test/C02cond.ztst: "test"
|
||||||
|
|
|
@ -614,14 +614,23 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cmd->read != -1 || (ret = read(cmd->fd, buf + used, 1)) == 1) {
|
if (cmd->read != -1 || (ret = read(cmd->fd, buf + used, 1)) == 1) {
|
||||||
|
int readchar;
|
||||||
if (cmd->read != -1) {
|
if (cmd->read != -1) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
buf[used] = (char) cmd->read;
|
readchar = cmd->read;
|
||||||
cmd->read = -1;
|
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;
|
seen = 1;
|
||||||
if (++used == blen) {
|
if (used >= blen-1) {
|
||||||
if (!*args) {
|
if (!*args) {
|
||||||
|
buf[used] = '\0';
|
||||||
|
unmetafy(buf, &used);
|
||||||
write_loop(1, buf, used);
|
write_loop(1, buf, used);
|
||||||
used = 0;
|
used = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -633,7 +642,8 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
|
||||||
buf[used] = '\0';
|
buf[used] = '\0';
|
||||||
|
|
||||||
if (!prog) {
|
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;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (ret < 0
|
if (ret < 0
|
||||||
|
@ -666,9 +676,11 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (*args)
|
if (*args)
|
||||||
setsparam(*args, ztrdup(metafy(buf, used, META_HREALLOC)));
|
setsparam(*args, ztrdup(buf));
|
||||||
else if (used)
|
else if (used) {
|
||||||
|
unmetafy(buf, &used);
|
||||||
write_loop(1, buf, used);
|
write_loop(1, buf, used);
|
||||||
|
}
|
||||||
|
|
||||||
if (seen && (!prog || matchok || !mustmatch))
|
if (seen && (!prog || matchok || !mustmatch))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
45
Test/X03zlebindkey.ztst
Normal file
45
Test/X03zlebindkey.ztst
Normal file
|
@ -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
|
|
@ -27,7 +27,7 @@ comptestinit () {
|
||||||
}
|
}
|
||||||
|
|
||||||
comptesteval \
|
comptesteval \
|
||||||
"export LC_ALL=C" \
|
"export LC_ALL=${ZSH_TEST_LANG:-C}" \
|
||||||
"emulate -R zsh" \
|
"emulate -R zsh" \
|
||||||
"export ZDOTDIR=$ZTST_testdir" \
|
"export ZDOTDIR=$ZTST_testdir" \
|
||||||
"module_path=( $module_path )" \
|
"module_path=( $module_path )" \
|
||||||
|
|
Loading…
Reference in a new issue