Merge lines.love

[?]
Feb 1, 2023, 6:47 AM
B4FAIVRAXKCS2ZZXYUHL7HHWVMDMG2MQ3BY6IOJARK7B5XTBAQNAC

Dependencies

  • [2] A4BSGS2C Merge lines.love
  • [3] SWZAQHGR bugfix: up arrow when line above is a drawing
  • [4] T4FRZSYL delete an ancient, unused file
  • [5] K2X6G75Z start writing some tests for drawings
  • [6] RSZD5A7G forgot to add json.lua
  • [7] TLOAPLBJ add a license
  • [8] D2GCFTTT clean up repl functionality
  • [9] ZPUQSPQP extract a few methods
  • [10] TACI4LU6 Merge lines.love
  • [11] CE4LZV4T drop last couple of manual tests
  • [12] DB7HJBHJ Merge lines.love
  • [13] K74U4BAU Merge lines.love
  • [14] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [15] VXORMHME delete experimental REPL
  • [16] BLWAYPKV extract a module
  • [17] OGUV4HSA remove some memory leaks from rendered fragments
  • [18] 3QNOKBFM beginnings of a test harness
  • [19] 4YDBYBA4 clean up memory leak experiments
  • [20] 66X36NZN a little more prose describing manual_tests
  • [21] OTIBCAUJ love2d scaffold
  • [22] JOPVPUSA editing source code from within the app
  • [23] MUJTM6RE bring back a level of wrapping
  • [24] XX7G2FFJ intermingle freehand line drawings with text
  • [25] LXTTOB33 extract a couple of files
  • [26] VHQCNMAR several more modules
  • [27] SVJZZDC3 snapshot - no, that's all wrong
  • [28] 3PSFWAIL Merge lines.love
  • [29] MD3W5IRA new fork: rip out drawing support
  • [30] ORKN6EOB Merge lines.love
  • [31] 2CTN2IEF Merge lines.love
  • [32] 6LJZN727 handle chords
  • [33] 73OCE2MC after much struggle, a brute-force undo
  • [34] AVTNUQYR basic test-enabled framework
  • [35] 2L5MEZV3 experiment: new edit namespace
  • [36] BULPIBEG beginnings of a module for the text editor
  • [37] LF7BWEG4 group all editor globals
  • [38] FS2ITYYH record a known issue
  • [39] ODLKHO7B switch to line index in a function
  • [40] TVCPXAAU rename
  • [41] OI4FPFIN support drawings in the source editor
  • [42] KKMFQDR4 editing source code from within the app
  • [43] Z5HLXU4P add state arg to a few functions
  • [44] VHUNJHXB Merge lines.love
  • [45] GUOQRUL7 Merge lines.love
  • [46] KMSL74GA support selections in the source editor
  • [47] ETXNVRPT Merge lines.love
  • [48] VP5KC4XZ Merge lines.love
  • [49] KG7YVGVR Merge lines.love
  • [50] UTDSCN3G Merge lines.love
  • [51] ZTZOO2OQ Merge lines.love
  • [52] ORRSP7FV deduce test names on failures
  • [53] R5QXEHUI somebody stop me
  • [*] PLKNHYZ4 extract a function

Change contents

  • file deletion: source_text_tests.lua (----------)source_text_tests.lua (----------)
    [4.2][4.83676:83721](),[4.2][4.83676:83721](),[4.83721][4.3498:3498]()
    function test_up_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    end
    function test_up_arrow_scrolls_up_by_one_line()
    end
    function test_down_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'down')
    check_eq(Editor_state.cursor1.line, 3, 'cursor')
    end
    function test_down_arrow_scrolls_down_by_one_line()
  • file deletion: source_text.lua (----------)source_text.lua (----------)
    [4.2][4.147062:147101](),[4.2][4.147062:147101](),[4.147101][4.83723:83723]()
    State.cursor1 = {line=new_cursor_line, posB=nil}
    Text.populate_screen_line_starting_pos(State, State.cursor1.line)
    local prev_line_cache = State.line_cache[State.cursor1.line]
    local prev_screen_line_starting_pos = prev_line_cache.screen_line_starting_pos[#prev_line_cache.screen_line_starting_pos]
    local prev_screen_line_starting_byte_offset = Text.offset(State.lines[State.cursor1.line].data, prev_screen_line_starting_pos)
    local s = string.sub(State.lines[State.cursor1.line].data, prev_screen_line_starting_byte_offset)
    State.cursor1.pos = prev_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, State.left) - 1
    break
    end
    State.cursor1 = {line=new_cursor_line, pos=nil}
    Text.populate_screen_line_starting_pos(State, State.cursor1.line)
    -- previous text line found, pick its final screen line
    --? print('has multiple screen lines')
    local screen_line_starting_pos = State.line_cache[State.cursor1.line].screen_line_starting_pos
    --? print(#screen_line_starting_pos)
    screen_line_starting_pos = screen_line_starting_pos[#screen_line_starting_pos]
    local screen_line_starting_byte_offset = Text.offset(State.lines[State.cursor1.line].data, screen_line_starting_pos)
    local s = string.sub(State.lines[State.cursor1.line].data, screen_line_starting_byte_offset)
    State.cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, State.left) - 1
    break
    end
  • edit in text_tests.lua at line 1001
    [4.9436][3.2:1103]()
    end
    function test_down_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'down')
    check_eq(Editor_state.cursor1.line, 3, 'cursor')
  • edit in text_tests.lua at line 1151
    [4.19428][3.1104:2197]()
    function test_up_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    end
  • replacement in text.lua at line 413
    [4.4051][4.4051:4094]()
    State.cursor1.line = new_cursor_line
    [4.4051]
    [4.4094]
    State.cursor1 = {line=new_cursor_line, pos=nil}
  • edit in text.lua at line 952
    [4.657][3.2199:2255](),[4.657][3.2199:2255]()
    State.cursor1 = {line=new_cursor_line, pos=nil}
  • resolve order conflict in text.lua at line 952
    [55.442]
  • edit in source_text_tests.lua at line 1026
    [2.8922]
    [4.38240]
    end
    function test_down_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'down')
    check_eq(Editor_state.cursor1.line, 3, 'cursor')
  • edit in source_text_tests.lua at line 1201
    [4.47572]
    [4.47572]
    function test_up_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    end
  • replacement in source_text.lua at line 683
    [4.5724][4.5724:5785]()
    State.cursor1 = {line=State.cursor1.line-1, pos=nil}
    [4.5724]
    [4.5785]
    State.cursor1 = {line=new_cursor_line, pos=nil}
  • replacement in source_text.lua at line 722
    [4.6750][4.6750:6812]()
    State.cursor1 = {line=State.cursor1.line-1, posB=nil}
    [4.6750]
    [4.6812]
    State.cursor1 = {line=new_cursor_line, posB=nil}