mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-12-04 21:56:45 +01:00
Autoload highlighters
This commit is contained in:
parent
6d5372a937
commit
b62aeb6168
22 changed files with 2287 additions and 1907 deletions
|
|
@ -30,33 +30,3 @@
|
|||
|
||||
# List of keyword and color pairs.
|
||||
typeset -gA ZSH_HIGHLIGHT_REGEXP
|
||||
|
||||
# Whether the pattern highlighter should be called or not.
|
||||
_zsh_highlight_highlighter_regexp_predicate()
|
||||
{
|
||||
_zsh_highlight_buffer_modified
|
||||
}
|
||||
|
||||
# Pattern syntax highlighting function.
|
||||
_zsh_highlight_highlighter_regexp_paint()
|
||||
{
|
||||
setopt localoptions extendedglob
|
||||
local pattern
|
||||
for pattern in ${(k)ZSH_HIGHLIGHT_REGEXP}; do
|
||||
_zsh_highlight_regexp_highlighter_loop "$BUFFER" "$pattern"
|
||||
done
|
||||
}
|
||||
|
||||
_zsh_highlight_regexp_highlighter_loop()
|
||||
{
|
||||
local buf="$1" pat="$2"
|
||||
integer OFFSET=0
|
||||
local MATCH; integer MBEGIN MEND
|
||||
local -a match mbegin mend
|
||||
while true; do
|
||||
[[ "$buf" =~ "$pat" ]] || return;
|
||||
region_highlight+=("$((MBEGIN - 1 + OFFSET)) $((MEND + OFFSET)) $ZSH_HIGHLIGHT_REGEXP[$pat], memo=zsh-syntax-highlighting")
|
||||
buf="$buf[$(($MEND+1)),-1]"
|
||||
OFFSET=$((MEND+OFFSET));
|
||||
done
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue