hsmw: Optimize shifting indexes by offset – *highlight can take offset

This commit is contained in:
Sebastian Gniazdowski 2016-10-31 18:43:48 +01:00
parent c92d64f944
commit 13e21cd4d6
2 changed files with 4 additions and 4 deletions

View file

@ -146,12 +146,12 @@ _hsmw_main() {
if (( page_start_idx != __hsmw_page_start_idx || offset != __hsmw_prev_offset )); then
region_highlight=( )
if [[ "$__hsmw_synhl" = "yes" ]]; then
integer pre_index=0
integer pre_index=$offset
local line
for line in "${__hsmw_disp_list_newlines[@]}"; do
reply=( )
-hsmw-highlight-process "$line"
region_highlight+=( "${reply[@]//(#b)([[:digit:]]##) ([[:digit:]]##)/$(( ${match[1]} + pre_index + offset )) $(( ${match[2]} + pre_index + offset ))}" )
-hsmw-highlight-process "$line" "$pre_index"
region_highlight+=( $reply )
pre_index+=${#line}+1
done
fi

View file

@ -223,7 +223,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
# in_array_assignment true between 'a=(' and the matching ')'
# braces_stack: "R" for round, "Q" for square, "Y" for curly
# mybuf, cdpath_dir are used in sub-functions
local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$1" mybuf cdpath_dir cur_cmd
local start_pos="$2" end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$1" mybuf cdpath_dir cur_cmd
# arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator
# idx and end_idx are used in sub-functions
# for this_word and next_word look below at commented integers and at state machine description