bugfix: backspace from start of final line

[?]
Aug 11, 2022, 5:38 AM
62JEPVQ34SOTQI6VQNLGLKS5O4KFU52UKAVDHN6N7G5T6Z5EZO5QC

Dependencies

  • [2] JJDT2X4F unnecessary args
  • [3] UHB4GARJ left/right margin -> left/right coordinates
  • [4] LF7BWEG4 group all editor globals
  • [5] HMODUNJE scroll on backspace
  • [6] SPSW74Y5 add state arg to Text.keychord_pressed
  • [7] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [8] XNFTJHC4 split keyboard handling between Text and Drawing
  • [9] QCPXQ2E3 add state arg to a few functions
  • [10] AYE2VEGJ extract a couple of methods
  • [*] LXTTOB33 extract a couple of files
  • [*] DSLD74DK lots more tests
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • edit in text_tests.lua at line 43
    [3.2318]
    [13.1482]
    end
    function test_backspace_from_start_of_final_line()
    io.write('\ntest_backspace_from_start_of_final_line')
    -- display final line of text with cursor at start of it
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', 'def'}
    Editor_state.screen_top1 = {line=2, pos=1}
    Editor_state.cursor1 = {line=2, pos=1}
    Text.redraw_all(Editor_state)
    -- backspace scrolls up
    edit.run_after_keychord(Editor_state, 'backspace')
    check_eq(#Editor_state.lines, 1, 'F - test_backspace_from_start_of_final_line/#lines')
    check_eq(Editor_state.cursor1.line, 1, 'F - test_backspace_from_start_of_final_line/cursor')
    check_eq(Editor_state.screen_top1.line, 1, 'F - test_backspace_from_start_of_final_line/screen_top')
  • replacement in text.lua at line 209
    [3.2866][3.2455:2510]()
    if Text.lt1(State.cursor1, State.screen_top1) then
    [3.2866]
    [2.3]
    if State.screen_top1.line > #State.lines then
    Text.populate_screen_line_starting_pos(State, #State.lines)
    local line_cache = State.line_cache[#State.line_cache]
    State.screen_top1 = {line=#State.lines, pos=line_cache.screen_line_starting_pos[#line_cache.screen_line_starting_pos]}
    elseif Text.lt1(State.cursor1, State.screen_top1) then