Merge lines.love

[?]
Sep 7, 2022, 5:19 PM
TFM6F5ODCDCNZPYVB5NZMW6MUEDTDUQNTBLPOVBTJ3IH7KT3ETKQC

Dependencies

  • [2] D4B52CQ2 Merge lines.love
  • [3] 2WGHUWE6 self-documenting 0 Test_right_margin
  • [4] D2GCFTTT clean up repl functionality
  • [5] T4FRZSYL delete an ancient, unused file
  • [6] OI4FPFIN support drawings in the source editor
  • [7] VHUNJHXB Merge lines.love
  • [8] FS2ITYYH record a known issue
  • [9] GUOQRUL7 Merge lines.love
  • [10] OGUV4HSA remove some memory leaks from rendered fragments
  • [11] KMSL74GA support selections in the source editor
  • [12] 73OCE2MC after much struggle, a brute-force undo
  • [13] TLOAPLBJ add a license
  • [14] R5QXEHUI somebody stop me
  • [15] 66X36NZN a little more prose describing manual_tests
  • [16] AVTNUQYR basic test-enabled framework
  • [17] BLWAYPKV extract a module
  • [18] JOPVPUSA editing source code from within the app
  • [19] QS3YLNKZ Merge lines.love
  • [20] MD3W5IRA new fork: rip out drawing support
  • [21] VXORMHME delete experimental REPL
  • [22] 32V6ZHQB Merge lines.love
  • [23] 2CTN2IEF Merge lines.love
  • [24] 6LJZN727 handle chords
  • [25] K2X6G75Z start writing some tests for drawings
  • [26] KKMFQDR4 editing source code from within the app
  • [27] VHQCNMAR several more modules
  • [28] BULPIBEG beginnings of a module for the text editor
  • [29] LXTTOB33 extract a couple of files
  • [30] OTIBCAUJ love2d scaffold
  • [31] 3QNOKBFM beginnings of a test harness
  • [32] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [33] 4YDBYBA4 clean up memory leak experiments
  • [34] RSZD5A7G forgot to add json.lua
  • [35] TVCPXAAU rename
  • [36] CE4LZV4T drop last couple of manual tests
  • [37] 2L5MEZV3 experiment: new edit namespace
  • [38] XX7G2FFJ intermingle freehand line drawings with text
  • [39] 3PSFWAIL Merge lines.love

