Manual test used here:
abc
{"p1":{"y":72,"x":82},"mode":"line","p2":{"y":29,"x":169}}
def
{"p1":{"y":36,"x":56},"mode":"line","p2":{"y":59,"x":163}}
ghi jkl
Hitting page-down moves the cursor from abc to ghi. The 'ghi' line should be fully visible on screen.
242L3OQXTU2TCAINRJXQEEDSXQXM7Y7USUPBK37ZNM3A7V5TUDSAC
A2TQYJ6JZJF2T47C26H2IRSR6O67BP6VHY5PV7GTFG4IZNQQBJVQC
DLQMM2656JHXX3ONOEM6UIOXKFJFT5QT7RHWK7YS2W77PVZWHRSAC
HYEAFRZ2UEKDYTAE2GDQLHEJBPQASP2NDLMXB7F6MTVK2BKOXKEAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC
FS2ITYYHBLFT66YUC3ENPFYI2HOYHOVEPQIN7NQR6KF5MEK4NKZAC
function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
while Cursor_line <= #Lines do
if Lines[Cursor_line].mode == 'text' then
break
end
Cursor_line = Cursor_line + 1
end
-- hack: insert a text line at bottom of file if necessary
if Cursor_line > #Lines then
assert(Cursor_line == #Lines+1)
table.insert(Lines, {mode='text', data=''})
end
if Cursor_line > Screen_bottom_line then
Screen_top_line = Cursor_line
Text.scroll_up_while_cursor_on_screen()
end
end
function Text.scroll_up_while_cursor_on_screen()
local y = Screen_height - 15*Zoom -- for Cursor_line
while true do
if Screen_top_line == 1 then break end
y = y - 15*Zoom
if Lines[Screen_top_line].mode == 'drawing' then
y = y - Drawing.pixels(Lines[Screen_top_line].h)
end
if y < 15*Zoom then
break
end
Screen_top_line = Screen_top_line - 1
end
end
* The text cursor will always stay on the screen. This can have some strange
implications:
* A long series of drawings will get silently skipped when you hit
page-down, until a line of text can be showed on screen.
* If there's no line of text at the bottom of the file, one will be
created.
So far this app isn't really designed for all-drawing files. I'm really just
targeting mostly-text files with a few drawings mixed in.