about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--drawing_tests.lua18
-rw-r--r--edit.lua4
-rw-r--r--main.lua18
-rw-r--r--source_edit.lua4
-rw-r--r--source_tests.lua6
5 files changed, 26 insertions, 24 deletions
diff --git a/drawing_tests.lua b/drawing_tests.lua
index f1e39a6..80a91f1 100644
--- a/drawing_tests.lua
+++ b/drawing_tests.lua
@@ -16,7 +16,7 @@ function test_creating_drawing_saves()
   edit.update(Editor_state, 0.01)
   check_nil(App.filesystem['foo'], 'F - test_creating_drawing_saves/early')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- filesystem contains drawing and an empty line of text
   check_eq(App.filesystem['foo'], '```lines\n```\n\n', 'F - test_creating_drawing_saves')
@@ -51,7 +51,7 @@ function test_draw_line()
   check_eq(p2.x, 35, 'F - test_draw_line/p2:x')
   check_eq(p2.y, 36, 'F - test_draw_line/p2:y')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- The format on disk isn't perfectly stable. Table fields can be reordered.
   -- So just reload from disk to verify.
@@ -430,7 +430,7 @@ function test_name_point()
   check_eq(Editor_state.current_drawing_mode, 'line', 'F - test_name_point/mode:3')
   check_eq(p2.name, 'A', 'F - test_name_point')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- change is saved
   load_from_disk(Editor_state)
@@ -462,7 +462,7 @@ function test_move_point()
   check_eq(p2.x, 35, 'F - test_move_point/baseline/p2:x')
   check_eq(p2.y, 36, 'F - test_move_point/baseline/p2:y')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- line is saved to disk
   load_from_disk(Editor_state)
@@ -489,7 +489,7 @@ function test_move_point()
   check_eq(Editor_state.current_drawing_mode, 'line', 'F - test_move_point/mode:3')
   check_eq(drawing.pending, {}, 'F - test_move_point/pending')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- change is saved
   load_from_disk(Editor_state)
@@ -550,7 +550,7 @@ function test_delete_lines_at_point()
   check_eq(drawing.shapes[1].mode, 'deleted', 'F - test_delete_lines_at_point/shape:1')
   check_eq(drawing.shapes[2].mode, 'deleted', 'F - test_delete_lines_at_point/shape:2')
   -- wait for some time
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- deleted points disappear after file is reloaded
   load_from_disk(Editor_state)
@@ -684,7 +684,7 @@ function test_undo_name_point()
   check_eq(Editor_state.next_history, 3, 'F - test_undo_name_point/next_history')
   check_eq(p2.name, '', 'F - test_undo_name_point')  -- not quite what it was before, but close enough
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- undo is saved
   load_from_disk(Editor_state)
@@ -735,7 +735,7 @@ function test_undo_move_point()
   check_eq(p2.x, 35, 'F - test_undo_move_point/x')
   check_eq(p2.y, 36, 'F - test_undo_move_point/y')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- undo is saved
   load_from_disk(Editor_state)
@@ -776,7 +776,7 @@ function test_undo_delete_point()
   check_eq(drawing.shapes[1].mode, 'line', 'F - test_undo_delete_point/shape:1')
   check_eq(drawing.shapes[2].mode, 'line', 'F - test_undo_delete_point/shape:2')
   -- wait until save
-  App.wait_fake_time(3.1)
+  Current_time = Current_time + 3.1
   edit.update(Editor_state, 0)
   -- undo is saved
   load_from_disk(Editor_state)
diff --git a/edit.lua b/edit.lua
index 3c722a7..db276a7 100644
--- a/edit.lua
+++ b/edit.lua
@@ -176,7 +176,7 @@ end
 
 function edit.update(State, dt)
   Drawing.update(State, dt)
-  if State.next_save and State.next_save < App.getTime() then
+  if State.next_save and State.next_save < Current_time then
     save_to_disk(State)
     State.next_save = nil
   end
@@ -184,7 +184,7 @@ end
 
 function schedule_save(State)
   if State.next_save == nil then
-    State.next_save = App.getTime() + 3  -- short enough that you're likely to still remember what you did
+    State.next_save = Current_time + 3  -- short enough that you're likely to still remember what you did
   end
 end
 
diff --git a/main.lua b/main.lua
index 570a7a1..7c3a482 100644
--- a/main.lua
+++ b/main.lua
@@ -81,8 +81,9 @@ function App.initialize_globals()
   end
 
   -- for hysteresis in a few places
