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UPLAC L6XA5EY2FVDQFRGCBFSCOM6O4GYN74K3YTZKGFUOPXIUYA3YT5JQC ORRSP7FVCHI2TF5GXBRGQYYJAA3JFYXZBM3T663BKSBV22FCZVCAC 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
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
-- 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')
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()
-- 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')
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]
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