diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-04-01 14:48:59 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-04-01 16:12:55 -0700 |
commit | 4ab901c92e11f47828bc7f5f16d8d2250812d53f (patch) | |
tree | 288dcf758b377c9b8586a9fc4bd7706d3a91e1f4 /source_text.lua | |
parent | fd2e5acb464c439325455acb63683d4fa316497c (diff) | |
download | lines.love-4ab901c92e11f47828bc7f5f16d8d2250812d53f.tar.gz |
get rid of to_text
I've been misunderstanding what Text objects are. They can render a lot of text with a given line height, word wrap, colors in various places. And I've been creating one for every word :facepalm: Unwinding this will take some time. This is just a first baby step for ad hoc text objects. Turns out I don't need to convert to Text to get something's rendered width, just the Font can do that. Thanks to the LÖVE Discord for educating me: https://discord.com/channels/329400828920070144/330089431379869708/1091535487333826580
Diffstat (limited to 'source_text.lua')
-rw-r--r-- | source_text.lua | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/source_text.lua b/source_text.lua index 4d13748..2aa27bc 100644 --- a/source_text.lua +++ b/source_text.lua @@ -45,8 +45,7 @@ function Text.draw(State, line_index, y, startpos, hide_cursor) if starts_with(trimmed_word, '[[') and ends_with(trimmed_word, ']]') then local filename = trimmed_word:gsub('^..(.*)..$', '%1') if source.link_exists(State, filename) then - local filename_text = App.newText(love.graphics.getFont(), filename) - button(State, 'link', {x=x+App.width(to_text('[[')), y=y, w=App.width(filename_text), h=State.line_height, color={1,1,1}, + button(State, 'link', {x=x+App.width('[['), y=y, w=App.width(filename), h=State.line_height, color={1,1,1}, icon = icon.hyperlink_decoration, onpress1 = function() source.switch_to_file(filename) |