mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-21 00:01:26 +01:00
restore read-from-minibuffer save/restore
This commit is contained in:
parent
71e5f09d58
commit
84e1cb93ad
3 changed files with 48 additions and 17 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-04-07 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 24797: Doc/Zsh/zle.yo, Functions/Zle/read-from-minibuffer:
|
||||||
|
document POSTDISPLAY highlighting; restore read-from-minibuffer
|
||||||
|
save/restore mechanism using variables to avoid problems with
|
||||||
|
not restoring special ZLE variables when they go out of scope.
|
||||||
|
|
||||||
2008-04-05 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2008-04-05 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* İsmail Dönmez <ismail@namtrac.org>: 24793: Doc/Zsh/zle.yo:
|
* İsmail Dönmez <ismail@namtrac.org>: 24793: Doc/Zsh/zle.yo:
|
||||||
|
|
|
@ -778,8 +778,12 @@ vindex(region_highlight)
|
||||||
item(tt(region_highlight) (array))(
|
item(tt(region_highlight) (array))(
|
||||||
Each element of this array may be set to a string that describes
|
Each element of this array may be set to a string that describes
|
||||||
highlighting for an arbitrary region of the command line that will
|
highlighting for an arbitrary region of the command line that will
|
||||||
take effect the next time the command line is redisplayed. Each
|
take effect the next time the command line is redisplayed. Highlighting
|
||||||
string consists of the following parts:
|
of the non-editable parts of the command line in tt(PREDISPLAY)
|
||||||
|
and tt(POSTDISPLAY) are possible, but note that the tt(P) flag
|
||||||
|
is needed for character indexing to include tt(PREDISPLAY).
|
||||||
|
|
||||||
|
Each string consists of the following parts:
|
||||||
|
|
||||||
startlist()
|
startlist()
|
||||||
list(Optionally, a `tt(P)' to signify that the start and end offset that
|
list(Optionally, a `tt(P)' to signify that the start and end offset that
|
||||||
|
|
|
@ -21,21 +21,41 @@ done
|
||||||
|
|
||||||
local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY
|
local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY
|
||||||
"
|
"
|
||||||
local LBUFFER="$2"
|
# We could use the local variables mechanism to save these
|
||||||
local RBUFFER="$3"
|
# values, but if read-from-minibuffer is called as a widget
|
||||||
local PREDISPLAY="$pretext${1:-? }"
|
# (which isn't actually all that useful) the values won't be
|
||||||
local POSTDISPLAY=
|
# restored because the variables are already local at the current
|
||||||
local -a region_highlight
|
# level and don't get restored when they go out of scope.
|
||||||
region_highlight=("P${#pretext} ${#PREDISPLAY} bold")
|
# 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[@]}")
|
||||||
|
|
||||||
if [[ -n $keys ]]; then
|
{
|
||||||
zle -R
|
LBUFFER="$2"
|
||||||
read -k $keys
|
RBUFFER="$3"
|
||||||
stat=$?
|
PREDISPLAY="$pretext${1:-? }"
|
||||||
else
|
POSTDISPLAY=
|
||||||
zle recursive-edit -K main
|
region_highlight=("P${#pretext} ${#PREDISPLAY} bold")
|
||||||
stat=$?
|
|
||||||
(( stat )) || REPLY=$BUFFER
|
if [[ -n $keys ]]; then
|
||||||
fi
|
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
|
return $stat
|
||||||
|
|
Loading…
Reference in a new issue