edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'C-m', 'm')
edit.run_after_keychord(Editor_state, 'left', 'left')
edit.run_after_keychord(Editor_state, 'right', 'right')
edit.run_after_keychord(Editor_state, 'left', 'left')
edit.run_after_keychord(Editor_state, 'right', 'right')
edit.run_after_keychord(Editor_state, 'M-left', 'left')
edit.run_after_keychord(Editor_state, 'M-left', 'left')
edit.run_after_keychord(Editor_state, 'M-left', 'left')
edit.run_after_keychord(Editor_state, 'M-left', 'left')
edit.run_after_keychord(Editor_state, 'M-left', 'left')
edit.run_after_keychord(Editor_state, 'M-left', 'left')
edit.run_after_keychord(Editor_state, 'M-right', 'right')
edit.run_after_keychord(Editor_state, 'M-right', 'right')
edit.run_after_keychord(Editor_state, 'M-right', 'right')
edit.run_after_keychord(Editor_state, 'M-right', 'right')
edit.run_after_keychord(Editor_state, 'M-right', 'right')
edit.run_after_keychord(Editor_state, 'S-right', 'right')
edit.run_after_keychord(Editor_state, 'right', 'right')
edit.run_after_keychord(Editor_state, 'C-c', 'c')
edit.run_after_keychord(Editor_state, 'C-x', 'x')
edit.run_after_keychord(Editor_state, 'C-v', 'v')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'C-v', 'v')
edit.run_after_keychord(Editor_state, 'C-a', 'a')
edit.run_after_keychord(Editor_state, 'C-x', 'x')
edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'pageup', 'pageup')
edit.run_after_keychord(Editor_state, 'pageup', 'pageup')
edit.run_after_keychord(Editor_state, 'pageup', 'pageup')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'left', 'left')
edit.run_after_keychord(Editor_state, 'right', 'right')
edit.run_after_keychord(Editor_state, 'home', 'home')
edit.run_after_keychord(Editor_state, 'end', 'end')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'C-z', 'z')
edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
edit.run_after_keychord(Editor_state, 'C-z', 'z')
edit.run_after_keychord(Editor_state, 'C-z', 'z')
edit.run_after_keychord(Editor_state, 'C-z', 'z')
edit.run_after_keychord(Editor_state, 'C-f', 'f')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'C-f', 'f')
edit.run_after_keychord(Editor_state, 'down', 'down')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'C-f', 'f')
edit.run_after_keychord(Editor_state, 'up', 'up')
edit.run_after_keychord(Editor_state, 'C-f', 'f')
edit.run_after_keychord(Editor_state, 'return', 'return')
edit.run_after_keychord(Editor_state, 'C-f', 'f')
edit.run_after_keychord(Editor_state, 'up', 'up')
-- cursor wraps
edit.run_after_text_input(Editor_state, 'a')
-- cursor wraps
edit.run_after_text_input(Editor_state, 'a')
check_eq(Editor_state.cursor1.line, 1, '2/cursor:line')
edit.run_after_text_input(Editor_state, 'a')
check_eq(Editor_state.cursor1.line, 4, '2/cursor:line')
edit.run_after_text_input(Editor_state, 'de')
check_eq(Editor_state.cursor1.line, 2, '1/cursor:line')
check_eq(Editor_state.cursor1.pos, 1, '1/cursor:pos')
edit.run_after_text_input(Editor_state, 'd')
-- selection is restored
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')
check_nil(Editor_state.selection1.pos, 'selection:pos')
--? check_eq(Editor_state.selection1.line, 2, 'selection:line')
--? check_eq(Editor_state.selection1.pos, 4, 'selection:pos')
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')
check_nil(Editor_state.selection1.pos, 'baseline/selection:pos')
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')
check_nil(Editor_state.selection1.pos, 'selection:pos')
check_eq(Editor_state.lines[1].data, 'abc', 'data:1')
check_eq(Editor_state.lines[2].data, 'f', 'data:2')
check_eq(Editor_state.lines[1].data, 'a', 'data:1')
check_eq(Editor_state.lines[2].data, 'def', 'data:2')
check_eq(Editor_state.lines[1].data, 'akl', 'data:1')
check_eq(Editor_state.lines[2].data, 'mno', 'data:2')
check_eq(Editor_state.lines[1].data, 'bc', 'data')
check_eq(Editor_state.lines[1].data, 'bc', 'data')
check_eq(Editor_state.lines[1].data, 'abcdef', 'check')
y = Editor_state.top
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
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')
y = Editor_state.top
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')
y = Editor_state.top
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')
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')
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')
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')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
y = Editor_state.top
y = Editor_state.top
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
end
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 2, 'cursor')
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')
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')
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')
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')
check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
check_eq(Editor_state.cursor1.line, 4, 'cursor')
check_eq(Editor_state.cursor1.line, 3, 'cursor')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 2, 'cursor')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line')
check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line')
check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos')
check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
check_eq(Editor_state.cursor1.line, 3, 'cursor')
check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
check_eq(Editor_state.cursor1.line, 2, 'cursor')
-- no crash
App.fake_key_release('lctrl')
edit.key_release(Editor_state, 'lctrl')
-- selection
check_eq(Editor_state.selection1.line, 1, 'selection:line')
check_eq(Editor_state.selection1.pos, 1, 'selection:pos')
check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
check_eq(Editor_state.cursor1.pos, 8, 'cursor:pos')
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')
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')
check_eq(Editor_state.lines[2].data, 'abc', 'data:2')
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')
-- page scrolls up
-- selection is reset since shift key is not pressed
-- selection includes the newline, so it's also deleted
check_eq(App.clipboard, 'a', 'clipboard')
check_eq(App.clipboard, 'a', 'clipboard')
-- no change to data, selection is reset
App.fake_key_release('lshift')
check_eq(Editor_state.cursor1.line, 2, 'line')
check_eq(Editor_state.cursor1.pos, 4, 'pos')
check_eq(Editor_state.cursor1.pos, 9, 'check')
check_eq(Editor_state.cursor1.pos, 4, 'check')
check_eq(Editor_state.cursor1.pos, 8, 'check')
check_eq(Editor_state.cursor1.pos, 4, 'check')
check_eq(Editor_state.cursor1.line, 1, 'line')
check_eq(Editor_state.cursor1.pos, 5, 'pos')
check_eq(Editor_state.cursor1.pos, 1, 'check')
check_eq(Editor_state.cursor1.pos, 9, 'check')
check_eq(Editor_state.cursor1.pos, 1, 'check')
check_eq(Editor_state.cursor1.pos, 1, 'check')
check_eq(Editor_state.cursor1.pos, 1, 'check')
check_eq(Editor_state.cursor1.line, 2, 'line')
check_eq(Editor_state.cursor1.pos, 1, 'pos')
check_eq(Editor_state.cursor1.line, 1, 'line')
check_eq(Editor_state.cursor1.pos, 4, 'pos') -- past end of line
check_eq(Editor_state.cursor1.pos, 2, 'check')
check_eq(Editor_state.cursor1.pos, 1, 'check')
end
function test_move_left()
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')
check_eq(#Editor_state.lines, 1, '#lines')
check_eq(Editor_state.cursor1.line, 1, 'cursor')