diff options
-rw-r--r-- | edit.lua | 7 | ||||
-rw-r--r-- | text.lua | 10 |
2 files changed, 8 insertions, 9 deletions
diff --git a/edit.lua b/edit.lua index 17bbc9e..c0b2f8e 100644 --- a/edit.lua +++ b/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 diff --git a/text.lua b/text.lua index 3af0a13..8bd0fac 100644 --- a/text.lua +++ b/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 |