diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-04-01 16:29:17 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-04-01 18:12:29 -0700 |
commit | 876d6298b40fc8b00bf559d4ec2d909ab1e6bc80 (patch) | |
tree | 8a949ceac0f9c6010a6de42518683ba9b75a3450 /source_select.lua | |
parent | 4ab901c92e11f47828bc7f5f16d8d2250812d53f (diff) | |
download | lines.love-876d6298b40fc8b00bf559d4ec2d909ab1e6bc80.tar.gz |
App.width can no longer take a Text
In the process I discovered the horrible fact that Text.x allocates a new Text. And it gets called (just once, thank goodness) on every single frame.
Diffstat (limited to 'source_select.lua')
-rw-r--r-- | source_select.lua | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/source_select.lua b/source_select.lua index 297a7bc..2298513 100644 --- a/source_select.lua +++ b/source_select.lua @@ -60,15 +60,12 @@ function Text.draw_highlight(State, line, x,y, pos, lo,hi) lo_px = 0 else local before = line.data:sub(pos_offset, lo_offset-1) - local before_text = App.newText(love.graphics.getFont(), before) - lo_px = App.width(before_text) + lo_px = App.width(before) end --? print(lo,pos,hi, '--', lo_offset,pos_offset,hi_offset, '--', lo_px) local s = line.data:sub(lo_offset, hi_offset-1) - local text = App.newText(love.graphics.getFont(), s) - local text_width = App.width(text) App.color(Highlight_color) - love.graphics.rectangle('fill', x+lo_px,y, text_width,State.line_height) + love.graphics.rectangle('fill', x+lo_px,y, App.width(s),State.line_height) App.color(Text_color) return lo_px end |