mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
38579: simplify saving and restoring of state
This commit is contained in:
parent
d2a140e75d
commit
20948d0889
2 changed files with 22 additions and 25 deletions
|
@ -1,5 +1,8 @@
|
||||||
2016-06-09 Oliver Kiddle <opk@zsh.org>
|
2016-06-09 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 38579: Functions/Zle/bracketed-paste-magic: simplify saving
|
||||||
|
and restoring of state
|
||||||
|
|
||||||
* 38641: Completion/Base/Utility/_values: allow for values which
|
* 38641: Completion/Base/Utility/_values: allow for values which
|
||||||
resemble compadd options
|
resemble compadd options
|
||||||
|
|
||||||
|
|
|
@ -145,27 +145,26 @@ bracketed-paste-magic() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Save context, create a clean slate for the paste
|
|
||||||
integer bpm_mark=$MARK bpm_cursor=$CURSOR bpm_region=$REGION_ACTIVE
|
|
||||||
integer bpm_numeric=${NUMERIC:-1}
|
|
||||||
local bpm_buffer=$BUFFER
|
|
||||||
fc -p -a /dev/null 0 0
|
|
||||||
BUFFER=
|
|
||||||
|
|
||||||
zstyle -a :bracketed-paste-magic inactive-keys bpm_inactive
|
zstyle -a :bracketed-paste-magic inactive-keys bpm_inactive
|
||||||
if zstyle -s :bracketed-paste-magic active-widgets bpm_active '|'; then
|
if zstyle -s :bracketed-paste-magic active-widgets bpm_active '|'; then
|
||||||
# There are active widgets. Reprocess $PASTED as keystrokes.
|
# Save context, create a clean slate for the paste
|
||||||
NUMERIC=1
|
integer bpm_mark=$MARK bpm_region=$REGION_ACTIVE
|
||||||
zle -U - $PASTED
|
integer bpm_numeric=${NUMERIC:-1}
|
||||||
|
integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
|
||||||
|
BUFFER=
|
||||||
|
CURSOR=1
|
||||||
|
zle .split-undo
|
||||||
|
UNDO_LIMIT_NO=$UNDO_CHANGE_NO
|
||||||
|
fc -p -a /dev/null 0 0
|
||||||
if [[ $bmp_keymap = vicmd ]]; then
|
if [[ $bmp_keymap = vicmd ]]; then
|
||||||
zle -K viins
|
zle -K viins
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# There are active widgets. Reprocess $PASTED as keystrokes.
|
||||||
|
NUMERIC=1
|
||||||
|
zle -U - $PASTED
|
||||||
|
|
||||||
# Just in case there are active undo widgets
|
# Just in case there are active undo widgets
|
||||||
zle .split-undo
|
|
||||||
integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
|
|
||||||
UNDO_LIMIT_NO=$UNDO_CHANGE_NO
|
|
||||||
|
|
||||||
while [[ -n $PASTED ]] && zle .read-command; do
|
while [[ -n $PASTED ]] && zle .read-command; do
|
||||||
PASTED=${PASTED#$KEYS}
|
PASTED=${PASTED#$KEYS}
|
||||||
|
@ -183,21 +182,16 @@ bracketed-paste-magic() {
|
||||||
done
|
done
|
||||||
PASTED=$BUFFER
|
PASTED=$BUFFER
|
||||||
|
|
||||||
# Reset the undo state
|
# Restore state
|
||||||
|
zle -K $bpm_keymap
|
||||||
|
fc -P
|
||||||
|
MARK=$bpm_mark
|
||||||
|
REGION_ACTIVE=$bpm_region
|
||||||
|
NUMERIC=$bpm_numeric
|
||||||
zle .undo $bpm_undo
|
zle .undo $bpm_undo
|
||||||
UNDO_LIMIT_NO=$bpm_limit
|
UNDO_LIMIT_NO=$bpm_limit
|
||||||
|
|
||||||
zle -K $bpm_keymap
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore state
|
|
||||||
BUFFER=$bpm_buffer
|
|
||||||
MARK=$bpm_mark
|
|
||||||
CURSOR=$bpm_cursor
|
|
||||||
REGION_ACTIVE=$bpm_region
|
|
||||||
NUMERIC=$bpm_numeric
|
|
||||||
fc -P
|
|
||||||
|
|
||||||
# PASTED has been updated, run the paste-finish functions
|
# PASTED has been updated, run the paste-finish functions
|
||||||
if zstyle -a :bracketed-paste-magic paste-finish bpm_hooks; then
|
if zstyle -a :bracketed-paste-magic paste-finish bpm_hooks; then
|
||||||
for bpm_func in $bpm_hooks; do
|
for bpm_func in $bpm_hooks; do
|
||||||
|
|
Loading…
Reference in a new issue