diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-04-08 22:21:55 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-04-08 22:28:19 -0700 |
commit | 6a7c5824c395b9bf48592f758f44186055f920b5 (patch) | |
tree | 4582c8f1b395523b335be271be2058900fd9e783 /source_text.lua | |
parent | c969fcdd8574b42fd48e0695ea556a643aedb7c1 (diff) | |
download | lines.love-6a7c5824c395b9bf48592f758f44186055f920b5.tar.gz |
bugfix: syntax highlighting in source editor
I missed that comments only get highlighted at start of line. This seems a bit hacky. But it continues to trade off CPU for reduced memory footprint.
Diffstat (limited to 'source_text.lua')
-rw-r--r-- | source_text.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source_text.lua b/source_text.lua index d0b4fcc..cf3d00f 100644 --- a/source_text.lua +++ b/source_text.lua @@ -44,8 +44,13 @@ function Text.draw(State, line_index, y, startpos, hide_cursor) local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len) Text.draw_highlight(State, line, State.left,y, pos, lo,hi) end - select_color(f) - App.screen.print(f, State.left,y) + -- render colorized text + local x = State.left + for frag in f:gmatch('%S*%s*') do + select_color(frag) + App.screen.print(frag, x,y) + x = x+App.width(frag) + end -- render cursor if necessary if not hide_cursor and line_index == State.cursor1.line then if pos <= State.cursor1.pos and pos + frag_len >= State.cursor1.pos then |