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id perturbing future edits')
end
function test_draw_text()
check_eq(Editor_state.cursor1.line, 1, 'cursor')
-- selection remains empty
check_nil(Editor_state.selection1.line, 'selection is empty to avoid perturbing future edits')
end
function test_click_below_all_lines()
-- display one line
App.screen.init{width=50, height=80}
Editor_state = edit.initialize_test_state()
Editor_state.lines = load_array{'abc'}
Text.redraw_all(Editor_state)
Editor_state.cursor1 = {line=1, pos=1}
Editor_state.screen_top1 = {line=1, pos=1}
Editor_state.screen_bottom1 = {}
Editor_state.selection1 = {}
-- click below first line
edit.draw(Editor_state)
edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+50, 1)
-- cursor doesn't move
check_eq(Editor_state.cursor1.line, 1, 'cursor')
Editor_state.selection1 = {}
-- click on the empty line
edit.draw(Editor_state)
edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-- cursor moves
Editor_state.selection1 = {}
-- click on the other line
edit.draw(Editor_state)
edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-- cursor moves
Editor_state.selection1 = {}
-- click to the left of the line
edit.draw(Editor_state)
edit.run_after_mouse_click(Editor_state, Editor_state.left-4,Editor_state.top+5, 1)
-- cursor moves to start of line
State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
if eq(State.cursor1, State.selection1) then
State.selection1 = {}
end
end
function edit.mouse_wheel_move(State, dx,dy)
if dy > 0 then
State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
end
end
function edit.clean_up_mouse_press(State)
if State.mousepress_shift then
if State.old_selection1.line == nil then
State.selection1 = State.old_cursor1
else
State.selection1 = State.old_selection1
end
end
-- still here? mouse release is below all screen lines
State.cursor1.line, State.cursor1.pos = State.screen_bottom1.line, Text.pos_at_end_of_screen_line(State, State.screen_bottom1)
edit.clean_up_mouse_press(State)
--? print_and_log(('edit.mouse_release: finally selection %s,%s cursor %d,%d'):format(tostring(State.selection1.line), tostring(State.selection1.pos), State.cursor1.line, State.cursor1.pos))
edit.clean_up_mouse_press(State)
return
end
end
end
if y < State.top then
State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
edit.clean_up_mouse_press(State)
return
end
for line_index,line in ipairs(State.lines) do
if line.mode == 'text' then
if Text.in_line(State, line_index, x,y) then
-- still here? mouse press is below all screen lines
State.old_cursor1 = State.cursor1
State.old_selection1 = State.selection1
State.mousepress_shift = App.shift_down()
State.selection1 = {
line=State.screen_bottom1.line,
pos=Text.pos_at_end_of_screen_line(State, State.screen_bottom1),
}
check_eq(Editor_state.cursor1.line, 1, 'cursor')
-- selection remains empty
check_nil(Editor_state.selection1.line, 'selection is empty to avoid perturbing future edits')
end
function test_click_below_all_lines()
-- display one line
App.screen.init{width=50, height=80}
Editor_state = edit.initialize_test_state()
Editor_state.lines = load_array{'abc'}
Text.redraw_all(Editor_state)
Editor_state.cursor1 = {line=1, pos=1}
Editor_state.screen_top1 = {line=1, pos=1}
Editor_state.screen_bottom1 = {}
Editor_state.selection1 = {}
-- click below first line
edit.draw(Editor_state)
edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+50, 1)
-- cursor doesn't move
if State.mousepress_shift then
if State.old_selection1.line == nil then
State.selection1 = State.old_cursor1
else
State.selection1 = State.old_selection1
end
end
State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
if eq(State.cursor1, State.selection1) then
State.selection1 = {}
end
break
edit.clean_up_mouse_press(State)
return
if State.mousepress_shift then
if State.old_selection1.line == nil then
State.selection1 = State.old_cursor1
else
State.selection1 = State.old_selection1
end
end
State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
if eq(State.cursor1, State.selection1) then
State.selection1 = {}
end
break
edit.clean_up_mouse_press(State)
return
function edit.clean_up_mouse_press(State)
if State.mousepress_shift then
if State.old_selection1.line == nil then
State.selection1 = State.old_cursor1
else
State.selection1 = State.old_selection1
end
end
State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
if eq(State.cursor1, State.selection1) then
State.selection1 = {}
end
end
edit.clean_up_mouse_press(State)
return
State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
if eq(State.cursor1, State.selection1) then
State.selection1 = {}
end
end
end
function edit.clean_up_mouse_press(State)
if State.mousepress_shift then
if State.old_selection1.line == nil then
State.selection1 = State.old_cursor1
else
State.selection1 = State.old_selection1
end
-- still here? mouse release is below all screen lines
State.cursor1.line, State.cursor1.pos = State.screen_bottom1.line, Text.pos_at_end_of_screen_line(State, State.screen_bottom1)
edit.clean_up_mouse_press(State)
if y < State.top then
State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
edit.clean_up_mouse_press(State)
return
end
-- still here? mouse press is below all screen lines