From 1d1a829d5b1f89220ebb261d8d01f34652fcd7b2 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 4 Feb 2024 09:30:48 -0800 Subject: more carefully pass the 'key' arg around --- drawing_tests.lua | 44 +++++++------- edit.lua | 6 +- source_tests.lua | 4 +- source_text_tests.lua | 160 ++++++++++++++++++++++++------------------------- text_tests.lua | 162 +++++++++++++++++++++++++------------------------- 5 files changed, 188 insertions(+), 188 deletions(-) diff --git a/drawing_tests.lua b/drawing_tests.lua index 491ff3a..ede25f0 100644 --- a/drawing_tests.lua +++ b/drawing_tests.lua @@ -110,7 +110,7 @@ function test_draw_circle() check_eq(#Editor_state.lines[1].shapes, 0, 'baseline/#shapes') -- draw a circle App.mouse_move(Editor_state.left+4, Editor_state.top+Drawing_padding_top+4) -- hover on drawing - edit.run_after_keychord(Editor_state, 'C-o') + edit.run_after_keychord(Editor_state, 'C-o', 'o') edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1) edit.run_after_mouse_release(Editor_state, Editor_state.left+35+30, Editor_state.top+Drawing_padding_top+36, 1) local drawing = Editor_state.lines[1] @@ -140,7 +140,7 @@ function test_cancel_stroke() -- start drawing a line edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1) -- cancel - edit.run_after_keychord(Editor_state, 'escape') + edit.run_after_keychord(Editor_state, 'escape', 'escape') 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, 0, '#shapes') @@ -156,7 +156,7 @@ function test_keys_do_not_affect_shape_when_mouse_up() edit.draw(Editor_state) -- hover over drawing and press 'o' without holding mouse App.mouse_move(Editor_state.left+4, Editor_state.top+Drawing_padding_top+4) -- hover on drawing - edit.run_after_keychord(Editor_state, 'o') + edit.run_after_keychord(Editor_state, 'o', 'o') -- no change to drawing mode check_eq(Editor_state.current_drawing_mode, 'line', 'drawing_mode') -- no change to text either because we didn't run the text_input event @@ -406,14 +406,14 @@ function test_name_point() check_eq(p2.y, 36, 'baseline/p2:y') check_nil(p2.name, 'baseline/p2:name') -- enter 'name' mode without moving the mouse - edit.run_after_keychord(Editor_state, 'C-n') + edit.run_after_keychord(Editor_state, 'C-n', 'n') check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1') edit.run_after_text_input(Editor_state, 'A') check_eq(p2.name, 'A', 'check1') -- still in 'name' mode check_eq(Editor_state.current_drawing_mode, 'name', 'mode:2') -- exit 'name' mode - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.current_drawing_mode, 'line', 'mode:3') check_eq(p2.name, 'A', 'check2') -- wait until save @@ -450,10 +450,10 @@ function test_name_point_then_hit_backspace() check_eq(p2.y, 36, 'baseline/p2:y') check_nil(p2.name, 'baseline/p2:name') -- enter 'name' mode without moving the mouse - edit.run_after_keychord(Editor_state, 'C-n') + edit.run_after_keychord(Editor_state, 'C-n', 'n') check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1') -- hit backspace - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') -- no crash end @@ -482,7 +482,7 @@ function test_name_point_then_exit_drawing() check_eq(p2.y, 36, 'baseline/p2:y') check_nil(p2.name, 'baseline/p2:name') -- enter 'name' mode without moving the mouse - edit.run_after_keychord(Editor_state, 'C-n') + edit.run_after_keychord(Editor_state, 'C-n', 'n') check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1') -- click outside the drawing edit.run_after_mouse_click(Editor_state, App.screen.width-5, App.screen.height-5, 1) @@ -525,7 +525,7 @@ function test_move_point() check_eq(p2.y, 36, 'save/y') edit.draw(Editor_state) -- enter 'move' mode without moving the mouse - edit.run_after_keychord(Editor_state, 'C-u') + edit.run_after_keychord(Editor_state, 'C-u', 'u') check_eq(Editor_state.current_drawing_mode, 'move', 'mode:1') -- point is lifted check_eq(drawing.pending.mode, 'move', 'mode:2') @@ -568,7 +568,7 @@ function test_move_point_on_manhattan_line() check_eq(drawing.shapes[1].mode, 'manhattan', 'baseline/shape:1') edit.draw(Editor_state) -- enter 'move' mode - edit.run_after_keychord(Editor_state, 'C-u') + edit.run_after_keychord(Editor_state, 'C-u', 'u') check_eq(Editor_state.current_drawing_mode, 'move', 'mode:1') -- move point App.mouse_move(Editor_state.left+26, Editor_state.top+Drawing_padding_top+44) @@ -596,7 +596,7 @@ function test_delete_lines_at_point() check_eq(drawing.shapes[2].mode, 'line', 'baseline/shape:2') -- hover on the common point and delete App.mouse_move(Editor_state.left+35, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'C-d') + edit.run_after_keychord(Editor_state, 'C-d', 'd') check_eq(drawing.shapes[1].mode, 'deleted', 'shape:1') check_eq(drawing.shapes[2].mode, 'deleted', 'shape:2') -- wait for some time @@ -626,7 +626,7 @@ function test_delete_line_under_mouse_pointer() check_eq(drawing.shapes[2].mode, 'line', 'baseline/shape:2') -- hover on one of the lines and delete App.mouse_move(Editor_state.left+25, Editor_state.top+Drawing_padding_top+26) - edit.run_after_keychord(Editor_state, 'C-d') + edit.run_after_keychord(Editor_state, 'C-d', 'd') -- only that line is deleted check_eq(drawing.shapes[1].mode, 'deleted', 'shape:1') check_eq(drawing.shapes[2].mode, 'line', 'shape:2') @@ -657,7 +657,7 @@ function test_delete_point_from_polygon() check_eq(#drawing.shapes[1].vertices, 4, 'baseline/vertices') -- hover on a point and delete App.mouse_move(Editor_state.left+35, Editor_state.top+Drawing_padding_top+26) - edit.run_after_keychord(Editor_state, 'C-d') + edit.run_after_keychord(Editor_state, 'C-d', 'd') -- just the one point is deleted check_eq(drawing.shapes[1].mode, 'polygon', 'shape') check_eq(#drawing.shapes[1].vertices, 3, 'vertices') @@ -685,7 +685,7 @@ function test_delete_point_from_polygon() check_eq(#drawing.shapes[1].vertices, 3, 'baseline/vertices') -- hover on a point and delete App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'C-d') + edit.run_after_keychord(Editor_state, 'C-d', 'd') -- there's < 3 points left, so the whole polygon is deleted check_eq(drawing.shapes[1].mode, 'deleted', 'check') end @@ -716,15 +716,15 @@ function test_undo_name_point() check_eq(#Editor_state.history, 1, 'baseline/history:1') --? print('a', Editor_state.lines.current_drawing) -- enter 'name' mode without moving the mouse - edit.run_after_keychord(Editor_state, 'C-n') + edit.run_after_keychord(Editor_state, 'C-n', 'n') edit.run_after_text_input(Editor_state, 'A') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(p2.name, 'A', 'baseline') check_eq(#Editor_state.history, 3, 'baseline/history:2') check_eq(Editor_state.next_history, 4, 'baseline/next_history') --? print('b', Editor_state.lines.current_drawing) -- undo - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') local drawing = Editor_state.lines[1] local p2 = drawing.points[drawing.shapes[1].p2] check_eq(Editor_state.next_history, 3, 'next_history') @@ -762,7 +762,7 @@ function test_undo_move_point() check_eq(p2.y, 36, 'baseline/p2:y') check_nil(p2.name, 'baseline/p2:name') -- move p2 - edit.run_after_keychord(Editor_state, 'C-u') + edit.run_after_keychord(Editor_state, 'C-u', 'u') App.mouse_move(Editor_state.left+26, Editor_state.top+Drawing_padding_top+44) edit.update(Editor_state, 0.05) local p2 = drawing.points[drawing.shapes[1].p2] @@ -772,8 +772,8 @@ function test_undo_move_point() edit.run_after_mouse_click(Editor_state, Editor_state.left+26, Editor_state.top+Drawing_padding_top+44, 1) check_eq(Editor_state.next_history, 4, 'next_history') -- undo - edit.run_after_keychord(Editor_state, 'C-z') - edit.run_after_keychord(Editor_state, 'C-z') -- bug: need to undo twice + edit.run_after_keychord(Editor_state, 'C-z', 'z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') -- bug: need to undo twice local drawing = Editor_state.lines[1] local p2 = drawing.points[drawing.shapes[1].p2] check_eq(Editor_state.next_history, 2, 'next_history') @@ -809,11 +809,11 @@ function test_undo_delete_point() check_eq(drawing.shapes[2].mode, 'line', 'baseline/shape:2') -- hover on the common point and delete App.mouse_move(Editor_state.left+35, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'C-d') + edit.run_after_keychord(Editor_state, 'C-d', 'd') check_eq(drawing.shapes[1].mode, 'deleted', 'shape:1') check_eq(drawing.shapes[2].mode, 'deleted', 'shape:2') -- undo - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') local drawing = Editor_state.lines[1] local p2 = drawing.points[drawing.shapes[1].p2] check_eq(Editor_state.next_history, 3, 'next_history') diff --git a/edit.lua b/edit.lua index ba6acda..70f3950 100644 --- a/edit.lua +++ b/edit.lua @@ -584,9 +584,9 @@ function edit.run_after_text_input(State, t) end -- not all keys are text_input -function edit.run_after_keychord(State, chord) - edit.keychord_press(State, chord) - edit.key_release(State, chord) +function edit.run_after_keychord(State, chord, key) + edit.keychord_press(State, chord, key) + edit.key_release(State, key) App.screen.contents = {} edit.update(State, 0) edit.draw(State) diff --git a/source_tests.lua b/source_tests.lua index e3264bb..f406c0b 100644 --- a/source_tests.lua +++ b/source_tests.lua @@ -29,7 +29,7 @@ function test_show_log_browser_side() check(not Show_log_browser_side, 'baseline') -- pressing ctrl+l shows log-browser side Current_time = Current_time + 0.1 - App.run_after_keychord('C-l') + App.run_after_keychord('C-l', 'l') check(Show_log_browser_side, 'check') end @@ -51,7 +51,7 @@ function test_show_log_browser_side_splits_window_width() log_browser.parse(Log_browser_state) -- display log browser Current_time = Current_time + 0.1 - App.run_after_keychord('C-l') + App.run_after_keychord('C-l', 'l') -- margins are now adjusted check_eq(Editor_state.left, Margin_left, 'edit:left') check_eq(Editor_state.right, App.screen.width/2 - Margin_right, 'edit:right') diff --git a/source_text_tests.lua b/source_text_tests.lua index 0d2eb48..c0edeab 100644 --- a/source_text_tests.lua +++ b/source_text_tests.lua @@ -36,7 +36,7 @@ function test_backspace_to_delete_drawing() -- cursor is on text as always (outside tests this will get initialized correctly) Editor_state.cursor1.line = 2 -- backspacing deletes the drawing - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(#Editor_state.lines, 1, '#lines') check_eq(Editor_state.cursor1.line, 1, 'cursor') end @@ -50,7 +50,7 @@ function test_backspace_from_start_of_final_line() Editor_state.cursor1 = {line=2, pos=1} Text.redraw_all(Editor_state) -- backspace scrolls up - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(#Editor_state.lines, 1, '#lines') check_eq(Editor_state.cursor1.line, 1, 'cursor') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') @@ -76,7 +76,7 @@ function test_press_ctrl() Editor_state.cursor1 = {line=1, pos=1} Editor_state.screen_top1 = {line=1, pos=1} Editor_state.screen_bottom1 = {} - edit.run_after_keychord(Editor_state, 'C-m') + edit.run_after_keychord(Editor_state, 'C-m', 'm') end function test_move_left() @@ -86,7 +86,7 @@ function test_move_left() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=2} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'left') + edit.run_after_keychord(Editor_state, 'left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -97,7 +97,7 @@ function test_move_right() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') check_eq(Editor_state.cursor1.pos, 2, 'check') end @@ -108,7 +108,7 @@ function test_move_left_to_previous_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=2, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'left') + edit.run_after_keychord(Editor_state, 'left', 'left') check_eq(Editor_state.cursor1.line, 1, 'line') check_eq(Editor_state.cursor1.pos, 4, 'pos') -- past end of line end @@ -120,7 +120,7 @@ function test_move_right_to_next_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- past end of line edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') check_eq(Editor_state.cursor1.line, 2, 'line') check_eq(Editor_state.cursor1.pos, 1, 'pos') end @@ -132,7 +132,7 @@ function test_move_to_start_of_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=3} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -143,7 +143,7 @@ function test_move_to_start_of_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- at the space between words edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -154,7 +154,7 @@ function test_skip_to_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=5} -- at the start of second word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -165,7 +165,7 @@ function test_skip_past_tab_to_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=10} -- within third word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 9, 'check') end @@ -176,7 +176,7 @@ function test_skip_multiple_spaces_to_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=6} -- at the start of second word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -187,7 +187,7 @@ function test_move_to_start_of_word_on_previous_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=2, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.line, 1, 'line') check_eq(Editor_state.cursor1.pos, 5, 'pos') end @@ -199,7 +199,7 @@ function test_move_past_end_of_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 4, 'check') end @@ -210,7 +210,7 @@ function test_skip_to_next_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- at the space between words edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 8, 'check') end @@ -221,7 +221,7 @@ function test_skip_past_tab_to_next_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=1} -- at the space between words edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 4, 'check') end @@ -232,7 +232,7 @@ function test_skip_multiple_spaces_to_next_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- at the start of second word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 9, 'check') end @@ -243,7 +243,7 @@ function test_move_past_end_of_word_on_next_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=8} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.line, 2, 'line') check_eq(Editor_state.cursor1.pos, 4, 'pos') end @@ -592,7 +592,7 @@ function test_select_text() edit.draw(Editor_state) -- select a letter App.fake_key_press('lshift') - edit.run_after_keychord(Editor_state, 'S-right') + edit.run_after_keychord(Editor_state, 'S-right', 'right') App.fake_key_release('lshift') edit.key_release(Editor_state, 'lshift') -- selection persists even after shift is released @@ -614,7 +614,7 @@ function test_cursor_movement_without_shift_resets_selection() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- press an arrow key without shift - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') -- no change to data, selection is reset check_nil(Editor_state.selection1.line, 'check') check_eq(Editor_state.lines[1].data, 'abc', 'data') @@ -671,7 +671,7 @@ function test_copy_does_not_reset_selection() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- copy selection - edit.run_after_keychord(Editor_state, 'C-c') + edit.run_after_keychord(Editor_state, 'C-c', 'c') check_eq(App.clipboard, 'a', 'clipboard') -- selection is reset since shift key is not pressed check(Editor_state.selection1.line, 'check') @@ -689,7 +689,7 @@ function test_cut() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- press a key - edit.run_after_keychord(Editor_state, 'C-x') + edit.run_after_keychord(Editor_state, 'C-x', 'x') check_eq(App.clipboard, 'a', 'clipboard') -- selected text is deleted check_eq(Editor_state.lines[1].data, 'bc', 'data') @@ -709,7 +709,7 @@ function test_paste_replaces_selection() -- set clipboard App.clipboard = 'xyz' -- paste selection - edit.run_after_keychord(Editor_state, 'C-v') + edit.run_after_keychord(Editor_state, 'C-v', 'v') -- selection is reset since shift key is not pressed -- selection includes the newline, so it's also deleted check_eq(Editor_state.lines[1].data, 'xyzdef', 'check') @@ -734,7 +734,7 @@ function test_deleting_selection_may_scroll() -- set up a selection starting above the currently displayed page Editor_state.selection1 = {line=1, pos=2} -- delete selection - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') -- page scrolls up check_eq(Editor_state.screen_top1.line, 1, 'check') check_eq(Editor_state.lines[1].data, 'ahi', 'data') @@ -775,7 +775,7 @@ function test_insert_newline() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- hitting the enter key splits the line - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -797,7 +797,7 @@ function test_insert_newline_at_start_of_line() Editor_state.screen_top1 = {line=1, pos=1} Editor_state.screen_bottom1 = {} -- hitting the enter key splits the line - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') check_eq(Editor_state.lines[1].data, '', 'data:1') @@ -822,7 +822,7 @@ function test_insert_from_clipboard() App.screen.check(y, 'ghi', 'baseline/screen:3') -- paste some text including a newline, check that new line is created App.clipboard = 'xy\nz' - edit.run_after_keychord(Editor_state, 'C-v') + edit.run_after_keychord(Editor_state, 'C-v', 'v') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 2, 'cursor:pos') @@ -982,7 +982,7 @@ function test_select_all_text() edit.draw(Editor_state) -- select all App.fake_key_press('lctrl') - edit.run_after_keychord(Editor_state, 'C-a') + edit.run_after_keychord(Editor_state, 'C-a', 'a') App.fake_key_release('lctrl') edit.key_release(Editor_state, 'lctrl') -- selection @@ -1004,7 +1004,7 @@ function test_cut_without_selection() Editor_state.selection1 = {} edit.draw(Editor_state) -- try to cut without selecting text - edit.run_after_keychord(Editor_state, 'C-x') + edit.run_after_keychord(Editor_state, 'C-x', 'x') -- no crash check_nil(Editor_state.selection1.line, 'check') end @@ -1024,7 +1024,7 @@ function test_pagedown() y = y + Editor_state.line_height App.screen.check(y, 'def', 'baseline/screen:2') -- after pagedown the bottom line becomes the top - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor') y = Editor_state.top @@ -1055,7 +1055,7 @@ function test_pagedown_skips_drawings() App.screen.check(y, 'abc', 'baseline/screen:1') -- after pagedown the screen draws the drawing up top -- 15px margin + 10px margin + 25px drawing + 10px margin + 15px line3 = 75px < screen height 80px - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor') y = Editor_state.top + drawing_height @@ -1079,7 +1079,7 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- after pagedown we scroll down the very long wrapping line - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line') check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos') y = Editor_state.top @@ -1108,7 +1108,7 @@ function test_pagedown_never_moves_up() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- pagedown makes no change - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line') check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos') end @@ -1130,7 +1130,7 @@ function test_down_arrow_moves_cursor() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the down arrow, the cursor moves down by 1 line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor') -- the screen is unchanged @@ -1163,7 +1163,7 @@ function test_down_arrow_skips_drawing() App.screen.check(y, 'ghi', 'baseline/screen:3') check(Editor_state.cursor_x, 'baseline/cursor_x') -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.cursor1.line, 3, 'cursor') end @@ -1184,7 +1184,7 @@ function test_down_arrow_scrolls_down_by_one_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the down arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 4, 'cursor') y = Editor_state.top @@ -1212,7 +1212,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the down arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') @@ -1241,7 +1241,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_ y = y + Editor_state.line_height App.screen.check(y, 'ghij', 'baseline/screen:3') -- after hitting the down arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') @@ -1269,12 +1269,12 @@ function test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up() y = y + Editor_state.line_height App.screen.check(y, 'ghij', 'baseline/screen:3') -- after hitting pagedown the screen scrolls down to start of a long line - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 3, 'baseline2/screen_top') check_eq(Editor_state.cursor1.line, 3, 'baseline2/cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'baseline2/cursor:pos') -- after hitting down arrow the screen doesn't scroll down further, and certainly doesn't scroll up - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 3, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') @@ -1303,7 +1303,7 @@ function test_up_arrow_moves_cursor() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the up arrow the cursor moves up by 1 line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor') -- the screen is unchanged @@ -1336,7 +1336,7 @@ function test_up_arrow_skips_drawing() App.screen.check(y, 'ghi', 'baseline/screen:3') check(Editor_state.cursor_x, 'baseline/cursor_x') -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.cursor1.line, 1, 'cursor') end @@ -1357,7 +1357,7 @@ function test_up_arrow_scrolls_up_by_one_line() y = y + Editor_state.line_height App.screen.check(y, 'jkl', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up by one line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1385,7 +1385,7 @@ function test_up_arrow_scrolls_up_by_one_line_skipping_drawing() y = y + Editor_state.line_height App.screen.check(y, 'jkl', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up to previous text line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') end @@ -1405,7 +1405,7 @@ function test_up_arrow_scrolls_up_by_one_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting the up arrow the screen scrolls up to first screen line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') y = Editor_state.top App.screen.check(y, 'ghi ', 'screen:1') y = y + Editor_state.line_height @@ -1435,7 +1435,7 @@ function test_up_arrow_scrolls_up_to_final_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up to final screen line of previous line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') y = Editor_state.top App.screen.check(y, 'def', 'screen:1') y = y + Editor_state.line_height @@ -1465,7 +1465,7 @@ function test_up_arrow_scrolls_up_to_empty_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up by one line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1491,7 +1491,7 @@ function test_pageup() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:2') -- after pageup the cursor goes to first line - edit.run_after_keychord(Editor_state, 'pageup') + edit.run_after_keychord(Editor_state, 'pageup', 'pageup') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1517,7 +1517,7 @@ function test_pageup_scrolls_up_by_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the page-up key the screen scrolls up to top - edit.run_after_keychord(Editor_state, 'pageup') + edit.run_after_keychord(Editor_state, 'pageup', 'pageup') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1544,7 +1544,7 @@ function test_pageup_scrolls_up_from_middle_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the page-up key the screen scrolls up to top - edit.run_after_keychord(Editor_state, 'pageup') + edit.run_after_keychord(Editor_state, 'pageup', 'pageup') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1573,7 +1573,7 @@ function test_enter_on_bottom_line_scrolls_down() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the enter key the screen scrolls down - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 4, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1598,7 +1598,7 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom() local y = Editor_state.top App.screen.check(y, 'jkl', 'baseline/screen:1') -- after hitting the enter key the screen does not scroll down - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.screen_top1.line, 4, 'screen_top') check_eq(Editor_state.cursor1.line, 5, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1674,7 +1674,7 @@ function test_left_arrow_scrolls_up_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting the left arrow the screen scrolls up to first screen line - edit.run_after_keychord(Editor_state, 'left') + edit.run_after_keychord(Editor_state, 'left', 'left') y = Editor_state.top App.screen.check(y, 'ghi ', 'screen:1') y = y + Editor_state.line_height @@ -1705,7 +1705,7 @@ function test_right_arrow_scrolls_down_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the right arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 6, 'cursor:pos') @@ -1733,7 +1733,7 @@ function test_home_scrolls_up_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting home the screen scrolls up to first screen line - edit.run_after_keychord(Editor_state, 'home') + edit.run_after_keychord(Editor_state, 'home', 'home') y = Editor_state.top App.screen.check(y, 'ghi ', 'screen:1') y = y + Editor_state.line_height @@ -1764,7 +1764,7 @@ function test_end_scrolls_down_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting end the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'end') + edit.run_after_keychord(Editor_state, 'end', 'end') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 8, 'cursor:pos') @@ -1827,7 +1827,7 @@ function test_backspace_can_scroll_up() y = y + Editor_state.line_height App.screen.check(y, 'jkl', 'baseline/screen:3') -- after hitting backspace the screen scrolls up by one line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1853,7 +1853,7 @@ function test_backspace_can_scroll_up_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting backspace the screen scrolls up by one screen line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') y = Editor_state.top App.screen.check(y, 'ghij', 'screen:1') y = y + Editor_state.line_height @@ -1874,7 +1874,7 @@ function test_backspace_past_line_boundary() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=2, pos=1} -- backspace joins with previous line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'abcdef', 'check') end @@ -1890,7 +1890,7 @@ function test_backspace_over_selection() Editor_state.cursor1 = {line=1, pos=1} Editor_state.selection1 = {line=1, pos=2} -- backspace deletes the selected character, even though it's after the cursor - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'bc', 'data') -- cursor (remains) at start of selection check_eq(Editor_state.cursor1.line, 1, 'cursor:line') @@ -1908,7 +1908,7 @@ function test_backspace_over_selection_reverse() Editor_state.cursor1 = {line=1, pos=2} Editor_state.selection1 = {line=1, pos=1} -- backspace deletes the selected character - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'bc', 'data') -- cursor moves to start of selection check_eq(Editor_state.cursor1.line, 1, 'cursor:line') @@ -1926,7 +1926,7 @@ function test_backspace_over_multiple_lines() Editor_state.cursor1 = {line=1, pos=2} Editor_state.selection1 = {line=4, pos=2} -- backspace deletes the region and joins the remaining portions of lines on either side - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'akl', 'data:1') check_eq(Editor_state.lines[2].data, 'mno', 'data:2') -- cursor remains at start of selection @@ -1945,7 +1945,7 @@ function test_backspace_to_end_of_line() Editor_state.cursor1 = {line=1, pos=2} Editor_state.selection1 = {line=1, pos=4} -- backspace deletes rest of line without joining to any other line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'a', 'data:1') check_eq(Editor_state.lines[2].data, 'def', 'data:2') -- cursor remains at start of selection @@ -1964,7 +1964,7 @@ function test_backspace_to_start_of_line() Editor_state.cursor1 = {line=2, pos=1} Editor_state.selection1 = {line=2, pos=3} -- backspace deletes beginning of line without joining to any other line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'abc', 'data:1') check_eq(Editor_state.lines[2].data, 'f', 'data:2') -- cursor remains at start of selection @@ -1996,7 +1996,7 @@ function test_undo_insert_text() y = y + Editor_state.line_height App.screen.check(y, 'xyz', 'baseline/screen:3') -- undo - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 4, 'cursor:pos') check_nil(Editor_state.selection1.line, 'selection:line') @@ -2018,7 +2018,7 @@ function test_undo_delete_text() Editor_state.screen_top1 = {line=1, pos=1} Editor_state.screen_bottom1 = {} -- delete a character - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.cursor1.line, 2, 'baseline/cursor:line') check_eq(Editor_state.cursor1.pos, 4, 'baseline/cursor:pos') check_nil(Editor_state.selection1.line, 'baseline/selection:line') @@ -2031,7 +2031,7 @@ function test_undo_delete_text() App.screen.check(y, 'xyz', 'baseline/screen:3') -- undo --? -- after undo, the backspaced key is selected - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') check_nil(Editor_state.selection1.line, 'selection:line') @@ -2062,8 +2062,8 @@ function test_undo_restores_selection() check_eq(Editor_state.lines[1].data, 'xbc', 'baseline') check_nil(Editor_state.selection1.line, 'baseline:selection') -- undo - edit.run_after_keychord(Editor_state, 'C-z') - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') -- selection is restored check_eq(Editor_state.selection1.line, 1, 'line') check_eq(Editor_state.selection1.pos, 2, 'pos') @@ -2079,19 +2079,19 @@ function test_search() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'd') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.cursor1.line, 2, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 1, '1/cursor:pos') -- reset cursor Editor_state.cursor1 = {line=1, pos=1} Editor_state.screen_top1 = {line=1, pos=1} -- search for second occurrence - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'de') - edit.run_after_keychord(Editor_state, 'down') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'down', 'down') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.cursor1.line, 4, '2/cursor:line') check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos') end @@ -2106,10 +2106,10 @@ function test_search_upwards() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'a') -- search for previous occurrence - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.cursor1.line, 1, '2/cursor:line') check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos') end @@ -2124,9 +2124,9 @@ function test_search_wrap() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'a') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') -- cursor wraps check_eq(Editor_state.cursor1.line, 1, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 2, '1/cursor:pos') @@ -2142,9 +2142,9 @@ function test_search_wrap_upwards() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search upwards for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'a') - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') -- cursor wraps check_eq(Editor_state.cursor1.line, 1, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 6, '1/cursor:pos') diff --git a/text_tests.lua b/text_tests.lua index 430733a..ae3d94d 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -36,7 +36,7 @@ function test_backspace_to_delete_drawing() -- cursor is on text as always (outside tests this will get initialized correctly) Editor_state.cursor1.line = 2 -- backspacing deletes the drawing - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(#Editor_state.lines, 1, '#lines') check_eq(Editor_state.cursor1.line, 1, 'cursor') end @@ -50,7 +50,7 @@ function test_backspace_from_start_of_final_line() Editor_state.cursor1 = {line=2, pos=1} Text.redraw_all(Editor_state) -- backspace scrolls up - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(#Editor_state.lines, 1, '#lines') check_eq(Editor_state.cursor1.line, 1, 'cursor') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') @@ -76,7 +76,7 @@ function test_press_ctrl() Editor_state.cursor1 = {line=1, pos=1} Editor_state.screen_top1 = {line=1, pos=1} Editor_state.screen_bottom1 = {} - edit.run_after_keychord(Editor_state, 'C-m') + edit.run_after_keychord(Editor_state, 'C-m', 'm') end function test_move_left() @@ -86,7 +86,7 @@ function test_move_left() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=2} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'left') + edit.run_after_keychord(Editor_state, 'left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -97,7 +97,7 @@ function test_move_right() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') check_eq(Editor_state.cursor1.pos, 2, 'check') end @@ -108,7 +108,7 @@ function test_move_left_to_previous_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=2, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'left') + edit.run_after_keychord(Editor_state, 'left', 'left') check_eq(Editor_state.cursor1.line, 1, 'line') check_eq(Editor_state.cursor1.pos, 4, 'pos') -- past end of line end @@ -120,7 +120,7 @@ function test_move_right_to_next_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- past end of line edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') check_eq(Editor_state.cursor1.line, 2, 'line') check_eq(Editor_state.cursor1.pos, 1, 'pos') end @@ -132,7 +132,7 @@ function test_move_to_start_of_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=3} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -143,7 +143,7 @@ function test_move_to_start_of_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- at the space between words edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -154,7 +154,7 @@ function test_skip_to_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=5} -- at the start of second word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -165,7 +165,7 @@ function test_skip_past_tab_to_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=10} -- within third word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 9, 'check') end @@ -176,7 +176,7 @@ function test_skip_multiple_spaces_to_previous_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=6} -- at the start of second word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.pos, 1, 'check') end @@ -187,7 +187,7 @@ function test_move_to_start_of_word_on_previous_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=2, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-left') + edit.run_after_keychord(Editor_state, 'M-left', 'left') check_eq(Editor_state.cursor1.line, 1, 'line') check_eq(Editor_state.cursor1.pos, 5, 'pos') end @@ -199,7 +199,7 @@ function test_move_past_end_of_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=1} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 4, 'check') end @@ -210,7 +210,7 @@ function test_skip_to_next_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- at the space between words edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 8, 'check') end @@ -221,7 +221,7 @@ function test_skip_past_tab_to_next_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=1} -- at the space between words edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 4, 'check') end @@ -232,7 +232,7 @@ function test_skip_multiple_spaces_to_next_word() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=4} -- at the start of second word edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.pos, 9, 'check') end @@ -243,7 +243,7 @@ function test_move_past_end_of_word_on_next_line() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=1, pos=8} edit.draw(Editor_state) - edit.run_after_keychord(Editor_state, 'M-right') + edit.run_after_keychord(Editor_state, 'M-right', 'right') check_eq(Editor_state.cursor1.line, 2, 'line') check_eq(Editor_state.cursor1.pos, 4, 'pos') end @@ -592,7 +592,7 @@ function test_select_text() edit.draw(Editor_state) -- select a letter App.fake_key_press('lshift') - edit.run_after_keychord(Editor_state, 'S-right') + edit.run_after_keychord(Editor_state, 'S-right', 'right') App.fake_key_release('lshift') edit.key_release(Editor_state, 'lshift') -- selection persists even after shift is released @@ -614,7 +614,7 @@ function test_cursor_movement_without_shift_resets_selection() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- press an arrow key without shift - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') -- no change to data, selection is reset check_nil(Editor_state.selection1.line, 'check') check_eq(Editor_state.lines[1].data, 'abc', 'data') @@ -671,7 +671,7 @@ function test_copy_does_not_reset_selection() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- copy selection - edit.run_after_keychord(Editor_state, 'C-c') + edit.run_after_keychord(Editor_state, 'C-c', 'c') check_eq(App.clipboard, 'a', 'clipboard') -- selection is reset since shift key is not pressed check(Editor_state.selection1.line, 'check') @@ -689,7 +689,7 @@ function test_cut() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- press a key - edit.run_after_keychord(Editor_state, 'C-x') + edit.run_after_keychord(Editor_state, 'C-x', 'x') check_eq(App.clipboard, 'a', 'clipboard') -- selected text is deleted check_eq(Editor_state.lines[1].data, 'bc', 'data') @@ -709,7 +709,7 @@ function test_paste_replaces_selection() -- set clipboard App.clipboard = 'xyz' -- paste selection - edit.run_after_keychord(Editor_state, 'C-v') + edit.run_after_keychord(Editor_state, 'C-v', 'v') -- selection is reset since shift key is not pressed -- selection includes the newline, so it's also deleted check_eq(Editor_state.lines[1].data, 'xyzdef', 'check') @@ -734,7 +734,7 @@ function test_deleting_selection_may_scroll() -- set up a selection starting above the currently displayed page Editor_state.selection1 = {line=1, pos=2} -- delete selection - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') -- page scrolls up check_eq(Editor_state.screen_top1.line, 1, 'check') check_eq(Editor_state.lines[1].data, 'ahi', 'data') @@ -775,7 +775,7 @@ function test_insert_newline() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- hitting the enter key splits the line - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -797,7 +797,7 @@ function test_insert_newline_at_start_of_line() Editor_state.screen_top1 = {line=1, pos=1} Editor_state.screen_bottom1 = {} -- hitting the enter key splits the line - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') check_eq(Editor_state.lines[1].data, '', 'data:1') @@ -822,7 +822,7 @@ function test_insert_from_clipboard() App.screen.check(y, 'ghi', 'baseline/screen:3') -- paste some text including a newline, check that new line is created App.clipboard = 'xy\nz' - edit.run_after_keychord(Editor_state, 'C-v') + edit.run_after_keychord(Editor_state, 'C-v', 'v') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 2, 'cursor:pos') @@ -982,7 +982,7 @@ function test_select_all_text() edit.draw(Editor_state) -- select all App.fake_key_press('lctrl') - edit.run_after_keychord(Editor_state, 'C-a') + edit.run_after_keychord(Editor_state, 'C-a', 'a') App.fake_key_release('lctrl') edit.key_release(Editor_state, 'lctrl') -- selection @@ -1004,7 +1004,7 @@ function test_cut_without_selection() Editor_state.selection1 = {} edit.draw(Editor_state) -- try to cut without selecting text - edit.run_after_keychord(Editor_state, 'C-x') + edit.run_after_keychord(Editor_state, 'C-x', 'x') -- no crash check_nil(Editor_state.selection1.line, 'check') end @@ -1024,7 +1024,7 @@ function test_pagedown() y = y + Editor_state.line_height App.screen.check(y, 'def', 'baseline/screen:2') -- after pagedown the bottom line becomes the top - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor') y = Editor_state.top @@ -1055,7 +1055,7 @@ function test_pagedown_skips_drawings() App.screen.check(y, 'abc', 'baseline/screen:1') -- after pagedown the screen draws the drawing up top -- 15px margin + 10px margin + 25px drawing + 10px margin + 15px line3 = 75px < screen height 80px - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor') y = Editor_state.top + drawing_height @@ -1079,7 +1079,7 @@ function test_pagedown_often_shows_start_of_wrapping_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- after pagedown we start drawing from the bottom _line_ (multiple screen lines) - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 2, 'screen_top:line') check_eq(Editor_state.screen_top1.pos, 1, 'screen_top:pos') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') @@ -1109,7 +1109,7 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- after pagedown we scroll down the very long wrapping line - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line') check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos') y = Editor_state.top @@ -1138,7 +1138,7 @@ function test_pagedown_never_moves_up() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- pagedown makes no change - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line') check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos') end @@ -1160,7 +1160,7 @@ function test_down_arrow_moves_cursor() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the down arrow, the cursor moves down by 1 line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor') -- the screen is unchanged @@ -1193,7 +1193,7 @@ function test_down_arrow_skips_drawing() App.screen.check(y, 'ghi', 'baseline/screen:3') check(Editor_state.cursor_x, 'baseline/cursor_x') -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.cursor1.line, 3, 'cursor') end @@ -1214,7 +1214,7 @@ function test_down_arrow_scrolls_down_by_one_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the down arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 4, 'cursor') y = Editor_state.top @@ -1242,7 +1242,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the down arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') @@ -1271,7 +1271,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_ y = y + Editor_state.line_height App.screen.check(y, 'ghij', 'baseline/screen:3') -- after hitting the down arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') @@ -1299,12 +1299,12 @@ function test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up() y = y + Editor_state.line_height App.screen.check(y, 'ghij', 'baseline/screen:3') -- after hitting pagedown the screen scrolls down to start of a long line - edit.run_after_keychord(Editor_state, 'pagedown') + edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown') check_eq(Editor_state.screen_top1.line, 3, 'baseline2/screen_top') check_eq(Editor_state.cursor1.line, 3, 'baseline2/cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'baseline2/cursor:pos') -- after hitting down arrow the screen doesn't scroll down further, and certainly doesn't scroll up - edit.run_after_keychord(Editor_state, 'down') + edit.run_after_keychord(Editor_state, 'down', 'down') check_eq(Editor_state.screen_top1.line, 3, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') @@ -1333,7 +1333,7 @@ function test_up_arrow_moves_cursor() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the up arrow the cursor moves up by 1 line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 2, 'cursor') -- the screen is unchanged @@ -1366,7 +1366,7 @@ function test_up_arrow_skips_drawing() App.screen.check(y, 'ghi', 'baseline/screen:3') check(Editor_state.cursor_x, 'baseline/cursor_x') -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.cursor1.line, 1, 'cursor') end @@ -1387,7 +1387,7 @@ function test_up_arrow_scrolls_up_by_one_line() y = y + Editor_state.line_height App.screen.check(y, 'jkl', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up by one line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1415,7 +1415,7 @@ function test_up_arrow_scrolls_up_by_one_line_skipping_drawing() y = y + Editor_state.line_height App.screen.check(y, 'jkl', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up to previous text line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') end @@ -1435,7 +1435,7 @@ function test_up_arrow_scrolls_up_by_one_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting the up arrow the screen scrolls up to first screen line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') y = Editor_state.top App.screen.check(y, 'ghi ', 'screen:1') y = y + Editor_state.line_height @@ -1465,7 +1465,7 @@ function test_up_arrow_scrolls_up_to_final_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up to final screen line of previous line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') y = Editor_state.top App.screen.check(y, 'def', 'screen:1') y = y + Editor_state.line_height @@ -1495,7 +1495,7 @@ function test_up_arrow_scrolls_up_to_empty_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the up arrow the screen scrolls up by one line - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1521,7 +1521,7 @@ function test_pageup() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:2') -- after pageup the cursor goes to first line - edit.run_after_keychord(Editor_state, 'pageup') + edit.run_after_keychord(Editor_state, 'pageup', 'pageup') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1547,7 +1547,7 @@ function test_pageup_scrolls_up_by_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the page-up key the screen scrolls up to top - edit.run_after_keychord(Editor_state, 'pageup') + edit.run_after_keychord(Editor_state, 'pageup', 'pageup') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1574,7 +1574,7 @@ function test_pageup_scrolls_up_from_middle_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the page-up key the screen scrolls up to top - edit.run_after_keychord(Editor_state, 'pageup') + edit.run_after_keychord(Editor_state, 'pageup', 'pageup') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1603,7 +1603,7 @@ function test_enter_on_bottom_line_scrolls_down() y = y + Editor_state.line_height App.screen.check(y, 'ghi', 'baseline/screen:3') -- after hitting the enter key the screen scrolls down - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 4, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1628,7 +1628,7 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom() local y = Editor_state.top App.screen.check(y, 'jkl', 'baseline/screen:1') -- after hitting the enter key the screen does not scroll down - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.screen_top1.line, 4, 'screen_top') check_eq(Editor_state.cursor1.line, 5, 'cursor:line') check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos') @@ -1704,7 +1704,7 @@ function test_left_arrow_scrolls_up_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting the left arrow the screen scrolls up to first screen line - edit.run_after_keychord(Editor_state, 'left') + edit.run_after_keychord(Editor_state, 'left', 'left') y = Editor_state.top App.screen.check(y, 'ghi ', 'screen:1') y = y + Editor_state.line_height @@ -1735,7 +1735,7 @@ function test_right_arrow_scrolls_down_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting the right arrow the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'right') + edit.run_after_keychord(Editor_state, 'right', 'right') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 6, 'cursor:pos') @@ -1763,7 +1763,7 @@ function test_home_scrolls_up_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting home the screen scrolls up to first screen line - edit.run_after_keychord(Editor_state, 'home') + edit.run_after_keychord(Editor_state, 'home', 'home') y = Editor_state.top App.screen.check(y, 'ghi ', 'screen:1') y = y + Editor_state.line_height @@ -1794,7 +1794,7 @@ function test_end_scrolls_down_in_wrapped_line() y = y + Editor_state.line_height App.screen.check(y, 'ghi ', 'baseline/screen:3') -- line wrapping includes trailing whitespace -- after hitting end the screen scrolls down by one line - edit.run_after_keychord(Editor_state, 'end') + edit.run_after_keychord(Editor_state, 'end', 'end') check_eq(Editor_state.screen_top1.line, 2, 'screen_top') check_eq(Editor_state.cursor1.line, 3, 'cursor:line') check_eq(Editor_state.cursor1.pos, 8, 'cursor:pos') @@ -1857,7 +1857,7 @@ function test_backspace_can_scroll_up() y = y + Editor_state.line_height App.screen.check(y, 'jkl', 'baseline/screen:3') -- after hitting backspace the screen scrolls up by one line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.screen_top1.line, 1, 'screen_top') check_eq(Editor_state.cursor1.line, 1, 'cursor') y = Editor_state.top @@ -1883,7 +1883,7 @@ function test_backspace_can_scroll_up_screen_line() y = y + Editor_state.line_height App.screen.check(y, 'mno', 'baseline/screen:2') -- after hitting backspace the screen scrolls up by one screen line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') y = Editor_state.top App.screen.check(y, 'ghij', 'screen:1') y = y + Editor_state.line_height @@ -1904,7 +1904,7 @@ function test_backspace_past_line_boundary() Text.redraw_all(Editor_state) Editor_state.cursor1 = {line=2, pos=1} -- backspace joins with previous line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'abcdef', 'check') end @@ -1920,7 +1920,7 @@ function test_backspace_over_selection() Editor_state.cursor1 = {line=1, pos=1} Editor_state.selection1 = {line=1, pos=2} -- backspace deletes the selected character, even though it's after the cursor - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'bc', 'data') -- cursor (remains) at start of selection check_eq(Editor_state.cursor1.line, 1, 'cursor:line') @@ -1938,7 +1938,7 @@ function test_backspace_over_selection_reverse() Editor_state.cursor1 = {line=1, pos=2} Editor_state.selection1 = {line=1, pos=1} -- backspace deletes the selected character - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'bc', 'data') -- cursor moves to start of selection check_eq(Editor_state.cursor1.line, 1, 'cursor:line') @@ -1956,7 +1956,7 @@ function test_backspace_over_multiple_lines() Editor_state.cursor1 = {line=1, pos=2} Editor_state.selection1 = {line=4, pos=2} -- backspace deletes the region and joins the remaining portions of lines on either side - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'akl', 'data:1') check_eq(Editor_state.lines[2].data, 'mno', 'data:2') -- cursor remains at start of selection @@ -1975,7 +1975,7 @@ function test_backspace_to_end_of_line() Editor_state.cursor1 = {line=1, pos=2} Editor_state.selection1 = {line=1, pos=4} -- backspace deletes rest of line without joining to any other line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'a', 'data:1') check_eq(Editor_state.lines[2].data, 'def', 'data:2') -- cursor remains at start of selection @@ -1994,7 +1994,7 @@ function test_backspace_to_start_of_line() Editor_state.cursor1 = {line=2, pos=1} Editor_state.selection1 = {line=2, pos=3} -- backspace deletes beginning of line without joining to any other line - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.lines[1].data, 'abc', 'data:1') check_eq(Editor_state.lines[2].data, 'f', 'data:2') -- cursor remains at start of selection @@ -2026,7 +2026,7 @@ function test_undo_insert_text() y = y + Editor_state.line_height App.screen.check(y, 'xyz', 'baseline/screen:3') -- undo - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 4, 'cursor:pos') check_nil(Editor_state.selection1.line, 'selection:line') @@ -2048,7 +2048,7 @@ function test_undo_delete_text() Editor_state.screen_top1 = {line=1, pos=1} Editor_state.screen_bottom1 = {} -- delete a character - edit.run_after_keychord(Editor_state, 'backspace') + edit.run_after_keychord(Editor_state, 'backspace', 'backspace') check_eq(Editor_state.cursor1.line, 2, 'baseline/cursor:line') check_eq(Editor_state.cursor1.pos, 4, 'baseline/cursor:pos') check_nil(Editor_state.selection1.line, 'baseline/selection:line') @@ -2061,7 +2061,7 @@ function test_undo_delete_text() App.screen.check(y, 'xyz', 'baseline/screen:3') -- undo --? -- after undo, the backspaced key is selected - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') check_eq(Editor_state.cursor1.line, 2, 'cursor:line') check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos') check_nil(Editor_state.selection1.line, 'selection:line') @@ -2092,8 +2092,8 @@ function test_undo_restores_selection() check_eq(Editor_state.lines[1].data, 'xbc', 'baseline') check_nil(Editor_state.selection1.line, 'baseline:selection') -- undo - edit.run_after_keychord(Editor_state, 'C-z') - edit.run_after_keychord(Editor_state, 'C-z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') + edit.run_after_keychord(Editor_state, 'C-z', 'z') -- selection is restored check_eq(Editor_state.selection1.line, 1, 'line') check_eq(Editor_state.selection1.pos, 2, 'pos') @@ -2109,19 +2109,19 @@ function test_search() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'd') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.cursor1.line, 2, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 1, '1/cursor:pos') -- reset cursor Editor_state.cursor1 = {line=1, pos=1} Editor_state.screen_top1 = {line=1, pos=1} -- search for second occurrence - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'de') - edit.run_after_keychord(Editor_state, 'down') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'down', 'down') + edit.run_after_keychord(Editor_state, 'return', 'return') check_eq(Editor_state.cursor1.line, 4, '2/cursor:line') check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos') end @@ -2136,10 +2136,10 @@ function test_search_upwards() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'a') -- search for previous occurrence - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') check_eq(Editor_state.cursor1.line, 1, '2/cursor:line') check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos') end @@ -2154,9 +2154,9 @@ function test_search_wrap() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'a') - edit.run_after_keychord(Editor_state, 'return') + edit.run_after_keychord(Editor_state, 'return', 'return') -- cursor wraps check_eq(Editor_state.cursor1.line, 1, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 2, '1/cursor:pos') @@ -2172,9 +2172,9 @@ function test_search_wrap_upwards() Editor_state.screen_bottom1 = {} edit.draw(Editor_state) -- search upwards for a string - edit.run_after_keychord(Editor_state, 'C-f') + edit.run_after_keychord(Editor_state, 'C-f', 'f') edit.run_after_text_input(Editor_state, 'a') - edit.run_after_keychord(Editor_state, 'up') + edit.run_after_keychord(Editor_state, 'up', 'up') -- cursor wraps check_eq(Editor_state.cursor1.line, 1, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 6, '1/cursor:pos') -- cgit 1.4.1-2-gfad0