|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /usr/share/zsh/4.3.10/functions/ |
Upload File : |
emulate -L zsh
setopt extendedglob
local opt keys
integer stat
while getopts "k:" opt; do
case $opt in
# Read the given number of keys. This is a bit
# ropey for more than a single key.
(k)
keys=$OPTARG
;;
(*)
return 1
;;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY
"
# We could use the local variables mechanism to save these
# values, but if read-from-minibuffer is called as a widget
# (which isn't actually all that useful) the values won't be
# restored because the variables are already local at the current
# level and don't get restored when they go out of scope.
# We could do it with an additional function level.
local save_lbuffer=$LBUFFER
local save_rbuffer=$RBUFFER
local save_predisplay=$PREDISPLAY
local save_postdisplay=$POSTDISPLAY
local -a save_region_highlight
save_region_highlight=("${region_highlight[@]}")
{
LBUFFER="$2"
RBUFFER="$3"
PREDISPLAY="$pretext${1:-? }"
POSTDISPLAY=
region_highlight=("P${#pretext} ${#PREDISPLAY} bold")
if [[ -n $keys ]]; then
zle -R
read -k $keys
stat=$?
else
zle recursive-edit -K main
stat=$?
(( stat )) || REPLY=$BUFFER
fi
} always {
LBUFFER=$save_lbuffer
RBUFFER=$save_rbuffer
PREDISPLAY=$save_predisplay
POSTDISPLAY=$save_postdisplay
region_highlight=("${save_region_highlight[@]}")
}
return $stat