From 92ad99853e8a38aa62e2246e372505ed0d1aff09 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 12 Jul 2022 15:39:11 -0700 Subject: call edit rather than App callbacks in tests --- edit.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'edit.lua') diff --git a/edit.lua b/edit.lua index d6f2646..86eacd5 100644 --- a/edit.lua +++ b/edit.lua @@ -440,3 +440,46 @@ end function edit.key_released(State, key, scancode) end + +--== copy some App methods for tests + +-- all textinput events are also keypresses +-- TODO: handle chords of multiple keys +function edit.run_after_textinput(State, t) + edit.keychord_pressed(State, t) + edit.textinput(State, t) + edit.key_released(State, t) + App.screen.contents = {} + edit.draw(State) +end + +-- not all keys are textinput +function edit.run_after_keychord(State, chord) + edit.keychord_pressed(State, chord) + edit.key_released(State, chord) + App.screen.contents = {} + edit.draw(State) +end + +function edit.run_after_mouse_click(State, x,y, button) + App.fake_mouse_press(x,y, button) + edit.mouse_pressed(State, x,y, button) + App.fake_mouse_release(x,y, button) + edit.mouse_released(State, x,y, button) + App.screen.contents = {} + edit.draw(State) +end + +function edit.run_after_mouse_press(State, x,y, button) + App.fake_mouse_press(x,y, button) + edit.mouse_pressed(State, x,y, button) + App.screen.contents = {} + edit.draw(State) +end + +function edit.run_after_mouse_release(State, x,y, button) + App.fake_mouse_release(x,y, button) + edit.mouse_released(State, x,y, button) + App.screen.contents = {} + edit.draw(State) +end -- cgit 1.4.1-2-gfad0