diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-08-17 16:19:30 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-08-17 17:44:19 -0700 |
commit | 2923ef3f492cfc453607327f72e3e60fca566f5e (patch) | |
tree | 29a7061794861ca21193841428fef53d28d33595 | |
parent | 03f3034930f7ac37a23cf6353f0a662e8967f200 (diff) | |
parent | 1221fde164c47480f3c30209ad5167e4a005769a (diff) | |
download | text.love-2923ef3f492cfc453607327f72e3e60fca566f5e.tar.gz |
Merge lines.love
-rw-r--r-- | text.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/text.lua b/text.lua index 51c6d0d..f8aee6a 100644 --- a/text.lua +++ b/text.lua @@ -18,7 +18,7 @@ function Text.draw(State, line_index, y, startpos) local x = State.left local pos = 1 local screen_line_starting_pos = startpos - Text.populate_screen_line_starting_pos(State, line_index) + Text.compute_fragments(State, line_index) for _, f in ipairs(line_cache.fragments) do local frag, frag_text = f.data, f.text local frag_len = utf8.len(frag) @@ -87,9 +87,7 @@ function Text.populate_screen_line_starting_pos(State, line_index) return end -- duplicate some logic from Text.draw - if line_cache.fragments == nil then - Text.compute_fragments(State, line_index) - end + Text.compute_fragments(State, line_index) line_cache.screen_line_starting_pos = {1} local x = State.left local pos = 1 @@ -111,6 +109,9 @@ function Text.compute_fragments(State, line_index) --? print('compute_fragments', line_index, 'between', State.left, State.right) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] + if line_cache.fragments then + return + end line_cache.fragments = {} local x = State.left -- try to wrap at word boundaries |