bugfix: manage screen_top and cursor when resizing

[?]
Jul 1, 2022, 5:30 PM
WOXIYUTL4NU7ACHQYXEXJDSXCRDLQ2X457KO6C7GEXFQZ43F3L7QC

Dependencies

  • [2] PX7DDEMO autosave slightly less aggressively
  • [3] DBNRULIJ record one more case I can't automatically detect
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] HOSPP2AN crisp font rendering
  • [*] OTIBCAUJ love2d scaffold
  • [*] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [*] K464QQR4 more defensive resize handling
  • [*] Z4XRNDTR find text
  • [*] OAHNWDYG .
  • [*] 2ENZW7TV select text using mouse drag
  • [*] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing

Change contents

  • edit in text.lua at line 918
    [6.3998]
    [6.3998]
    function Text.tweak_screen_top_and_cursor()
    --? print('a', Selection1.line)
    if Screen_top1.pos == 1 then return end
    Text.populate_screen_line_starting_pos(Screen_top1.line)
    local line = Lines[Screen_top1.line]
    for i=2,#line.screen_line_starting_pos do
    local pos = line.screen_line_starting_pos[i]
    if pos == Screen_top1.pos then
    break
    end
    if pos > Screen_top1.pos then
    -- make sure screen top is at start of a screen line
    local prev = line.screen_line_starting_pos[i-1]
    if Screen_top1.pos - prev < pos - Screen_top1.pos then
    Screen_top1.pos = prev
    else
    Screen_top1.pos = pos
    end
    break
    end
    end
    -- make sure cursor is on screen
    if Text.lt1(Cursor1, Screen_top1) then
    Cursor1 = {line=Screen_top1.line, pos=Screen_top1.pos}
    elseif Cursor1.line >= Screen_bottom1.line then
    --? print('too low')
    App.draw()
    if Text.lt1(Screen_bottom1, Cursor1) then
    --? print('tweak')
    local line = Lines[Screen_bottom1.line]
    Cursor1 = {line=Screen_bottom1.line, pos=Text.to_pos_on_line(line, App.screen.width-5, App.screen.height-5)}
    end
    end
    end
  • edit in main.lua at line 55
    [8.8975]
    [8.9024]
    --
    -- Make sure these coordinates are never aliased, so that changing one causes
    -- action at a distance.
  • edit in main.lua at line 193
    [9.217]
    [2.154]
    Selection1 = {} -- no support for shift drag while we're resizing
    Text.tweak_screen_top_and_cursor()
  • edit in main.lua at line 329
    [10.2909]
    [11.49]
    --? print('press')
  • edit in main.lua at line 363
    [10.2943]
    [12.293]
    --? print('release')
  • edit in Manual_tests.md at line 23
    [3.301]
    * Like any high-level language, it's easy to accidentally alias two non-scalar
    variables. I wish there was a way to require copy when assigning.