first stab at equally hacky cursor down support
[?]
May 21, 2022, 3:33 AM
PR4KIAZDOBQMEUOV2G7ZEZUW3E4L5ZCHYSS7PTYWGXPSNVRAGHCACDependencies
- [2]
537TQ2QNsome more logging - [3]
HBZ2UCUFstop recomputing Cursor_x now that we're saving it - [4]
XNFTJHC4split keyboard handling between Text and Drawing - [5]
SVJZZDC3snapshot - no, that's all wrong - [6]
DLQMM265scroll past first page - [7]
5ED3YGHWplanning out cursor up/down over wrapped lines - [8]
76AIXR7Hbugfix - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
WLHI7KD3new globals: draw partial screen line up top - [*]
HYEAFRZ2split mouse_pressed events between Text and Drawing - [*]
242L3OQXbugfix: ensure Cursor_line is always on a text line
Change contents
- edit in text.lua at line 28
endif y > Screen_height thenif line.screen_line_starting_pos thenBottom_screen_line_starting_pos = line.screen_line_starting_pos[#line.screen_line_starting_pos]elseBottom_screen_line_starting_pos = 1end - replacement in text.lua at line 283[4.4509]→[4.28:50](∅→∅),[4.50]→[4.4509:4681](∅→∅),[4.4509]→[4.4509:4681](∅→∅),[4.4758]→[4.4758:4796](∅→∅),[4.4796]→[3.178:258](∅→∅),[4.156]→[4.4885:4899](∅→∅),[3.258]→[4.4885:4899](∅→∅),[4.4885]→[4.4885:4899](∅→∅)
-- next text linelocal new_cursor_line = Cursor_linewhile new_cursor_line < #Lines donew_cursor_line = new_cursor_line+1if Lines[new_cursor_line].mode == 'text' thenCursor_line = new_cursor_lineCursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)breakif Text.cursor_at_final_screen_line() then-- line is done, skip to next text lineprint('down: cursor at final screen line of its line')local new_cursor_line = Cursor_linewhile new_cursor_line < #Lines donew_cursor_line = new_cursor_line+1if Lines[new_cursor_line].mode == 'text' thenCursor_line = new_cursor_lineCursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)print(Cursor_pos)breakendendif Cursor_line > Screen_bottom_line thenScreen_top_line = Cursor_lineText.scroll_up_while_cursor_on_screen() - replacement in text.lua at line 300
endif Cursor_line > Screen_bottom_line thenScreen_top_line = Cursor_lineelse-- move down one screen line in current lineprint('cursor is NOT at final screen line of its line')local screen_line_index, screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line()new_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index+1]print('switching pos of screen line at cursor from '..tostring(screen_line_starting_pos)..' to '..tostring(new_screen_line_starting_pos))local s = string.sub(Lines[Cursor_line].data, new_screen_line_starting_pos)Cursor_pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1print('cursor pos is now '..tostring(Cursor_pos))Text.scroll_up_while_cursor_on_screen() - edit in text.lua at line 327[12.6][13.1]
function Text.cursor_at_final_screen_line()if Lines[Cursor_line].screen_line_starting_pos == nil thenreturn trueendi=#Lines[Cursor_line].screen_line_starting_poslocal spos = Lines[Cursor_line].screen_line_starting_pos[i]return spos <= Cursor_posend