keep all text cache writes inside text.lua
This commit is contained in:
parent
4ff6de9951
commit
64eed74980
7
edit.lua
7
edit.lua
|
@ -130,10 +130,9 @@ function edit.draw(State)
|
|||
State.screen_bottom1.line = line_index
|
||||
if line.mode == 'text' then
|
||||
--? print('text.draw', y, line_index)
|
||||
line.starty = y
|
||||
line.startpos = 1
|
||||
local startpos = 1
|
||||
if line_index == State.screen_top1.line then
|
||||
line.startpos = State.screen_top1.pos
|
||||
startpos = State.screen_top1.pos
|
||||
end
|
||||
if line.data == '' then
|
||||
-- button to insert new drawing
|
||||
|
@ -150,7 +149,7 @@ function edit.draw(State)
|
|||
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
|
||||
--? print('=> y', y)
|
||||
elseif line.mode == 'drawing' then
|
||||
|
|
10
text.lua
10
text.lua
|
@ -6,16 +6,16 @@ require 'select'
|
|||
require 'undo'
|
||||
require 'text_tests'
|
||||
|
||||
-- return values:
|
||||
-- y coordinate drawn until in px
|
||||
-- position of start of final screen line drawn
|
||||
function Text.draw(State, line_index)
|
||||
-- draw a line starting from startpos to screen at y between State.left and State.right
|
||||
-- return the final y, and position of start of final screen line drawn
|
||||
function Text.draw(State, line_index, y, startpos)
|
||||
--? print('text.draw', line_index)
|
||||
App.color(Text_color)
|
||||
local line = State.lines[line_index]
|
||||
line.starty = y
|
||||
line.startpos = startpos
|
||||
-- wrap long lines
|
||||
local x = State.left
|
||||
local y = line.starty
|
||||
local pos = 1
|
||||
local screen_line_starting_pos = 1
|
||||
if line.fragments == nil then
|
||||
|
|
Loading…
Reference in New Issue