diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-07-17 07:58:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-07-17 08:00:56 -0700 |
commit | 038f06a342acfbd4c8e8aa1519b49361d8dc1bbc (patch) | |
tree | 7a4897b096773a5b02f6eff93a714a7268330b8c | |
parent | 0ac44f0756fe507ade41296b6e0cf3df9eab4863 (diff) | |
download | text.love-038f06a342acfbd4c8e8aa1519b49361d8dc1bbc.tar.gz |
drop some redundant args from Text.draw
-rw-r--r-- | edit.lua | 6 | ||||
-rw-r--r-- | text.lua | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/edit.lua b/edit.lua index abb6260..772d638 100644 --- a/edit.lua +++ b/edit.lua @@ -38,9 +38,9 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c -- a text is a table with: -- mode = 'text', -- string data, - -- startpos, the index of data the line starts rendering from (if currently on screen), can only be >1 for topmost line on screen - -- starty, the y coord in pixels -- some cached data that's blown away and recomputed when data changes: + -- startpos, the index of data the line starts rendering from (if currently on screen), can only be >1 for topmost line on screen + -- starty, the y coord in pixels -- fragments: snippets of rendered love.graphics.Text, guaranteed to not wrap -- screen_line_starting_pos: optional array of grapheme indices if it wraps over more than one screen line -- a drawing is a table with: @@ -163,7 +163,7 @@ function edit.draw(State) line.startpos = State.screen_top1.pos end --? print('text.draw', y, line_index) - y, State.screen_bottom1.pos = Text.draw(State, line, line_index, line.starty) + y, State.screen_bottom1.pos = Text.draw(State, line_index) y = y + State.line_height --? print('=> y', y) end diff --git a/text.lua b/text.lua index d4bfbc2..fa7b0ea 100644 --- a/text.lua +++ b/text.lua @@ -9,12 +9,13 @@ require 'text_tests' -- return values: -- y coordinate drawn until in px -- position of start of final screen line drawn -function Text.draw(State, line, line_index, top) +function Text.draw(State, line_index) --? print('text.draw', line_index) App.color(Text_color) + local line = State.lines[line_index] -- wrap long lines local x = State.left - local y = top + local y = line.starty local pos = 1 local screen_line_starting_pos = 1 if line.fragments == nil then |