keep all text cache writes inside text.lua

This commit is contained in:
Kartik K. Agaram 2022-07-17 10:06:39 -07:00
parent 4ff6de9951
commit 64eed74980
2 changed files with 8 additions and 9 deletions

View File

@ -130,10 +130,9 @@ function edit.draw(State)
State.screen_bottom1.line = line_index State.screen_bottom1.line = line_index
if line.mode == 'text' then if line.mode == 'text' then
--? print('text.draw', y, line_index) --? print('text.draw', y, line_index)
line.starty = y local startpos = 1
line.startpos = 1
if line_index == State.screen_top1.line then if line_index == State.screen_top1.line then
line.startpos = State.screen_top1.pos startpos = State.screen_top1.pos
end end
if line.data == '' then if line.data == '' then
-- button to insert new drawing -- button to insert new drawing
@ -150,7 +149,7 @@ function edit.draw(State)
end, end,
}) })
end end
y, State.screen_bottom1.pos = Text.draw(State, line_index) y, State.screen_bottom1.pos = Text.draw(State, line_index, y, startpos)
y = y + State.line_height y = y + State.line_height
--? print('=> y', y) --? print('=> y', y)
elseif line.mode == 'drawing' then elseif line.mode == 'drawing' then

View File

@ -6,16 +6,16 @@ require 'select'
require 'undo' require 'undo'
require 'text_tests' require 'text_tests'
-- return values: -- draw a line starting from startpos to screen at y between State.left and State.right
-- y coordinate drawn until in px -- return the final y, and position of start of final screen line drawn
-- position of start of final screen line drawn function Text.draw(State, line_index, y, startpos)
function Text.draw(State, line_index)
--? print('text.draw', line_index) --? print('text.draw', line_index)
App.color(Text_color) App.color(Text_color)
local line = State.lines[line_index] local line = State.lines[line_index]
line.starty = y
line.startpos = startpos
-- wrap long lines -- wrap long lines
local x = State.left local x = State.left
local y = line.starty
local pos = 1 local pos = 1
local screen_line_starting_pos = 1 local screen_line_starting_pos = 1
if line.fragments == nil then if line.fragments == nil then