From 670886240f78314b9925e94e1814a8ade5fbaf3e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 2 Jun 2022 15:45:25 -0700 Subject: 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. --- main.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'main.lua') 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) -- cgit 1.4.1-2-gfad0