Change contents

  • file deletion: source_tests.lua (----------)source_tests.lua (----------)
    [4.2][4.150199:150239](),[4.2][4.150199:150239](),[4.150239][4.147103:147103]()
    check_eq(Editor_state.width, 200-Margin_left-Margin_right, 'F - test_resize_window/drawing_width')
    -- TODO: how to make assertions about when App.update got past the early exit?
    end
    function test_drop_file()
    io.write('\ntest_drop_file')
    App.screen.init{width=Editor_state.left+300, height=300}
    Editor_state = edit.initialize_test_state()
    App.filesystem['foo'] = 'abc\ndef\nghi\n'
    local fake_dropped_file = {
    opened = false,
    getFilename = function(self)
    return 'foo'
    end,
    open = function(self)
    self.opened = true
    end,
    lines = function(self)
    assert(self.opened)
    return App.filesystem['foo']:gmatch('[^\n]+')
    end,
    close = function(self)
    self.opened = false
    end,
    }
    App.filedropped(fake_dropped_file)
    check_eq(#Editor_state.lines, 3, 'F - test_drop_file/#lines')
    check_eq(Editor_state.lines[1].data, 'abc', 'F - test_drop_file/lines:1')
    check_eq(Editor_state.lines[2].data, 'def', 'F - test_drop_file/lines:2')
    check_eq(Editor_state.lines[3].data, 'ghi', 'F - test_drop_file/lines:3')
    edit.draw(Editor_state)
    end
    function test_drop_file_saves_previous()
    io.write('\ntest_drop_file_saves_previous')
    App.screen.init{width=Editor_state.left+300, height=300}
    -- initially editing a file called foo that hasn't been saved to filesystem yet
    Editor_state.lines = load_array{'abc', 'def'}
    Editor_state.filename = 'foo'
    schedule_save(Editor_state)
    -- now drag a new file bar from the filesystem
    App.filesystem['bar'] = 'abc\ndef\nghi\n'
    local fake_dropped_file = {
    opened = false,
    getFilename = function(self)
    return 'bar'
    end,
    open = function(self)
    self.opened = true
    end,
    lines = function(self)
    assert(self.opened)
    return App.filesystem['bar']:gmatch('[^\n]+')
    end,
    close = function(self)
    self.opened = false
    end,
    }
    App.filedropped(fake_dropped_file)
    -- filesystem now contains a file called foo
    check_eq(App.filesystem['foo'], 'abc\ndef\n', 'F - test_drop_file_saves_previous')
    end
    check_eq(Editor_state.left, Margin_left, 'F - test_resize_window/left_margin')
    check_eq(Editor_state.right, 200-Margin_right, 'F - test_resize_window/right_margin')
    -- ugly; resize switches to real, non-test margins
    check_eq(App.screen.width, 200, 'F - test_resize_window/width')
    check_eq(App.screen.height, 400, 'F - test_resize_window/height')
    check_eq(Editor_state.right, 300 - Test_margin_right, 'F - test_resize_window/baseline/left_margin')
    App.resize(200, 400)
  • file deletion: source_edit.lua (----------)source_edit.lua (----------)
    [4.2][4.165725:165764](),[4.2][4.165725:165764](),[4.165764][4.152440:152440]()
    App.screen.width - Test_margin_right,
    14, -- font height assuming default LÖVE font
    15) -- line height
    end
    -- all textinput events are also keypresses
    -- TODO: handle chords of multiple keys
    function edit.run_after_textinput(State, t)
    edit.keychord_pressed(State, t)
    edit.textinput(State, t)
    edit.key_released(State, t)
    App.screen.contents = {}
    edit.draw(State)
    end
    -- not all keys are textinput
    function edit.run_after_keychord(State, chord)
    edit.keychord_pressed(State, chord)
    edit.key_released(State, chord)
    App.screen.contents = {}
    edit.draw(State)
    end
    function edit.run_after_mouse_click(State, x,y, mouse_button)
    App.fake_mouse_press(x,y, mouse_button)
    edit.mouse_pressed(State, x,y, mouse_button)
    App.fake_mouse_release(x,y, mouse_button)
    edit.mouse_released(State, x,y, mouse_button)
    App.screen.contents = {}
    edit.draw(State)
    end
    function edit.run_after_mouse_press(State, x,y, mouse_button)
    App.fake_mouse_press(x,y, mouse_button)
    edit.mouse_pressed(State, x,y, mouse_button)
    App.screen.contents = {}
    edit.draw(State)
    end
    function edit.run_after_mouse_release(State, x,y, mouse_button)
    App.fake_mouse_release(x,y, mouse_button)
    edit.mouse_released(State, x,y, mouse_button)
    App.screen.contents = {}
    edit.draw(State)
    end
    Test_margin_right = 0
    function edit.initialize_test_state()
    -- if you change these values, tests will start failing
    return edit.initialize_state(
    15, -- top margin
    Test_margin_left,
    -- Insulate tests from some key globals so I don't have to change the vast
    -- majority of tests when they're modified for the real app.
    Test_margin_left = 25
  • edit in source_tests.lua at line 10
    [4.147649]
    [4.147649]
    check_eq(Editor_state.right, 300 - Test_margin_right, 'F - test_resize_window/baseline/left_margin')
  • edit in source_tests.lua at line 12
    [4.147672]
    [4.147672]
    -- ugly; resize switches to real, non-test margins
  • replacement in source_tests.lua at line 15
    [4.147806][4.147806:147945]()
    check_eq(Editor_state.left, Test_margin_left, 'F - test_resize_window/left_margin')
    -- ugly; right margin switches from 0 after resize
    [4.147806]
    [4.147945]
    check_eq(Editor_state.left, Margin_left, 'F - test_resize_window/left_margin')
  • replacement in source_tests.lua at line 17
    [4.148033][4.148033:148139]()
    check_eq(Editor_state.width, 200-Test_margin_left-Margin_right, 'F - test_resize_window/drawing_width')
    [4.148033]
    [4.148139]
    check_eq(Editor_state.width, 200-Margin_left-Margin_right, 'F - test_resize_window/drawing_width')
  • edit in source_edit.lua at line 518
    [4.164285]
    [4.164285]
    -- Insulate tests from some key globals so I don't have to change the vast
    -- majority of tests when they're modified for the real app.
  • edit in source_edit.lua at line 521
    [4.164307]
    [4.164307]
    Test_margin_right = 0
  • replacement in source_edit.lua at line 528
    [4.164485][4.164485:164530]()
    App.screen.width, -- right margin = 0
    [4.164485]
    [4.164530]
    App.screen.width - Test_margin_right,