1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-19 23:41:31 +01:00
zsh/Test/comptest

120 lines
2.8 KiB
Text
Raw Normal View History

2000-02-29 16:51:18 +01:00
#!/usr/local/bin/zsh -f
2000-03-03 19:42:49 +01:00
[[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
2000-03-01 19:31:21 +01:00
zmodload -i zsh/zpty
2000-02-29 16:51:18 +01:00
setopt extendedglob
2000-03-24 13:47:37 +01:00
fpath=( $ZTST_srcdir/../(Completion|Functions)/*~*/CVS(/) )
2000-03-03 19:42:49 +01:00
2000-02-29 16:51:18 +01:00
debug=
dump=(-D)
code=
zsh=${ZSH:-zsh}
2000-03-01 16:38:25 +01:00
termcap_ce="$(echotc ce)"
2000-02-29 16:51:18 +01:00
while getopts Dd:c:z: opt; do
case $opt in
D) debug=yes;;
d) dump=(-d "$OPTARG");;
c) code="$OPTARG";;
z) zsh="$OPTARG";;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
input="$*"
2000-03-01 14:14:50 +01:00
tmp=/tmp/comptest.$$
cat <<End >$tmp
2000-03-03 19:42:49 +01:00
module_path=( $module_path )
fpath=( $fpath )
2000-03-01 14:14:50 +01:00
stty columns 80 rows 24
2000-02-29 16:51:18 +01:00
LISTMAX=10000000
2000-03-01 14:14:50 +01:00
ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
2000-02-29 16:51:18 +01:00
bindkey -e
autoload -U compinit
compinit $dump
2000-03-01 14:14:50 +01:00
zstyle ":completion:*" group-name ""
2000-02-29 16:51:18 +01:00
zstyle ":completion*:messages" format "<MESSAGE>%d</MESSAGE>
"
zstyle ":completion*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
"
zstyle ":completion*:options" verbose yes
zstyle ":completion*:values" verbose yes
setopt noalwayslastprompt listrowsfirst completeinword
zmodload zsh/complist
expand-or-complete-with-report () {
print -lr "<WIDGET><expand-or-complete>"
zle expand-or-complete
2000-03-01 14:14:50 +01:00
print -lr - "<LBUFFER>\$LBUFFER</LBUFFER>" "<RBUFFER>\$RBUFFER</RBUFFER>"
2000-02-29 16:51:18 +01:00
zle clear-screen
zle -R
}
list-choices-with-report () {
print -lr "<WIDGET><list-choices>"
zle list-choices
zle clear-screen
zle -R
}
finish () {
print "<WIDGET><finish>"
2000-03-01 18:14:54 +01:00
sleep 1
2000-02-29 16:51:18 +01:00
exit 0
}
zle -N expand-or-complete-with-report
zle -N list-choices-with-report
zle -N finish
bindkey "^I" expand-or-complete-with-report
bindkey "^D" list-choices-with-report
bindkey "^Z" finish
2000-03-01 14:14:50 +01:00
$code
End
2000-02-29 16:51:18 +01:00
export PS1="<PROMPT>"
zpty zsh "$zsh" -f
2000-03-01 18:14:54 +01:00
zpty -r zsh log1 "*<PROMPT>*" || {
print first prompt doesn\'t appered.
exit 1
}
2000-02-29 16:51:18 +01:00
2000-03-01 14:14:50 +01:00
zpty -w zsh ". $tmp"
2000-03-01 18:14:54 +01:00
zpty -r zsh log2 "*<PROMPT>*" || {
print second prompt doesn\'t appered.
exit 1
}
2000-03-01 14:14:50 +01:00
rm $tmp
2000-02-29 16:51:18 +01:00
2000-03-01 18:14:54 +01:00
zpty -n -w zsh "$input"$'\C-Z'
zpty -r zsh log "*<WIDGET><finish>*" || {
print finish widget doesn\'t invoked.
exit 1
}
2000-02-29 16:51:18 +01:00
2000-03-01 14:14:50 +01:00
if [[ -n "$debug" ]]; then
print -lr - "$log" > /tmp/comptest.debug
fi
2000-02-29 16:51:18 +01:00
logs=(${(s:<WIDGET>:)log})
shift logs
for log in "$logs[@]"; do
if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
print -lr "line: {$match[1]}{$match[2]}"
fi
while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>)} )); do
log="${log[$mend[1]+1,-1]}"
if (( 0 <= $mbegin[2] )); then
if [[ $match[2] != TC && $match[3] != \ # ]]; then
2000-03-01 16:38:25 +01:00
print -lr "$match[2]:{${match[3]%$termcap_ce}}"
2000-02-29 16:51:18 +01:00
fi
elif (( 0 <= $mbegin[4] )); then
2000-03-01 14:14:50 +01:00
print -lr "DESCRIPTION:{$match[4]}"
2000-02-29 16:51:18 +01:00
elif (( 0 <= $mbegin[5] )); then
2000-03-01 14:14:50 +01:00
print -lr "MESSAGE:{$match[5]}"
2000-02-29 16:51:18 +01:00
fi
done
done