about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-02 15:45:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-02 15:45:25 -0700
commit670886240f78314b9925e94e1814a8ade5fbaf3e (patch)
tree9e52827ab930246aa88576007903a0fa11dbafb7 /main.lua
parenta9a133e6fb80460ab364e66206a7ffc8f9404b46 (diff)
downloadtext.love-670886240f78314b9925e94e1814a8ade5fbaf3e.tar.gz
after much struggle, a brute-force undo
Incredibly inefficient, but I don't yet know how to efficiently encode
undo mutations that can span multiple lines.

There seems to be one bug related to creating new drawings; they're not
spawning events and undoing past drawing creation has some weird
artifacts. Redo seems to consistently work, though.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index a6b0d73..9372207 100644
--- a/main.lua
+++ b/main.lua
@@ -65,6 +65,10 @@ Zoom = 1.5
 
 Filename = love.filesystem.getUserDirectory()..'/lines.txt'
 
+-- undo
+History = {}
+Next_history = 1
+
 end  -- App.initialize_globals
 
 function App.initialize(arg)
@@ -102,6 +106,7 @@ function App.initialize(arg)
 end  -- App.initialize
 
 function App.filedropped(file)
+  App.initialize_globals()  -- in particular, forget all undo history
   Filename = file:getFilename()
   file:open('r')
   Lines = load_from_file(file)