1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 05:24:23 +01:00
zsh/Functions/Zle/read-from-minibuffer
2003-03-28 11:34:07 +00:00

45 lines
677 B
Plaintext

emulate -L zsh
setopt extendedglob
local opt keys
integer stat
while getopts "k:" opt; do
case $opt in
(k)
keys=$OPTARG
;;
(*)
return 1
;;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
local savelbuffer=$LBUFFER saverbuffer=$RBUFFER
local savepredisplay=$PREDISPLAY savepostdisplay=$POSTDISPLAY
LBUFFER=
RBUFFER=
PREDISPLAY="$PREDISPLAY$savelbuffer$saverbuffer$POSTDISPLAY
${1:-? }"
POSTDISPLAY=
if [[ -n $keys ]]; then
zle -R
read -k $keys
stat=$?
else
zle recursive-edit
stat=$?
(( stat )) || REPLY=$BUFFER
fi
LBUFFER=$savelbuffer
RBUFFER=$saverbuffer
PREDISPLAY=$savepredisplay
POSTDISPLAY=$savepostdisplay
return $stat