Now it's clear that the border around editors is not ideal; we need some padding.
C4RZN6K6RH3L4BA5CPJD4WIUBTDTZA6XYM7YE6TMYVGCPAMRSURQC XARRVCCHOAL3WIFQI4SPDV4PCUG2HZJAHTATXEX6VPTGJUMNMM6QC ZU7WAHVDKXEF5IU45HFKAFBUL6R2ZXT7Q73RZXKLIW4QLKY267EQC R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC EDRTD2YKYXX7R4NCJC757JIOVGDVJBQHFC3HYDD2ONDWMPFJOJ6AC HUJUG5MOR3II73DDX4NLZ2TBLAVVFMDCG35VUX4AILWBMGZ2JQIQC IBXNUZM7R2OUGL5TDRF7OUFYY53GTZMEFQ5VJRFQF47P3VWDVDJAC NJHPKGC4MV6DDRYI4NJEE5LQBSWJBB54QV7EPSOS2ECVI7CBPOJQC BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC TXHMMX25XTR5BQLKHQXIT5TZBFW2KZ54XY3CCL36ZJYJWPKGKC6QC O6JOCPML4QCKJ33RF2SXDHMNH4KF2FA54SQBS7QOJFIWJJPTKBNAC 6FM47PAEXXD74ABGEP7AJT7PA3U3SERUAEE6PHJJMBXLKPHLKJSQC I64IPGJXWRTGHHVAYJUBUIWFR4BY6NM5P7TLTV4JOD7K4BVYDECQC DHI6IJCNSTHGED67T6H5X6Y636C7PIDGIJD32HBEKLT5WIMRS5MAC HALS7E5UGKCP3DFY456F7Z3Y6WNGIABOCV2SHT34D5ZAGNCPV5PQC RME4YP33NNUXA7HCHKUMB7UTNVGUCBDU3AZW3TDUTYL2CFZMNGOQC OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC 4KC7I3E2DIKLIP7LQRKB5WFA2Z5XZXAU46RFHNFQU5BVEJPDX6UQC 2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC 36Z442IVPXHZ7D2QI26YLN3TDDEMDRQ2GKBYQAD6NUHQZVCCY4VAC -- State transitions while colorizing a single line.-- Just for comments and strings.-- Limitation: each fragment gets a uniform color so we can only change color-- at word boundaries.Next_state = {normal={{prefix='--', target='comment'},{prefix='[[', target='block_string'}, -- only single line for now},dstring={{suffix='"', target='normal'},},sstring={{suffix="'", target='normal'},},-- comments are a sink}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,sstring=String_color,}Current_state = 'normal'function initialize_color()--? print('new line')Current_state = 'normal'endfunction select_color(frag)--? print('before', '^'..frag..'$', Current_state)switch_color_based_on_prefix(frag)--? print('using color', Current_state, Colors[Current_state])App.color(Colors[Current_state])switch_color_based_on_suffix(frag)--? print('state after suffix', Current_state)endfunction switch_color_based_on_prefix(frag)if Next_state[Current_state] == nil thenreturnendfrag = rtrim(frag)for _,edge in pairs(Next_state[Current_state]) doCurrent_state = edge.targetbreakendendendfunction switch_color_based_on_suffix(frag)if Next_state[Current_state] == nil thenreturnendfrag = rtrim(frag)for _,edge in pairs(Next_state[Current_state]) doCurrent_state = edge.targetbreakendendendif edge.suffix and ends_with(frag, edge.suffix) thenif edge.prefix and starts_with(frag, edge.prefix) thendstring=String_color,block_string=String_color,block_comment=Comment_color,comment=Comment_color,Comment_color = {r=0, g=0, b=1}block_comment={{suffix=']]', target='normal'},},},block_string={{suffix=']]', target='normal'},-- these don't mostly work well until we can change color within words-- {prefix='"', target='dstring'},-- {prefix="'", target='sstring'},{prefix='--[[', target='block_comment'}, -- only single-line for now
App.color(Line_number_color)love.graphics.print(line_index, State.left-Line_number_width*App.width('m')+10,y)if fg == nil theninitialize_color()end