bugfix

[?]
Mar 18, 2023, 4:52 AM
LK4ZW4BBDD5LC4JK4XK5DJESSDFAIRVFPDM324S7SCAUXEXYVTLQC

Dependencies

  • [2] 2LEXWUW3 get rid of some ridiculous code
  • [3] ORRSP7FV deduce test names on failures
  • [4] ZPUQSPQP extract a few methods
  • [5] JJDT2X4F unnecessary args
  • [6] MXA3RZYK deduce left/right from state where possible
  • [7] KMSL74GA support selections in the source editor
  • [8] KKMFQDR4 editing source code from within the app
  • [9] QCPXQ2E3 add state arg to a few functions
  • [10] UHB4GARJ left/right margin -> left/right coordinates
  • [11] SPSW74Y5 add state arg to Text.keychord_pressed
  • [12] KECEMMMR extract couple of functions
  • [13] HMODUNJE scroll on backspace
  • [14] 62JEPVQ3 bugfix: backspace from start of final line
  • [15] XNFTJHC4 split keyboard handling between Text and Drawing
  • [16] OI4FPFIN support drawings in the source editor
  • [17] F65ADDGL add state arg to a few functions
  • [18] HTWAM4NZ bugfix: scrolling in left/right movements
  • [19] G54H3YG2 get rid of all bifold text
  • [*] LXTTOB33 extract a couple of files
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • edit in text_tests.lua at line 1282
    [3.12204]
    [21.20697]
    end
    function test_up_arrow_scrolls_up_by_one_line_skipping_drawing()
    -- display lines 3/4/5 with a drawing just off screen at line 2
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', '```lines', '```', 'def', 'ghi', 'jkl'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=3, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'def', 'baseline/screen:1')
    y = y + Editor_state.line_height
    App.screen.check(y, 'ghi', 'baseline/screen:2')
    y = y + Editor_state.line_height
    App.screen.check(y, 'jkl', 'baseline/screen:3')
    -- after hitting the up arrow the screen scrolls up to previous text line
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
  • replacement in text.lua at line 233
    [4.1154][4.3:57](),[4.2510][4.3:57](),[4.57][4.15654:15731](),[4.15654][4.15654:15731](),[4.15731][4.540:588](),[4.540][4.540:588]()
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2, State.left, State.right)
    State.screen_top1 = Text.to1(State, top2)
    [4.1154]
    [4.588]
    State.screen_top1 = {
    line=State.cursor1.line,
    pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
    }
  • replacement in text.lua at line 452
    [2.56][2.56:204]()
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2)
    State.screen_top1 = Text.to1(State, top2)
    [2.56]
    [2.204]
    State.screen_top1 = {
    line=State.cursor1.line,
    pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
    }
    Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
  • replacement in text.lua at line 595
    [4.606][4.2107:2209](),[4.2209][4.1702:1748](),[4.1702][4.1702:1748]()
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2)
    State.screen_top1 = Text.to1(State, top2)
    [4.606]
    [4.568]
    State.screen_top1 = {
    line=State.cursor1.line,
    pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
    }
    Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
  • edit in source_text_tests.lua at line 1252
    [3.35050]
    [4.49007]
    end
    function test_up_arrow_scrolls_up_by_one_line_skipping_drawing()
    -- display lines 3/4/5 with a drawing just off screen at line 2
    App.screen.init{width=120, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', '```lines', '```', 'def', 'ghi', 'jkl'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=3, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'def', 'baseline/screen:1')
    y = y + Editor_state.line_height
    App.screen.check(y, 'ghi', 'baseline/screen:2')
    y = y + Editor_state.line_height
    App.screen.check(y, 'jkl', 'baseline/screen:3')
    -- after hitting the up arrow the screen scrolls up to previous text line
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
  • replacement in source_text.lua at line 250
    [4.102512][4.102512:102691]()
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2, State.left, State.right)
    State.screen_top1 = Text.to1(State, top2)
    [4.102512]
    [4.102691]
    State.screen_top1 = {
    line=State.cursor1.line,
    pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
    }
  • replacement in source_text.lua at line 469
    [4.111167][4.111167:111315]()
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2)
    State.screen_top1 = Text.to1(State, top2)
    [4.111167]
    [4.111315]
    State.screen_top1 = {
    line=State.cursor1.line,
    pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
    }
    Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
  • replacement in source_text.lua at line 612
    [4.123165][4.123165:123313]()
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2)
    State.screen_top1 = Text.to1(State, top2)
    [4.123165]
    [4.123313]
    State.screen_top1 = {
    line=State.cursor1.line,
    pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
    }
    Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks