about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-03 14:37:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-03 14:37:32 -0700
commite2696fcc72d134e70c0636ff2c7a0c79631c3166 (patch)
tree9e656312ce34f84a80f2d57bfa48ef6071695059 /text.lua
parent1bdb93157557236cab566dce5b4613672cc5b626 (diff)
downloadtext.love-e2696fcc72d134e70c0636ff2c7a0c79631c3166.tar.gz
more precise search highlighting
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua8
1 files changed, 2 insertions, 6 deletions
diff --git a/text.lua b/text.lua
index 1398896..30f000f 100644
--- a/text.lua
+++ b/text.lua
@@ -62,13 +62,9 @@ function Text.draw(line, line_width, line_index)
       if pos <= Cursor1.pos and pos + frag_len > Cursor1.pos then
         if Search_term then
           if Lines[Cursor1.line].data:sub(Cursor1.pos, Cursor1.pos+utf8.len(Search_term)-1) == Search_term then
-            if Search_text == nil then
-              Search_text = App.newText(love.graphics.getFont(), Search_term)
-            end
-            love.graphics.setColor(0.7,1,1)
-            love.graphics.rectangle('fill', x,y, App.width(Search_text),Line_height)
+            local lo_px = Text.draw_highlight(line, x,y, pos, Cursor1.pos, Cursor1.pos+utf8.len(Search_term))
             love.graphics.setColor(0,0,0)
-            love.graphics.print(Search_term, x,y)
+            love.graphics.print(Search_term, x+lo_px,y)
           end
         else
           Text.draw_cursor(x+Text.x(frag, Cursor1.pos-pos+1), y)