mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-29 17:31:02 +01:00
32377: change keybindings and PTY control for vi-mode tests to make them more reliable
This commit is contained in:
parent
ba58bfe4bf
commit
5c89c4ca9c
2 changed files with 33 additions and 8 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2014-02-13 Barton E. Schaefer <schaefer@brasslantern.com>
|
||||||
|
|
||||||
|
* 32377: Test/comptest: change keybindings and PTY control for
|
||||||
|
vi-mode tests to make them more reliable
|
||||||
|
|
||||||
2014-02-08 Barton E. Schaefer <schaefer@zsh.org>
|
2014-02-08 Barton E. Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
* 32365: Src/Zle/zle_refresh.c, Src/init.c: another stab at the
|
* 32365: Src/Zle/zle_refresh.c, Src/init.c: another stab at the
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,15 @@ comp-finish () {
|
||||||
zle -R
|
zle -R
|
||||||
}
|
}
|
||||||
zle-finish () {
|
zle-finish () {
|
||||||
print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR"
|
local buffer="$BUFFER" cursor="$CURSOR" mark="$MARK"
|
||||||
(( region_active )) && print -lr "MARK: $MARK"
|
(( region_active)) || unset mark
|
||||||
zle -K main
|
BUFFER=""
|
||||||
|
zle -I
|
||||||
zle clear-screen
|
zle clear-screen
|
||||||
zle send-break
|
zle redisplay
|
||||||
zle -R
|
print -lr "<WIDGET><finish>" "BUFFER: $buffer" "CURSOR: $cursor"
|
||||||
|
(( $+mark )) && print -lr "MARK: $mark"
|
||||||
|
zle accept-line
|
||||||
}
|
}
|
||||||
zle -N expand-or-complete-with-report
|
zle -N expand-or-complete-with-report
|
||||||
zle -N list-choices-with-report
|
zle -N list-choices-with-report
|
||||||
|
|
@ -83,30 +86,45 @@ zle -N zle-finish
|
||||||
bindkey "^I" expand-or-complete-with-report
|
bindkey "^I" expand-or-complete-with-report
|
||||||
bindkey "^D" list-choices-with-report
|
bindkey "^D" list-choices-with-report
|
||||||
bindkey "^Z" comp-finish
|
bindkey "^Z" comp-finish
|
||||||
bindkey "^M" zle-finish
|
bindkey "^X" zle-finish
|
||||||
bindkey -a "^M" zle-finish
|
bindkey -a "^X" zle-finish
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zpty_flush() {
|
||||||
|
local junk
|
||||||
|
if zpty -r -t zsh junk \*; then
|
||||||
|
(( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}"
|
||||||
|
while zpty -r -t zsh junk \* ; do
|
||||||
|
(( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}"
|
||||||
|
done
|
||||||
|
(( ZTST_verobse > 2 )) && print -u $ZTST_fd ''
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
comptesteval () {
|
comptesteval () {
|
||||||
local tmp=/tmp/comptest.$$
|
local tmp=/tmp/comptest.$$
|
||||||
|
|
||||||
print -lr - "$@" > $tmp
|
print -lr - "$@" > $tmp
|
||||||
|
zpty_flush Before comptesteval
|
||||||
zpty -w zsh ". $tmp"
|
zpty -w zsh ". $tmp"
|
||||||
zpty -r -m zsh log_eval "*<PROMPT>*" || {
|
zpty -r -m zsh log_eval "*<PROMPT>*" || {
|
||||||
print "prompt hasn't appeared."
|
print "prompt hasn't appeared."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
zpty_flush After comptesteval
|
||||||
rm $tmp
|
rm $tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
comptest () {
|
comptest () {
|
||||||
input="$*"
|
input="$*"
|
||||||
|
zpty_flush Before comptest
|
||||||
zpty -n -w zsh "$input"$'\C-Z'
|
zpty -n -w zsh "$input"$'\C-Z'
|
||||||
zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
|
zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
|
||||||
print "failed to invoke finish widget."
|
print "failed to invoke finish widget."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
zpty_flush After comptest
|
||||||
|
|
||||||
logs=(${(s:<WIDGET>:)log})
|
logs=(${(s:<WIDGET>:)log})
|
||||||
shift logs
|
shift logs
|
||||||
|
|
@ -136,10 +154,12 @@ comptest () {
|
||||||
|
|
||||||
zletest () {
|
zletest () {
|
||||||
input="$*"
|
input="$*"
|
||||||
zpty -n -w zsh "$input"$'\C-M'
|
zpty_flush Before zletest
|
||||||
|
zpty -n -w zsh "$input"$'\C-X'
|
||||||
zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
|
zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
|
||||||
print "failed to invoke finish widget."
|
print "failed to invoke finish widget."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
zpty_flush After zletest
|
||||||
print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
|
print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue