diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-06-03 14:37:32 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-06-03 14:37:32 -0700 |
commit | e2696fcc72d134e70c0636ff2c7a0c79631c3166 (patch) | |
tree | 9e656312ce34f84a80f2d57bfa48ef6071695059 /select.lua | |
parent | 1bdb93157557236cab566dce5b4613672cc5b626 (diff) | |
download | text.love-e2696fcc72d134e70c0636ff2c7a0c79631c3166.tar.gz |
more precise search highlighting
Diffstat (limited to 'select.lua')
-rw-r--r-- | select.lua | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/select.lua b/select.lua index 499c309..3d8999e 100644 --- a/select.lua +++ b/select.lua @@ -51,6 +51,8 @@ function Text.clip_selection(line_index, apos, bpos) end -- draw highlight for line corresponding to (lo,hi) given an approximate x,y and pos on the same screen line +-- Creates text objects every time, so use this sparingly. +-- Returns some intermediate computation useful elsewhere. function Text.draw_highlight(line, x,y, pos, lo,hi) if lo then local lo_offset = utf8.offset(line.data, lo) @@ -71,6 +73,7 @@ function Text.draw_highlight(line, x,y, pos, lo,hi) love.graphics.setColor(0.7,0.7,0.9) love.graphics.rectangle('fill', x+lo_px,y, text_width,Line_height) love.graphics.setColor(0,0,0) + return lo_px end end |