Merge lines.love

[?]
Mar 26, 2023, 4:49 PM
MU2HIRR62BULXR6QKVGJNUWSURYYJ2YFCHUHS4BOI3KHUM725BLAC

Dependencies

  • [2] UD7HNQL7 purge unused button infrastructure
  • [3] 2TQUKHBC Merge lines.love
  • [4] AF253GHL bugfix
  • [5] 4EGQRXDA bugfix: naming points
  • [6] MD3W5IRA new fork: rip out drawing support
  • [7] ORRSP7FV deduce test names on failures
  • [8] 2ZYV7D3W handle tab characters
  • [9] LNUHQOGH start passing in Editor_state explicitly
  • [10] 2CK5QI7W make love event names consistent
  • [11] 7VGDIPLC more robust state validation
  • [12] VP5KC4XZ Merge lines.love
  • [13] APX2PY6G stop tracking wallclock time
  • [14] 42LVB4DE test: naming a point
  • [15] 2L5MEZV3 experiment: new edit namespace
  • [16] MTJEVRJR add state arg to a few functions
  • [17] A4BSGS2C Merge lines.love
  • [18] U3MJNFUY Merge lines.love
  • [19] 5Y24ZDZI bugfix
  • [20] MUJTM6RE bring back a level of wrapping
  • [21] 3QQZ7W4E bring couple more globals back to the app level
  • [22] KYNGDE2C consistent names in a few more places
  • [23] L6XA5EY2 test: moving a point
  • [24] Y4VYNEGF test: autosave after name/move/delete of point
  • [25] VZJHGWSP Merge lines.love
  • [26] 5ZA3BRNY add state arg to a few functions
  • [27] LF7BWEG4 group all editor globals
  • [28] Z5HLXU4P add state arg to a few functions
  • [29] K6DTOGOQ flip return value of button handlers
  • [30] LSYLEVBD drop some redundant args when clearing the cache
  • [31] ORKN6EOB Merge lines.love
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] K2X6G75Z start writing some tests for drawings

