about summary refs log tree commit diff stats
path: root/source_text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-07-31 08:56:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-07-31 08:56:20 -0700
commit2b52383e181e317f348b5abe734f0f484ea69121 (patch)
tree779aa2bc9c71c00418c257fb23499ae4bda378bc /source_text.lua
parent8879fd6f29c1c997a87afe33167d634f7294e397 (diff)
downloadlines.love-2b52383e181e317f348b5abe734f0f484ea69121.tar.gz
remove a duplicate print to screen
In addition to being more efficient, this will simplify the next bugfix.
Diffstat (limited to 'source_text.lua')
-rw-r--r--source_text.lua20
1 files changed, 9 insertions, 11 deletions
diff --git a/source_text.lua b/source_text.lua
index 2c33159..d02d7d7 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -39,18 +39,11 @@ function Text.draw(State, line_index, y, startpos, hide_cursor)
           })
         end
       end
-      -- render fragment
+      -- render any highlights
       if State.selection1.line then
         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
-      -- render colorized text
-      local x = State.left
-      for frag in screen_line:gmatch('%S*%s*') do
-        select_color(frag)
-        App.screen.print(frag, x,y)
-        x = x+App.width(frag)
-      end
       if not hide_cursor and line_index == State.cursor1.line then
         -- render search highlight or cursor
         if State.search_term then
@@ -59,9 +52,7 @@ function Text.draw(State, line_index, y, startpos, hide_cursor)
             local cursor_offset = Text.offset(data, State.cursor1.pos)
             if data:sub(cursor_offset, cursor_offset+#State.search_term-1) == State.search_term then
               local hi = State.cursor1.pos+utf8.len(State.search_term)
-              local lo_px = Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, hi)
-              App.color(Text_color)
-              love.graphics.print(State.search_term, State.left+lo_px,y)
+              Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, hi)
             end
           end
         elseif Focus == 'edit' then
@@ -75,6 +66,13 @@ function Text.draw(State, line_index, y, startpos, hide_cursor)
           end
         end
       end
+      -- render colorized text
+      local x = State.left
+      for frag in screen_line:gmatch('%S*%s*') do
+        select_color(frag)
+        App.screen.print(frag, x,y)
+        x = x+App.width(frag)
+      end
       y = y + State.line_height
       if y >= App.screen.height then
         break