about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--app.lua9
-rw-r--r--text_tests.lua17
2 files changed, 26 insertions, 0 deletions
diff --git a/app.lua b/app.lua
index ae36495..20fd027 100644
--- a/app.lua
+++ b/app.lua
@@ -236,6 +236,15 @@ function App.run_after_keychord(key)
   App.draw()
 end
 
+function App.run_after_mouse_click(x,y, button)
+  App.fake_mouse_press(x,y, button)
+  App.mousepressed(x,y, button)
+  App.fake_mouse_release(x,y, button)
+  App.mousereleased(x,y, button)
+  App.screen.contents = {}
+  App.draw()
+end
+
 function App.run_after_mouse_press(x,y, button)
   App.fake_mouse_press(x,y, button)
   App.mousepressed(x,y, button)
diff --git a/text_tests.lua b/text_tests.lua
index 6b92153..440cec7 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -23,6 +23,23 @@ function test_press_ctrl()
   App.run_after_keychord('C-m')
 end
 
+function test_click_with_mouse()
+  io.write('\ntest_click')
+  -- display two lines with cursor on one of them
+  App.screen.init{width=50, height=80}
+  Lines = load_array{'abc', 'def'}
+  Line_width = App.screen.width
+  Cursor1 = {line=2, pos=1}
+  Screen_top1 = {line=1, pos=1}
+  Screen_bottom1 = {}
+  -- click on the other line
+  local screen_left_margin = 25  -- pixels
+  App.draw()
+  App.run_after_mouse_click(screen_left_margin+8,Margin_top+5, '1')
+  -- cursor moves
+  check_eq(Cursor1.line, 1, 'F - test_click/cursor')
+end
+
 function test_draw_text()
   io.write('\ntest_draw_text')
   App.screen.init{width=120, height=60}