first stab at supporting wrapping in cursor up

[?]
May 20, 2022, 3:55 PM
MGT5FTJ35MGYCQO3TZVK3RYUIN5YX475R4XG7RO42SYLYF4AIKFAC

Dependencies

  • [2] 5ED3YGHW planning out cursor up/down over wrapped lines
  • [3] WLHI7KD3 new globals: draw partial screen line up top
  • [4] 76AIXR7H bugfix
  • [5] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [6] XNFTJHC4 split keyboard handling between Text and Drawing
  • [7] 5L7K4GBD clicking to the right of a wrapped line
  • [8] DLQMM265 scroll past first page
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [*] FEEGTRGQ bugfix: duplicate character on enter

Change contents

  • replacement in text.lua at line 22
    [5.2151][3.1:83]()
    if line_index > Screen_top_line or pos >= Top_screen_line_starting_pos then
    [5.2151]
    [3.83]
    if line_index > Screen_top_line or pos > Top_screen_line_starting_pos then
  • replacement in text.lua at line 222
    [5.4030][2.1:27](),[2.27][5.4030:4312](),[5.4030][5.4030:4312](),[5.4312][4.1:78](),[4.78][5.4401:4415](),[5.4401][5.4401:4415]()
    -- previous text line
    local new_cursor_line = Cursor_line
    while new_cursor_line > 1 do
    new_cursor_line = new_cursor_line-1
    if Lines[new_cursor_line].mode == 'text' then
    local old_x = Text.cursor_x(Lines[new_cursor_line].data, Cursor_pos)
    Cursor_line = new_cursor_line
    Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, old_x)
    break
    [5.4030]
    [5.4415]
    if Top_screen_line_starting_pos == 1 then
    -- top line is done; skip to previous text line
    local new_cursor_line = Cursor_line
    while new_cursor_line > 1 do
    new_cursor_line = new_cursor_line-1
    if Lines[new_cursor_line].mode == 'text' then
    local old_x = Text.cursor_x(Lines[new_cursor_line].data, Cursor_pos)
    Cursor_line = new_cursor_line
    Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, old_x)
    break
    end
    end
    if Cursor_line < Screen_top_line then
    Screen_top_line = Cursor_line
  • replacement in text.lua at line 237
    [5.4425][5.4425:4433](),[5.4433][5.190:268]()
    end
    if Cursor_line < Screen_top_line then
    Screen_top_line = Cursor_line
    [5.4425]
    [5.268]
    else
    -- scroll up just one screen line in current line
    local 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)
  • edit in manual_tests at line 17
    [12.67]
    scrolling:
    given moby dick, a file containing all text:
    page up moves top line on screen to bottom
    page down moves bottom line on screen to top
    cursor remains on screen
    cursor 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