-  Last_focus_time = App.getTime()  -- https://love2d.org/forums/viewtopic.php?p=249700
-  Last_resize_time = App.getTime()
+  Current_time = 0
+  Last_focus_time = 0  -- https://love2d.org/forums/viewtopic.php?p=249700
+  Last_resize_time = 0
 end
 
 function App.initialize(arg)
@@ -103,7 +104,7 @@ function App.resize(w,h)
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
-  Last_resize_time = App.getTime()
+  Last_resize_time = Current_time
 end
 
 function App.filedropped(file)
@@ -118,7 +119,7 @@ end
 
 function App.focus(in_focus)
   if in_focus then
-    Last_focus_time = App.getTime()
+    Last_focus_time = Current_time
   end
   if Current_app == 'run' then
     if run.focus then run.focus(in_focus) end
@@ -140,8 +141,9 @@ function App.draw()
 end
 
 function App.update(dt)
+  Current_time = Current_time + dt
   -- some hysteresis while resizing
-  if App.getTime() < Last_resize_time + 0.1 then
+  if Current_time < Last_resize_time + 0.1 then
     return
   end
   --
@@ -156,7 +158,7 @@ end
 
 function App.keychord_pressed(chord, key)
   -- ignore events for some time after window in focus (mostly alt-tab)
-  if App.getTime() < Last_focus_time + 0.01 then
+  if Current_time < Last_focus_time + 0.01 then
     return
   end
   --
@@ -194,7 +196,7 @@ end
 
 function App.textinput(t)
   -- ignore events for some time after window in focus (mostly alt-tab)
-  if App.getTime() < Last_focus_time + 0.01 then
+  if Current_time < Last_focus_time + 0.01 then
     return
   end
   --
@@ -209,7 +211,7 @@ end
 
 function App.keyreleased(chord, key)
   -- ignore events for some time after window in focus (mostly alt-tab)
-  if App.getTime() < Last_focus_time + 0.01 then
+  if Current_time < Last_focus_time + 0.01 then
     return
   end
   --
diff --git a/source_edit.lua b/source_edit.lua
index 4f55083..1d82596 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -189,7 +189,7 @@ end
 
 function edit.update(State, dt)
   Drawing.update(State, dt)
-  if State.next_save and State.next_save < App.getTime() then
+  if State.next_save and State.next_save < Current_time then
     save_to_disk(State)
     State.next_save = nil
   end
@@ -197,7 +197,7 @@ end
 
 function schedule_save(State)
   if State.next_save == nil then
-    State.next_save = App.getTime() + 3  -- short enough that you're likely to still remember what you did
+    State.next_save = Current_time + 3  -- short enough that you're likely to still remember what you did
   end
 end
 
diff --git a/source_tests.lua b/source_tests.lua
index 81bdb74..b6e5861 100644
--- a/source_tests.lua
+++ b/source_tests.lua
@@ -31,7 +31,7 @@ function test_show_log_browser_side()
   log_browser.parse(Log_browser_state)
   check(not Show_log_browser_side, 'F - test_show_log_browser_side/baseline')
   -- pressing ctrl+l shows log-browser side
-  App.wait_fake_time(0.1)
+  Current_time = Current_time + 0.1
   App.run_after_keychord('C-l')
   check(Show_log_browser_side, 'F - test_show_log_browser_side')
 end
@@ -56,7 +56,7 @@ function test_show_log_browser_side_doubles_window_width_if_possible()
   Text.redraw_all(Log_browser_state)
   log_browser.parse(Log_browser_state)
   -- display log browser
-  App.wait_fake_time(0.1)
+  Current_time = Current_time + 0.1
   App.run_after_keychord('C-l')
   -- window width is doubled
   check_eq(App.screen.width, 600, 'F - test_show_log_browser_side_doubles_window_width_if_possible/display:width')
@@ -87,7 +87,7 @@ function test_show_log_browser_side_resizes_both_sides_if_cannot_double_window_w
   Text.redraw_all(Log_browser_state)
   log_browser.parse(Log_browser_state)
   -- display log browser
-  App.wait_fake_time(0.1)
+  Current_time = Current_time + 0.1
   App.run_after_keychord('C-l')
   -- margins are now adjusted
   check_eq(Editor_state.left, Margin_left, 'F - test_show_log_browser_side_resizes_both_sides_if_cannot_double_window_width/edit:left')