Zstyle to configure whether to check paths for existence

parse.zsh -oo, after changes:

Running time: 1.5653990000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1557,37     4,45   99,99%   1199,04     3,43   76,98%  -hsmw-highlight-process
 2) 2800         294,91     0,11   18,93%    294,91     0,11   18,93%  -hsmw-highlight-string
 3) 1750          40,81     0,02    2,62%     40,81     0,02    2,62%  -hsmw-highlight-check-path
 4) 1400          22,61     0,02    1,45%     22,61     0,02    1,45%  -hsmw-highlight-main-type
 5)    1           0,12     0,12    0,01%      0,12     0,12    0,01%  -hsmw-highlight-fill-option-variables
 6)    1           0,02     0,02    0,00%      0,02     0,02    0,00%  -hsmw-highlight-init
This commit is contained in:
Sebastian Gniazdowski 2016-11-05 11:36:03 +01:00
parent 175d0ae6d4
commit e6bc8ff0c0
3 changed files with 8 additions and 6 deletions

View file

@ -109,10 +109,11 @@ place you're doing your other `zgen load` calls in.
## Zstyles
```zsh
zstyle ":history-search-multi-word" page-size "8" # Number of entries to show, default is LINES/3
zstyle ":history-search-multi-word" highlight-color "fg=yellow,bold" # Color in which to highlight matched, searched text
zstyle ":plugin:history-search-multi-word" synhl "yes" # Whether to perform syntax highlighting
zstyle ":plugin:history-search-multi-word" active "underline" # Effect on active history entry. Try: standout, bold, bg=blue
zstyle ":history-search-multi-word" page-size "8" # Number of entries to show (default is $LINES/3)
zstyle ":history-search-multi-word" highlight-color "fg=yellow,bold" # Color in which to highlight matched, searched text (default bg=17 on 256-color terminals)
zstyle ":plugin:history-search-multi-word" synhl "yes" # Whether to perform syntax highlighting (default true)
zstyle ":plugin:history-search-multi-word" active "underline" # Effect on active history entry. Try: standout, bold, bg=blue (default underline)
zstyle ":plugin:history-search-multi-word" check-paths "yes" # Whether to check paths for existence and mark with magenta (default true)
```
## Syntax highlighting

View file

@ -29,7 +29,7 @@ zmodload zsh/termcap 2>/dev/null
typeset -g __hsmw_hcw_index
typeset -g __hsmw_hcw_widget_name __hsmw_hcw_restart __hsmw_hcw_call_count
typeset -g __hsmw_page_size __hsmw_hl_color __hsmw_synhl __hsmw_active
typeset -g __hsmw_page_size __hsmw_hl_color __hsmw_synhl __hsmw_active __hsmw_no_check_paths
typeset -ga __hsmw_disp_list __hsmw_disp_list_newlines __hsmw_region_highlight_data
typeset -gi __hsmw_page_start_idx __hsmw_prev_offset __hsmw_recedit_trap_executed
typeset -gaU __hsmw_hcw_found
@ -48,6 +48,7 @@ _hsmw_main() {
zstyle -s ':history-search-multi-word' highlight-color __hsmw_hl_color || __hsmw_hl_color="fg=yellow,bold"
zstyle -s ":plugin:history-search-multi-word" synhl __hsmw_synhl || __hsmw_synhl="yes"
zstyle -s ":plugin:history-search-multi-word" active __hsmw_active || __hsmw_active="underline"
zstyle -T ":plugin:history-search-multi-word" check-paths && __hsmw_no_check_paths=0 || __hsmw_no_check_paths=1
[[ "$__hsmw_synhl" != "1" && "$__hsmw_synhl" != "yes" && "$__hsmw_synhl" != "true" ]] && __hsmw_synhl="no" || __hsmw_synhl="yes"
-hsmw-highlight-init
fi

View file

@ -546,7 +546,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
elif (( in_redirection == 2 )); then
style=redirection
else
if -hsmw-highlight-check-path; then
if (( __hsmw_no_check_paths == 0 )) && -hsmw-highlight-check-path; then
# ADD
reply+=("$start_pos $end_pos ${HSMW_HIGHLIGHT_STYLES[path]}")
already_added=1