mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-11-25 12:50:25 +00:00
Syntax-highlight history, slight cleanup
This commit is contained in:
parent
ef2fd4cdb5
commit
df91d236b5
1 changed files with 8 additions and 9 deletions
|
@ -96,34 +96,33 @@ _hsmw_main() {
|
|||
# also preceeded by two spaces
|
||||
disp_list=( "${(@)disp_list/(#m)*/ ${MATCH[1,COLUMNS-8]}}" )
|
||||
|
||||
local nl=$'\n'
|
||||
local entry="${disp_list[on_page_idx]}"
|
||||
entry[1]='>'
|
||||
disp_list[on_page_idx]="$entry"
|
||||
|
||||
#
|
||||
# Detect where "> .." entry starts
|
||||
# Detect where "> .." entry starts, add the ">" mark
|
||||
#
|
||||
|
||||
local txt_before="${(F)${(@)disp_list[1,on_page_idx-1]}}"
|
||||
local for_syntax_text="${(F)disp_list}"
|
||||
local entry="${disp_list[on_page_idx]}"
|
||||
entry[1]='>'
|
||||
disp_list[on_page_idx]="$entry"
|
||||
local text="${(F)disp_list}"
|
||||
|
||||
#
|
||||
# Colorify
|
||||
#
|
||||
|
||||
local preamble=$'\n'"Searching for: $BUFFER"$'\n'"Element #$__hsmw_hcw_index of $max_index"$'\n'
|
||||
local text="${(F)disp_list}"
|
||||
integer offset=${#preamble}+${#BUFFER}
|
||||
|
||||
POSTDISPLAY="$preamble$text"
|
||||
|
||||
region_highlight=( )
|
||||
-hsmw-highlight-init
|
||||
-hsmw-highlight-process "$text"
|
||||
-hsmw-highlight-process "$for_syntax_text"
|
||||
region_highlight=( "${region_highlight[@]//(#b)([[:digit:]]##)/$(( ${match[1]} + offset ))}" )
|
||||
|
||||
region_highlight+=( "$(( offset + ${#txt_before} )) $(( offset + ${#txt_before} + ${#entry} + 1 )) underline" )
|
||||
if [ -n "$colsearch_pattern" ]; then
|
||||
local nl=$'\n'
|
||||
# Following line is taken from Zaw (GH zsh-users/zaw) – license is named "Zaw", it is in LICENSE file
|
||||
region_highlight+=( "${(f)${(S)text//*(#bi)(${~colsearch_pattern})/$(( offset + mbegin[1] - 1 )) $(( offset + mend[1] )) ${__hsmw_hl_color}${nl}}%$nl*}" )
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue