2000-05-17 14:31:32 +02:00
comptestinit () {
setopt extendedglob
[[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
2001-04-03 13:25:11 +02:00
fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/)
$ZTST_srcdir/../Completion
$ZTST_srcdir/../Completion/*/*~*/CVS(/) )
2000-02-29 16:51:21 +01:00
2001-06-25 05:06:33 +02:00
zmodload -i zsh/zpty || return $?
2000-05-17 13:59:32 +02:00
2000-05-17 14:31:32 +02:00
comptest_zsh=${ZSH:-zsh}
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
while getopts z: opt; do
case $opt in
z) comptest_zsh="$OPTARG";;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
export PS1="<PROMPT>"
2001-05-08 12:26:58 +02:00
zpty zsh "$comptest_zsh -f +Z"
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
zpty -r zsh log1 "*<PROMPT>*" || {
2000-06-06 01:06:52 +02:00
print "first prompt hasn't appeared."
2000-05-17 14:31:32 +02:00
return 1
}
2000-05-17 13:59:32 +02:00
2000-05-17 14:31:32 +02:00
comptesteval \
2000-07-04 02:45:07 +02:00
"export ZDOTDIR=$ZTST_testdir" \
2000-05-17 14:31:32 +02:00
"module_path=( $module_path )" \
"fpath=( $fpath )" \
'LISTMAX=10000000
2001-06-08 05:02:46 +02:00
TERM=vt100
2000-05-17 13:59:32 +02:00
stty columns 80 rows 24
2001-02-08 04:29:58 +01:00
setopt zle
2000-02-29 16:51:21 +01:00
bindkey -e
autoload -U compinit
2000-06-22 19:33:38 +02:00
compinit -u
2000-06-19 14:16:34 +02:00
zstyle ":completion:*:default" list-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-05-17 13:59:32 +02:00
zstyle ":completion:*" group-name ""
2000-06-19 14:16:34 +02:00
zstyle ":completion:*:messages" format "<MESSAGE>%d</MESSAGE>
2000-02-29 16:51:21 +01:00
"
2000-06-19 14:16:34 +02:00
zstyle ":completion:*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
2000-02-29 16:51:21 +01:00
"
2000-06-19 14:16:34 +02:00
zstyle ":completion:*:options" verbose yes
zstyle ":completion:*:values" verbose yes
2000-02-29 16:51:21 +01:00
setopt noalwayslastprompt listrowsfirst completeinword
zmodload zsh/complist
expand-or-complete-with-report () {
print -lr "<WIDGET><expand-or-complete>"
zle expand-or-complete
2000-05-17 14:31:32 +02:00
print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
2000-02-29 16:51:21 +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-05-17 14:31:32 +02:00
zle kill-whole-line
zle clear-screen
zle -R
2000-02-29 16:51:21 +01:00
}
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-05-17 14:31:32 +02:00
'
2000-05-17 13:59:32 +02:00
}
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
comptesteval () {
local tmp=/tmp/comptest.$$
2000-05-17 13:59:32 +02:00
2000-05-17 14:31:32 +02:00
print -lr - "$@" > $tmp
zpty -w zsh ". $tmp"
zpty -r zsh log_eval "*<PROMPT>*" || {
2000-06-06 01:06:52 +02:00
print "prompt hasn't appeared."
2000-05-17 14:31:32 +02:00
return 1
}
rm $tmp
2000-05-17 13:59:32 +02:00
}
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
comptest () {
input="$*"
zpty -n -w zsh "$input"$'\C-Z'
zpty -r zsh log "*<WIDGET><finish>*<PROMPT>*" || {
2000-06-06 01:06:52 +02:00
print "failed to invoke finish widget."
2000-05-17 14:31:32 +02:00
return 1
}
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
logs=(${(s:<WIDGET>:)log})
shift logs
2000-02-29 16:51:21 +01:00
2000-05-17 14:31:32 +02:00
for log in "$logs[@]"; do
if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
print -lr "line: {$match[1]}{$match[2]}"
2000-02-29 16:51:21 +01:00
fi
2001-01-28 20:37:30 +01:00
while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>|<COMPADD>(*)</COMPADD>|<INSERT_POSITIONS>(*)</INSERT_POSITIONS>)} )); do
2000-05-17 14:31:32 +02:00
log="${log[$mend[1]+1,-1]}"
if (( 0 <= $mbegin[2] )); then
if [[ $match[2] != TC && $match[3] != \ # ]]; then
2001-06-09 19:25:56 +02:00
print -lr "$match[2]:{${match[3]%${(%):-%E}}}"
2000-05-17 14:31:32 +02:00
fi
elif (( 0 <= $mbegin[4] )); then
print -lr "DESCRIPTION:{$match[4]}"
elif (( 0 <= $mbegin[5] )); then
print -lr "MESSAGE:{$match[5]}"
elif (( 0 <= $mbegin[6] )); then
2000-05-18 05:33:39 +02:00
print -lr "COMPADD:{${${match[6]}//[$'\r\n']/}}"
2001-01-28 20:37:30 +01:00
elif (( 0 <= $mbegin[7] )); then
print -lr "INSERT_POSITIONS:{${${match[7]}//[$'\r\n']/}}"
2000-05-17 14:31:32 +02:00
fi
done
2000-02-29 16:51:21 +01:00
done
2000-05-17 14:31:32 +02:00
}