Looks pretty clean.
MGT5FTJ35MGYCQO3TZVK3RYUIN5YX475R4XG7RO42SYLYF4AIKFAC 5ED3YGHW6H7XIXPMHRI5ZJ3VA5UCANZF4AJRSE6V7BLUF67Q6NAAC WLHI7KD3LJTQH6V7RLVJWGZUR4YQK6LN4OIUMIN45BGMMQGN6RNQC 76AIXR7HAUL74GYPPFH3N5N4VJWZL67WM4XTKWGSA6ESLIJZPB6QC H2DPLWMVRFYTO2CQTG54FMT2LF3B6UKLXH32CUA22DNQJVP5XBNQC BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC DLQMM2656JHXX3ONOEM6UIOXKFJFT5QT7RHWK7YS2W77PVZWHRSAC FEEGTRGQR5PETZZQLXVDMILD3Z3CMXP7IDR3DFVXBCGE7GMHB7GQC BJ5X5O4ACBBJ56LRBBSTCW6IBQP4HAEOOOPNH3SKTA4F66YTOIDAC -- previous text linelocal new_cursor_line = Cursor_linewhile new_cursor_line > 1 donew_cursor_line = new_cursor_line-1if Lines[new_cursor_line].mode == 'text' thenlocal old_x = Text.cursor_x(Lines[new_cursor_line].data, Cursor_pos)Cursor_line = new_cursor_lineCursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, old_x)break
if Top_screen_line_starting_pos == 1 then-- top line is done; skip to previous text linelocal new_cursor_line = Cursor_linewhile new_cursor_line > 1 donew_cursor_line = new_cursor_line-1if Lines[new_cursor_line].mode == 'text' thenlocal old_x = Text.cursor_x(Lines[new_cursor_line].data, Cursor_pos)Cursor_line = new_cursor_lineCursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, old_x)breakendendif Cursor_line < Screen_top_line thenScreen_top_line = Cursor_line
endif Cursor_line < Screen_top_line thenScreen_top_line = Cursor_line
else-- scroll up just one screen line in current linelocal screen_line_index = table.find(Lines[Cursor_line].screen_line_starting_pos, Top_screen_line_starting_pos)assert(screen_line_index > 1)Top_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index-1]local s = string.sub(Lines[Cursor_line].data, Top_screen_line_starting_pos)Cursor_pos = Text.nearest_cursor_pos(s, Cursor_x)
scrolling:given moby dick, a file containing all text:page up moves top line on screen to bottompage down moves bottom line on screen to topcursor remains on screencursor remains on text line'up' arrow with cursor at top of screen scrolls up one line (drawings still fully in or out)if top line wrapped before, it scrolls up by only one screen line'down' arrow with cursor at bottom of screen scrolls down one line (drawings still fully in or out)if top line wrapped before, it scrolls down by only one screen line