Merge lines.love
[?]
Sep 7, 2022, 5:19 PM
TFM6F5ODCDCNZPYVB5NZMW6MUEDTDUQNTBLPOVBTJ3IH7KT3ETKQCDependencies
- [2]
D4B52CQ2Merge lines.love - [3]
2WGHUWE6self-documenting 0 Test_right_margin - [4]
D2GCFTTTclean up repl functionality - [5]
T4FRZSYLdelete an ancient, unused file - [6]
OI4FPFINsupport drawings in the source editor - [7]
VHUNJHXBMerge lines.love - [8]
FS2ITYYHrecord a known issue - [9]
GUOQRUL7Merge lines.love - [10]
OGUV4HSAremove some memory leaks from rendered fragments - [11]
KMSL74GAsupport selections in the source editor - [12]
73OCE2MCafter much struggle, a brute-force undo - [13]
TLOAPLBJadd a license - [14]
R5QXEHUIsomebody stop me - [15]
66X36NZNa little more prose describing manual_tests - [16]
AVTNUQYRbasic test-enabled framework - [17]
BLWAYPKVextract a module - [18]
JOPVPUSAediting source code from within the app - [19]
QS3YLNKZMerge lines.love - [20]
MD3W5IRAnew fork: rip out drawing support - [21]
VXORMHMEdelete experimental REPL - [22]
32V6ZHQBMerge lines.love - [23]
2CTN2IEFMerge lines.love - [24]
6LJZN727handle chords - [25]
K2X6G75Zstart writing some tests for drawings - [26]
KKMFQDR4editing source code from within the app - [27]
VHQCNMARseveral more modules - [28]
BULPIBEGbeginnings of a module for the text editor - [29]
LXTTOB33extract a couple of files - [30]
OTIBCAUJlove2d scaffold - [31]
3QNOKBFMbeginnings of a test harness - [32]
BJ5X5O4Alet's prevent the text cursor from ever getting on a drawing - [33]
4YDBYBA4clean up memory leak experiments - [34]
RSZD5A7Gforgot to add json.lua - [35]
TVCPXAAUrename - [36]
CE4LZV4Tdrop last couple of manual tests - [37]
2L5MEZV3experiment: new edit namespace - [38]
XX7G2FFJintermingle freehand line drawings with text - [39]
3PSFWAILMerge lines.love
Change contents
- file deletion: source_tests.lua source_tests.lua
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?endfunction 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 = trueend,lines = function(self)assert(self.opened)return App.filesystem['foo']:gmatch('[^\n]+')end,close = function(self)self.opened = falseend,}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)endfunction 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 yetEditor_state.lines = load_array{'abc', 'def'}Editor_state.filename = 'foo'schedule_save(Editor_state)-- now drag a new file bar from the filesystemApp.filesystem['bar'] = 'abc\ndef\nghi\n'local fake_dropped_file = {opened = false,getFilename = function(self)return 'bar'end,open = function(self)self.opened = trueend,lines = function(self)assert(self.opened)return App.filesystem['bar']:gmatch('[^\n]+')end,close = function(self)self.opened = falseend,}App.filedropped(fake_dropped_file)-- filesystem now contains a file called foocheck_eq(App.filesystem['foo'], 'abc\ndef\n', 'F - test_drop_file_saves_previous')endcheck_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 marginscheck_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
App.screen.width - Test_margin_right,14, -- font height assuming default LÖVE font15) -- line heightend-- all textinput events are also keypresses-- TODO: handle chords of multiple keysfunction 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 textinputfunction edit.run_after_keychord(State, chord)edit.keychord_pressed(State, chord)edit.key_released(State, chord)App.screen.contents = {}edit.draw(State)endfunction 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)endfunction 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)endfunction 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)endTest_margin_right = 0function edit.initialize_test_state()-- if you change these values, tests will start failingreturn edit.initialize_state(15, -- top marginTest_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
check_eq(Editor_state.right, 300 - Test_margin_right, 'F - test_resize_window/baseline/left_margin') - edit in source_tests.lua at line 12
-- ugly; resize switches to real, non-test margins - replacement in source_tests.lua at line 15
check_eq(Editor_state.left, Test_margin_left, 'F - test_resize_window/left_margin')-- ugly; right margin switches from 0 after resizecheck_eq(Editor_state.left, Margin_left, 'F - test_resize_window/left_margin') - replacement in source_tests.lua at line 17
check_eq(Editor_state.width, 200-Test_margin_left-Margin_right, 'F - test_resize_window/drawing_width')check_eq(Editor_state.width, 200-Margin_left-Margin_right, 'F - test_resize_window/drawing_width') - edit in source_edit.lua at line 518
-- 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
Test_margin_right = 0 - replacement in source_edit.lua at line 528
App.screen.width, -- right margin = 0App.screen.width - Test_margin_right,