Merge pull request #123 from Shura0/master
Highlighted dollar variable ver. 2
This commit is contained in:
commit
08b80022ca
@ -184,18 +184,36 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
_zsh_highlight_main_highlighter_highlight_string()
|
_zsh_highlight_main_highlighter_highlight_string()
|
||||||
{
|
{
|
||||||
setopt localoptions noksharrays
|
setopt localoptions noksharrays
|
||||||
local i j k style
|
local i j k style varflag
|
||||||
# Starting quote is at 1, so start parsing at offset 2 in the string.
|
# Starting quote is at 1, so start parsing at offset 2 in the string.
|
||||||
for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do
|
for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do
|
||||||
(( j = i + start_pos - 1 ))
|
(( j = i + start_pos - 1 ))
|
||||||
(( k = j + 1 ))
|
(( k = j + 1 ))
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
'$') style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument];;
|
'$' ) style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]
|
||||||
|
(( varflag = 1))
|
||||||
|
;;
|
||||||
"\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]
|
"\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]
|
||||||
|
for (( c = i + 1 ; c < end_pos - start_pos ; c += 1 )); do
|
||||||
|
[[ "$arg[$c]" != ([0-9,xX,a-f,A-F]) ]] && break
|
||||||
|
done
|
||||||
|
AA=$arg[$i+1,$c-1]
|
||||||
|
# Matching for HEX and OCT values like \0xA6, \xA6 or \012
|
||||||
|
if [[ "$AA" =~ "^(0*(x|X)[0-9,a-f,A-F]{1,2})" || "$AA" =~ "^(0[0-7]{1,3})" ]];then
|
||||||
|
(( k += $#MATCH ))
|
||||||
|
(( i += $#MATCH ))
|
||||||
|
else
|
||||||
(( k += 1 )) # Color following char too.
|
(( k += 1 )) # Color following char too.
|
||||||
(( i += 1 )) # Skip parsing the escaped char.
|
(( i += 1 )) # Skip parsing the escaped char.
|
||||||
|
fi
|
||||||
|
(( varflag = 0 )) # End of variable
|
||||||
;;
|
;;
|
||||||
*) continue;;
|
([^a-zA-Z0-9_]))
|
||||||
|
(( varflag = 0 )) # End of variable
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
*) [[ $varflag -eq 0 ]] && continue ;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
region_highlight+=("$j $k $style")
|
region_highlight+=("$j $k $style")
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user