about summary refs log tree commit diff stats
path: root/text_tests.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-04 14:14:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-04 14:54:40 -0700
commit1326914d7bda65a5791c2121dae6d3987a907994 (patch)
treeb8f47fd975f18540c62097e39cfb89fa3c5f4ddd /text_tests.lua
parent98f50f0b404b48bc38d95126939aefa6c3bea139 (diff)
downloadlines.love-1326914d7bda65a5791c2121dae6d3987a907994.tar.gz
select text with shift + mouseclick
It's still a bit simple-minded. Most software will keep the first bound
fixed and move the second. Lines currently has the bounds in a queue of
sorts. But I have a test to indicate the behavior that is definitely
desired. We'll see if we need it to get more complex.
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/text_tests.lua b/text_tests.lua
index 91b3b46..8272faf 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -159,11 +159,39 @@ function test_move_cursor_using_mouse()
   Cursor1 = {line=1, pos=1}
   Screen_top1 = {line=1, pos=1}
   Screen_bottom1 = {}
+  Selection1 = {}
   App.draw()  -- populate line.y for each line in Lines
   local screen_left_margin = 25  -- pixels
   App.run_after_mouserelease(screen_left_margin+8,Margin_top+5, '1')
   check_eq(Cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line')
   check_eq(Cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')
+  check_nil(Selection1.line, 'F - test_move_cursor_using_mouse/selection:line')
+  check_nil(Selection1.pos, 'F - test_move_cursor_using_mouse/selection:pos')
+end
+
+function test_select_text_using_mouse()
+  io.write('\ntest_select_text_using_mouse')
+  App.screen.init{width=50, height=60}
+  Lines = load_array{'abc', 'def', 'xyz'}
+  Line_width = App.screen.width
+  Cursor1 = {line=1, pos=1}
+  Screen_top1 = {line=1, pos=1}
+  Screen_bottom1 = {}
+  Selection1 = {}
+  App.draw()  -- populate line.y for each line in Lines
+  local screen_left_margin = 25  -- pixels
+  -- click on first location
+  App.run_after_mousepress(screen_left_margin+8,Margin_top+5, '1')
+  App.run_after_mouserelease(screen_left_margin+8,Margin_top+5, '1')
+  -- hold down shift and click somewhere else
+  App.keypress('lshift')
+  App.run_after_mousepress(screen_left_margin+20,Margin_top+5, '1')
+  App.run_after_mouserelease(screen_left_margin+20,Margin_top+Line_height+5, '1')
+  App.keyrelease('lshift')
+  check_eq(Cursor1.line, 2, 'F - test_select_text_using_mouse/cursor:line')
+  check_eq(Cursor1.pos, 4, 'F - test_select_text_using_mouse/cursor:pos')
+  check_eq(Selection1.line, 1, 'F - test_select_text_using_mouse/selection:line')
+  check_eq(Selection1.pos, 2, 'F - test_select_text_using_mouse/selection:pos')
 end
 
 function test_pagedown()