Merge lines.love
[?]
Mar 26, 2023, 4:49 PM
MU2HIRR62BULXR6QKVGJNUWSURYYJ2YFCHUHS4BOI3KHUM725BLACDependencies
- [2]
UD7HNQL7purge unused button infrastructure - [3]
2TQUKHBCMerge lines.love - [4]
AF253GHLbugfix - [5]
4EGQRXDAbugfix: naming points - [6]
MD3W5IRAnew fork: rip out drawing support - [7]
ORRSP7FVdeduce test names on failures - [8]
2ZYV7D3Whandle tab characters - [9]
LNUHQOGHstart passing in Editor_state explicitly - [10]
2CK5QI7Wmake love event names consistent - [11]
7VGDIPLCmore robust state validation - [12]
VP5KC4XZMerge lines.love - [13]
APX2PY6Gstop tracking wallclock time - [14]
42LVB4DEtest: naming a point - [15]
2L5MEZV3experiment: new edit namespace - [16]
MTJEVRJRadd state arg to a few functions - [17]
A4BSGS2CMerge lines.love - [18]
U3MJNFUYMerge lines.love - [19]
5Y24ZDZIbugfix - [20]
MUJTM6REbring back a level of wrapping - [21]
3QQZ7W4Ebring couple more globals back to the app level - [22]
KYNGDE2Cconsistent names in a few more places - [23]
L6XA5EY2test: moving a point - [24]
Y4VYNEGFtest: autosave after name/move/delete of point - [25]
VZJHGWSPMerge lines.love - [26]
5ZA3BRNYadd state arg to a few functions - [27]
LF7BWEG4group all editor globals - [28]
Z5HLXU4Padd state arg to a few functions - [29]
K6DTOGOQflip return value of button handlers - [30]
LSYLEVBDdrop some redundant args when clearing the cache - [31]
ORKN6EOBMerge lines.love - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
K2X6G75Zstart writing some tests for drawings
Change contents
- edit in text.lua at line 164
assert(State.lines[State.cursor1.line].mode == 'text') - resolve order conflict in text.lua at line 164
- edit in edit.lua at line 89
return loc1.line > #State.linesor loc1.pos > #State.lines[loc1.line].data - resurrect zombie in edit.lua at line 89
if loc1.line > #State.lines then return true endlocal l = State.lines[loc1.line]if l.mode ~= 'text' then return false end -- pos is irrelevant to validity for a drawing linereturn loc1.pos > #State.lines[loc1.line].data - resurrect zombie in edit.lua at line 152
--? print('press', State.cursor1.line) - resurrect zombie in edit.lua at line 179
for line_index,line in ipairs(State.lines) doif 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 thenif State.old_selection1.line == nil thenState.selection1 = State.old_cursor1elseState.selection1 = State.old_selection1 - edit in edit.lua at line 179
--? print('release', State.cursor1.line) - edit in edit.lua at line 193
--? print('release', State.cursor1.line) - resolve order conflict in edit.lua at line 193
- edit in edit.lua at line 225
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' thenif len > 0 thenlocal byte_offset = Text.offset(p.name, len-1)if len == 1 then byte_offset = 0 endp.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
- replacement in drawing_tests.lua at line 429
function test_move_point()function test_name_point_then_hit_backspace() - edit in drawing_tests.lua at line 438
-- draw a line - edit in drawing_tests.lua at line 442
function test_name_point_then_hit_backspace() - resurrect zombie in drawing_tests.lua at line 442
-- create a drawing with a lineApp.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixelsEditor_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 lineedit.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 mouseedit.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
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 mouseedit.run_after_keychord(Editor_state, 'C-n')check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')-- hit backspaceedit.run_after_keychord(Editor_state, 'backspace')-- no crashendfunction test_name_point_then_exit_drawing() - edit in drawing_tests.lua at line 467
edit.check_locs(Editor_state) - replacement in drawing_tests.lua at line 487
-- hit backspaceedit.run_after_keychord(Editor_state, 'backspace')-- no crash-- click outside the drawingedit.run_after_mouse_click(Editor_state, App.screen.width-5, App.screen.height-5, 1)-- press a keyedit.run_after_text_input(Editor_state, 'a')-- key goes to textcheck_eq(Editor_state.lines[2].data, 'a') - edit in drawing_tests.lua at line 495
function test_move_point()-- create a drawing with a lineApp.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixelsEditor_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
function test_name_point_then_exit_drawing()-- create a drawing with a lineApp.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixelsEditor_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 lineedit.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 mouseedit.run_after_keychord(Editor_state, 'C-n')check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')-- click outside the drawingedit.run_after_mouse_click(Editor_state, App.screen.width-5, App.screen.height-5, 1)-- press a keyedit.run_after_text_input(Editor_state, 'a')-- key goes to textcheck_eq(Editor_state.lines[2].data, 'a')end - resolve order conflict in drawing_tests.lua at line 830[6.44405]