driver: Rewrite without a state variable

Suggested-by: m0viefreak
This commit is contained in:
Daniel Shahaf 2016-10-17 15:12:24 +00:00 committed by Matthew Martin
parent d2594c1157
commit b5249f17ab

View file

@ -93,13 +93,6 @@ _zsh_highlight__function_callable_p() {
fi fi
} }
integer zsh_highlight_use_redrawhook
if _zsh_highlight__function_callable_p add-zle-hook-widget
then
autoload -U add-zle-hook-widget
(( zsh_highlight_use_redrawhook=1 ))
fi
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Core highlighting update system # Core highlighting update system
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
@ -341,7 +334,25 @@ _zsh_highlight_call_widget()
_zsh_highlight _zsh_highlight
} }
if true; then if _zsh_highlight__function_callable_p add-zle-hook-widget
then
autoload -U add-zle-hook-widget
_zsh_highlight__zle-line-finish() {
# Reset $WIDGET since the 'main' highlighter depends on it.
#
# A nested function is required to hide zle parameters; see
# "User-defined widgets" in zshall.
() {
local -h +r WIDGET=zle-line-finish
_zsh_highlight "$@"
} "$@"
}
_zsh_highlight_bind_widgets(){}
if [[ -o zle ]]; then
add-zle-hook-widget zle-line-pre-redraw _zsh_highlight
add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish
fi
else
# Rebind all ZLE widgets to make them invoke _zsh_highlights. # Rebind all ZLE widgets to make them invoke _zsh_highlights.
_zsh_highlight_bind_widgets() _zsh_highlight_bind_widgets()
{ {
@ -410,24 +421,6 @@ if true; then
} }
fi fi
if (( $zsh_highlight_use_redrawhook )); then
_zsh_highlight__zle-line-finish() {
# Reset $WIDGET since the 'main' highlighter depends on it.
#
# A nested function is required to hide zle parameters; see
# "User-defined widgets" in zshall.
() {
local -h +r WIDGET=zle-line-finish
_zsh_highlight "$@"
} "$@"
}
_zsh_highlight_bind_widgets(){}
if [[ -o zle ]]; then
add-zle-hook-widget zle-line-pre-redraw _zsh_highlight
add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish
fi
fi
# Load highlighters from directory. # Load highlighters from directory.
# #
# Arguments: # Arguments: