first stab at equally hacky cursor down support

[?]
May 21, 2022, 3:33 AM
PR4KIAZDOBQMEUOV2G7ZEZUW3E4L5ZCHYSS7PTYWGXPSNVRAGHCAC

Dependencies

  • [2] 537TQ2QN some more logging
  • [3] HBZ2UCUF stop recomputing Cursor_x now that we're saving it
  • [4] XNFTJHC4 split keyboard handling between Text and Drawing
  • [5] SVJZZDC3 snapshot - no, that's all wrong
  • [6] DLQMM265 scroll past first page
  • [7] 5ED3YGHW planning out cursor up/down over wrapped lines
  • [8] 76AIXR7H bugfix
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] WLHI7KD3 new globals: draw partial screen line up top
  • [*] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [*] 242L3OQX bugfix: ensure Cursor_line is always on a text line

Change contents

  • edit in text.lua at line 28
    [2.110]
    [11.119]
    end
    if y > Screen_height then
    if line.screen_line_starting_pos then
    Bottom_screen_line_starting_pos = line.screen_line_starting_pos[#line.screen_line_starting_pos]
    else
    Bottom_screen_line_starting_pos = 1
    end
  • 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 line
    local new_cursor_line = Cursor_line
    while new_cursor_line < #Lines do
    new_cursor_line = new_cursor_line+1
    if Lines[new_cursor_line].mode == 'text' then
    Cursor_line = new_cursor_line
    Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)
    break
    [4.4509]
    [4.4899]
    if Text.cursor_at_final_screen_line() then
    -- line is done, skip to next text line
    print('down: cursor at final screen line of its line')
    local new_cursor_line = Cursor_line
    while new_cursor_line < #Lines do
    new_cursor_line = new_cursor_line+1
    if Lines[new_cursor_line].mode == 'text' then
    Cursor_line = new_cursor_line
    Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)
    print(Cursor_pos)
    break
    end
    end
    if Cursor_line > Screen_bottom_line then
    Screen_top_line = Cursor_line
    Text.scroll_up_while_cursor_on_screen()
  • replacement in text.lua at line 300
    [4.4909][4.277:366]()
    end
    if Cursor_line > Screen_bottom_line then
    Screen_top_line = Cursor_line
    [4.4909]
    [4.1313]
    else
    -- move down one screen line in current line
    print('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) - 1
    print('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 then
    return true
    end
    i=#Lines[Cursor_line].screen_line_starting_pos
    local spos = Lines[Cursor_line].screen_line_starting_pos[i]
    return spos <= Cursor_pos
    end