about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-06 09:03:01 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-06 09:03:54 -0700
commitdff4587219221d00a15d8a6907583643d8127090 (patch)
tree2ad2447c165e7a2a089052acb8aa0c003741766e /main.lua
parent2973324ef6881c3828e6ebfce6c78b8835275b5b (diff)
downloadtext.love-dff4587219221d00a15d8a6907583643d8127090.tar.gz
just keep the cursor visible after any input events
This is much nicer.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/main.lua b/main.lua
index 8902b11..5a42309 100644
--- a/main.lua
+++ b/main.lua
@@ -333,6 +333,8 @@ end
 
 function App.mousepressed(x,y, mouse_button)
   if Search_term then return end
+  -- ensure cursor is visible immediately after it moves
+  Cursor_time = 0
 --?   print('press', Selection1.line, Selection1.pos)
   propagate_to_button_handlers(x,y, mouse_button)
 
@@ -370,6 +372,8 @@ end
 function App.mousereleased(x,y, button)
   if Search_term then return end
 --?   print('release')
+  -- ensure cursor is visible immediately after it moves
+  Cursor_time = 0
   if Lines.current_drawing then
     Drawing.mouse_released(x,y, button)
     schedule_save()
@@ -384,8 +388,6 @@ function App.mousereleased(x,y, button)
 --?           print('reset selection')
           Cursor1 = {line=line_index, pos=Text.to_pos_on_line(line, x, y)}
 --?           print('cursor', Cursor1.line, Cursor1.pos)
-          -- ensure cursor is immediately visible
-          Cursor_time = 0
           if Mousepress_shift then
             if Old_selection1.line == nil then
               Selection1 = Old_cursor1
@@ -403,6 +405,8 @@ function App.mousereleased(x,y, button)
 end
 
 function App.textinput(t)
+  -- ensure cursor is visible immediately after it moves
+  Cursor_time = 0
   for _,line in ipairs(Lines) do line.y = nil end  -- just in case we scroll
   if Search_term then
     Search_term = Search_term..t
@@ -421,6 +425,8 @@ function App.textinput(t)
 end
 
 function App.keychord_pressed(chord, key)
+  -- ensure cursor is visible immediately after it moves
+  Cursor_time = 0
   if Selection1.line and
       not Lines.current_drawing and
       -- printable character created using shift key => delete selection