main: Split highlighting code into another function

This will allow for highlighting $( ) and similar.
This commit is contained in:
Matthew Martin 2018-03-10 14:47:52 -06:00
parent 81e89a8800
commit ead8f8a1fc
1 changed files with 11 additions and 3 deletions

View File

@ -271,8 +271,16 @@ _zsh_highlight_highlighter_main_paint()
'!' # reserved word; unrelated to $histchars[1]
)
integer start_pos=0 end_pos buf_offset=-$#PREBUFFER
local buf="$PREBUFFER$BUFFER" highlight_glob=true arg style
_zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' "$PREBUFFER$BUFFER"
}
# $1 is the offset of $3 from the parent buffer. Added to the returned highlights.
# $2 is the initial braces_stack (for a closing paren).
# $3 is the buffer to highlight.
_zsh_highlight_main_highlighter_highlight_list()
{
integer start_pos=0 end_pos buf_offset=$1
local buf=$3 highlight_glob=true arg style
local in_array_assignment=false # true between 'a=(' and the matching ')'
integer len=$#buf
local -a match mbegin mend
@ -285,7 +293,7 @@ _zsh_highlight_highlighter_main_paint()
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
# ":" for 'then'
local braces_stack
local braces_stack=$2
# State machine
#