diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-11-11 18:06:55 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-11-11 18:06:55 -0800 |
commit | ec4cda13aa8a3f1dd9c544b87de0f7a4f0a57499 (patch) | |
tree | c7ac3d033aec12ad72272c23695e9e83078135b8 | |
parent | 4522b0ac66b77b77e89b476be3ad7cfbe3f1ce19 (diff) | |
parent | d5c34ba043d6fb470b2b358881a71aec079dd823 (diff) | |
download | view.love-ec4cda13aa8a3f1dd9c544b87de0f7a4f0a57499.tar.gz |
Merge lines.love
-rw-r--r-- | colorize.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/colorize.lua b/colorize.lua index c0d2117..6c2057c 100644 --- a/colorize.lua +++ b/colorize.lua @@ -4,9 +4,11 @@ -- at word boundaries. Next_state = { normal={ + {prefix='--[[', target='block_comment'}, -- only single-line for now {prefix='--', target='comment'}, {prefix='"', target='dstring'}, {prefix="'", target='sstring'}, + {prefix='[[', target='block_string'}, -- only single line for now }, dstring={ {suffix='"', target='normal'}, @@ -14,18 +16,26 @@ Next_state = { sstring={ {suffix="'", target='normal'}, }, + block_string={ + {suffix=']]', target='normal'}, + }, + block_comment={ + {suffix=']]', target='normal'}, + }, -- 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} Divider_color = {r=0.7, g=0.7, b=0.7} Colors = { normal=Text_color, - comment=Comments_color, + comment=Comment_color, sstring=String_color, - dstring=String_color + dstring=String_color, + block_string=String_color, + block_comment=Comment_color, } Current_state = 'normal' @@ -63,7 +73,7 @@ function switch_color_based_on_suffix(frag) end frag = rtrim(frag) 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 break end |