source editing: highlight [[ ]] comments/strings
In the process I fixed suffix detection for patterns with more than 1 character.
This commit is contained in:
parent
a54e59446d
commit
d5c34ba043
18
colorize.lua
18
colorize.lua
|
@ -4,9 +4,11 @@
|
||||||
-- at word boundaries.
|
-- at word boundaries.
|
||||||
Next_state = {
|
Next_state = {
|
||||||
normal={
|
normal={
|
||||||
|
{prefix='--[[', target='block_comment'}, -- only single-line for now
|
||||||
{prefix='--', target='comment'},
|
{prefix='--', target='comment'},
|
||||||
{prefix='"', target='dstring'},
|
{prefix='"', target='dstring'},
|
||||||
{prefix="'", target='sstring'},
|
{prefix="'", target='sstring'},
|
||||||
|
{prefix='[[', target='block_string'}, -- only single line for now
|
||||||
},
|
},
|
||||||
dstring={
|
dstring={
|
||||||
{suffix='"', target='normal'},
|
{suffix='"', target='normal'},
|
||||||
|
@ -14,18 +16,26 @@ Next_state = {
|
||||||
sstring={
|
sstring={
|
||||||
{suffix="'", target='normal'},
|
{suffix="'", target='normal'},
|
||||||
},
|
},
|
||||||
|
block_string={
|
||||||
|
{suffix=']]', target='normal'},
|
||||||
|
},
|
||||||
|
block_comment={
|
||||||
|
{suffix=']]', target='normal'},
|
||||||
|
},
|
||||||
-- comments are a sink
|
-- comments are a sink
|
||||||
}
|
}
|
||||||
|
|
||||||
Comments_color = {r=0, g=0, b=1}
|
Comment_color = {r=0, g=0, b=1}
|
||||||
String_color = {r=0, g=0.5, b=0.5}
|
String_color = {r=0, g=0.5, b=0.5}
|
||||||
Divider_color = {r=0.7, g=0.7, b=0.7}
|
Divider_color = {r=0.7, g=0.7, b=0.7}
|
||||||
|
|
||||||
Colors = {
|
Colors = {
|
||||||
normal=Text_color,
|
normal=Text_color,
|
||||||
comment=Comments_color,
|
comment=Comment_color,
|
||||||
sstring=String_color,
|
sstring=String_color,
|
||||||
dstring=String_color
|
dstring=String_color,
|
||||||
|
block_string=String_color,
|
||||||
|
block_comment=Comment_color,
|
||||||
}
|
}
|
||||||
|
|
||||||
Current_state = 'normal'
|
Current_state = 'normal'
|
||||||
|
@ -63,7 +73,7 @@ function switch_color_based_on_suffix(frag)
|
||||||
end
|
end
|
||||||
frag = rtrim(frag)
|
frag = rtrim(frag)
|
||||||
for _,edge in pairs(Next_state[Current_state]) do
|
for _,edge in pairs(Next_state[Current_state]) do
|
||||||
if edge.suffix and rfind(frag, edge.suffix, nil, --[[plain]] true) == #frag then
|
if edge.suffix and rfind(frag, edge.suffix, nil, --[[plain]] true) == #frag - #edge.suffix + 1 then
|
||||||
Current_state = edge.target
|
Current_state = edge.target
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue