about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-12 15:39:11 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-12 15:41:17 -0700
commit92ad99853e8a38aa62e2246e372505ed0d1aff09 (patch)
tree66faad3437655fcdd738d052ef743e51428621f5 /edit.lua
parent81ecca89ff04988fa2117d8ecf4a94fce722c478 (diff)
downloadtext.love-92ad99853e8a38aa62e2246e372505ed0d1aff09.tar.gz
call edit rather than App callbacks in tests
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua43
1 files changed, 43 insertions, 0 deletions
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