Change contents

  • edit in text.lua at line 164
    [6.79][5.3:60](),[6.79][5.3:60]()
    assert(State.lines[State.cursor1.line].mode == 'text')
  • resolve order conflict in text.lua at line 164
    [6.2204]
    [6.3]
  • edit in edit.lua at line 89
    [6.565][6.565:648](),[6.565][6.565:648]()
    return loc1.line > #State.lines
    or loc1.pos > #State.lines[loc1.line].data
  • resurrect zombie in edit.lua at line 89
    [6.565][4.26:258](),[6.565][4.26:258]()
    if loc1.line > #State.lines then return true end
    local l = State.lines[loc1.line]
    if l.mode ~= 'text' then return false end -- pos is irrelevant to validity for a drawing line
    return loc1.pos > #State.lines[loc1.line].data
  • resurrect zombie in edit.lua at line 152
    [6.4581][5.84:125](),[6.4581][5.84:125]()
    --? print('press', State.cursor1.line)
  • resurrect zombie in edit.lua at line 179
    [6.8468][6.10816:11328](),[6.8468][6.10816:11328]()
    for line_index,line in ipairs(State.lines) do
    if Text.in_line(State, line_index, x,y) then
    --? print('reset selection')
    State.cursor1 = {
    line=line_index,
    pos=Text.to_pos_on_line(State, line_index, x, y),
    }
    --? print('cursor', State.cursor1.line, State.cursor1.pos)
    if State.mousepress_shift then
    if State.old_selection1.line == nil then
    State.selection1 = State.old_cursor1
    else
    State.selection1 = State.old_selection1
  • edit in edit.lua at line 179
    [6.5338]
    [6.10816]
    --? print('release', State.cursor1.line)
  • edit in edit.lua at line 193
    [6.11328][6.8763:8763](),[6.5338][5.126:169](),[6.5338][5.126:169]()
    --? print('release', State.cursor1.line)
  • resolve order conflict in edit.lua at line 193
    [6.11328]
    [6.9594]
  • edit in edit.lua at line 225
    [6.2117][5.200:283](),[6.2117][5.200:283]()
    elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
  • edit in edit.lua at line 349
    [6.11602][6.8798:8798](),[6.15043][5.284:367](),[6.15043][5.284:367](),[6.15593][6.26:330](),[6.15593][6.26:330]()
    elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
    if len > 0 then
    local byte_offset = Text.offset(p.name, len-1)
    if len == 1 then byte_offset = 0 end
    p.name = string.sub(p.name, 1, byte_offset)
    record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})
    end
  • resolve order conflict in edit.lua at line 349
    [6.11602]
    [6.15871]
  • replacement in drawing_tests.lua at line 429
    [6.25944][6.25944:25971]()
    function test_move_point()
    [6.25944]
    [6.26003]
    function test_name_point_then_hit_backspace()
  • edit in drawing_tests.lua at line 438
    [6.26373]
    [6.26373]
    -- draw a line
  • edit in drawing_tests.lua at line 442
    [6.26631][6.31738:31738](),[6.19][6.332:378](),[6.19][6.332:378]()
    function test_name_point_then_hit_backspace()
  • resurrect zombie in drawing_tests.lua at line 442
    [6.378][6.378:1638](),[6.378][6.378:1638]()
    -- create a drawing with a line
    App.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
    Editor_state = edit.initialize_test_state()
    Editor_state.filename = 'foo'
    Editor_state.lines = load_array{'```lines', '```', ''}
    Text.redraw_all(Editor_state)
    Editor_state.current_drawing_mode = 'line'
    edit.draw(Editor_state)
    -- draw a line
    edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
    edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
    local drawing = Editor_state.lines[1]
    check_eq(#drawing.shapes, 1, 'baseline/#shapes')
    check_eq(#drawing.points, 2, 'baseline/#points')
    check_eq(drawing.shapes[1].mode, 'line', 'baseline/shape:1')
    local p1 = drawing.points[drawing.shapes[1].p1]
    local p2 = drawing.points[drawing.shapes[1].p2]
    check_eq(p1.x, 5, 'baseline/p1:x')
    check_eq(p1.y, 6, 'baseline/p1:y')
    check_eq(p2.x, 35, 'baseline/p2:x')
    check_eq(p2.y, 36, 'baseline/p2:y')
    check_nil(p2.name, 'baseline/p2:name')
    -- enter 'name' mode without moving the mouse
    edit.run_after_keychord(Editor_state, 'C-n')
    check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')
  • resolve order conflict in drawing_tests.lua at line 442
    [6.26631]
  • edit in drawing_tests.lua at line 442
    [0.143]
    [6.378]
    check_eq(#drawing.shapes, 1, 'baseline/#shapes')
    check_eq(#drawing.points, 2, 'baseline/#points')
    check_eq(drawing.shapes[1].mode, 'line', 'baseline/shape:1')
    local p1 = drawing.points[drawing.shapes[1].p1]
    local p2 = drawing.points[drawing.shapes[1].p2]
    check_eq(p1.x, 5, 'baseline/p1:x')
    check_eq(p1.y, 6, 'baseline/p1:y')
    check_eq(p2.x, 35, 'baseline/p2:x')
    check_eq(p2.y, 36, 'baseline/p2:y')
    check_nil(p2.name, 'baseline/p2:name')
    -- enter 'name' mode without moving the mouse
    edit.run_after_keychord(Editor_state, 'C-n')
    check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')
    -- hit backspace
    edit.run_after_keychord(Editor_state, 'backspace')
    -- no crash
    end
    function test_name_point_then_exit_drawing()
  • edit in drawing_tests.lua at line 467
    [6.677]
    [6.677]
    edit.check_locs(Editor_state)
  • replacement in drawing_tests.lua at line 487
    [6.1638][6.1638:1724](),[6.1638][6.1638:1724]()
    -- hit backspace
    edit.run_after_keychord(Editor_state, 'backspace')
    -- no crash
    [6.1638]
    [6.1724]
    -- click outside the drawing
    edit.run_after_mouse_click(Editor_state, App.screen.width-5, App.screen.height-5, 1)
    -- press a key
    edit.run_after_text_input(Editor_state, 'a')
    -- key goes to text
    check_eq(Editor_state.lines[2].data, 'a')
  • edit in drawing_tests.lua at line 495
    [6.1729]
    [6.56390]
    function test_move_point()
    -- create a drawing with a line
    App.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
    Editor_state = edit.initialize_test_state()
    Editor_state.filename = 'foo'
    Editor_state.lines = load_array{'```lines', '```', ''}
    Text.redraw_all(Editor_state)
    Editor_state.current_drawing_mode = 'line'
    edit.draw(Editor_state)
    edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
    edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
    local drawing = Editor_state.lines[1]
  • edit in drawing_tests.lua at line 830
    [6.44405][6.35176:35176](),[6.1729][5.369:1959](),[6.1729][5.369:1959]()
    function test_name_point_then_exit_drawing()
    -- create a drawing with a line
    App.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
    Editor_state = edit.initialize_test_state()
    Editor_state.filename = 'foo'
    Editor_state.lines = load_array{'```lines', '```', ''}
    Text.redraw_all(Editor_state)
    edit.check_locs(Editor_state)
    Editor_state.current_drawing_mode = 'line'
    edit.draw(Editor_state)
    -- draw a line
    edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
    edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
    local drawing = Editor_state.lines[1]
    check_eq(#drawing.shapes, 1, 'baseline/#shapes')
    check_eq(#drawing.points, 2, 'baseline/#points')
    check_eq(drawing.shapes[1].mode, 'line', 'baseline/shape:1')
    local p1 = drawing.points[drawing.shapes[1].p1]
    local p2 = drawing.points[drawing.shapes[1].p2]
    check_eq(p1.x, 5, 'baseline/p1:x')
    check_eq(p1.y, 6, 'baseline/p1:y')
    check_eq(p2.x, 35, 'baseline/p2:x')
    check_eq(p2.y, 36, 'baseline/p2:y')
    check_nil(p2.name, 'baseline/p2:name')
    -- enter 'name' mode without moving the mouse
    edit.run_after_keychord(Editor_state, 'C-n')
    check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')
    -- click outside the drawing
    edit.run_after_mouse_click(Editor_state, App.screen.width-5, App.screen.height-5, 1)
    -- press a key
    edit.run_after_text_input(Editor_state, 'a')
    -- key goes to text
    check_eq(Editor_state.lines[2].data, 'a')
    end
  • resolve order conflict in drawing_tests.lua at line 830
    [6.44405]