about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--edit.lua23
-rw-r--r--main.lua22
2 files changed, 21 insertions, 24 deletions
diff --git a/edit.lua b/edit.lua
index dee5334..a114607 100644
--- a/edit.lua
+++ b/edit.lua
@@ -102,12 +102,6 @@ Search_term = nil
 Search_text = nil
 Search_backup = nil  -- stuff to restore when cancelling search
 
--- resize
-Last_resize_time = nil
-
--- blinking cursor
-Cursor_time = 0
-
 end  -- App.initialize_globals
 
 function edit.draw()
@@ -172,15 +166,6 @@ function edit.draw()
 end
 
 function edit.update(dt)
-  Cursor_time = Cursor_time + dt
-  -- some hysteresis while resizing
-  if Last_resize_time then
-    if App.getTime() - Last_resize_time < 0.1 then
-      return
-    else
-      Last_resize_time = nil
-    end
-  end
   Drawing.update(dt)
   if Next_save and Next_save < App.getTime() then
     save_to_disk(Lines, Filename)
@@ -203,8 +188,6 @@ end
 
 function edit.mouse_pressed(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)
 
@@ -245,8 +228,6 @@ end
 function edit.mouse_released(x,y, mouse_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, mouse_button)
     schedule_save()
@@ -284,8 +265,6 @@ function edit.mouse_released(x,y, mouse_button)
 end
 
 function edit.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
@@ -304,8 +283,6 @@ function edit.textinput(t)
 end
 
 function edit.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
diff --git a/main.lua b/main.lua
index c9c5142..f1ac122 100644
--- a/main.lua
+++ b/main.lua
@@ -14,7 +14,13 @@ Editor_state = {}
 
 -- called both in tests and real run
 function App.initialize_globals()
-  return edit.initialize_globals()
+  edit.initialize_globals()
+
+  -- resize
+  Last_resize_time = nil
+
+  -- blinking cursor
+  Cursor_time = 0
 end
 
 -- called only for real run
@@ -144,6 +150,15 @@ function App.draw()
 end
 
 function App.update(dt)
+  Cursor_time = Cursor_time + dt
+  -- some hysteresis while resizing
+  if Last_resize_time then
+    if App.getTime() - Last_resize_time < 0.1 then
+      return
+    else
+      Last_resize_time = nil
+    end
+  end
   edit.update(dt)
 end
 
@@ -165,21 +180,26 @@ function love.quit()
 end
 
 function App.mousepressed(x,y, mouse_button)
+  Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.mouse_pressed(x,y, mouse_button)
 end
 
 function App.mousereleased(x,y, mouse_button)
+  Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.mouse_released(x,y, mouse_button)
 end
 
 function App.textinput(t)
+  Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.textinput(t)
 end
 
 function App.keychord_pressed(chord, key)
+  Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.keychord_pressed(chord, key)
 end
 
 function App.keyreleased(key, scancode)
+  Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.key_released(key, scancode)
 end