From 038f06a342acfbd4c8e8aa1519b49361d8dc1bbc Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 17 Jul 2022 07:58:51 -0700 Subject: drop some redundant args from Text.draw --- edit.lua | 6 +++--- 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 -- cgit 1.4.1-2-gfad0