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-10 11:48:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-10 11:48:32 -0700
commitc875f7be46d76650e1c6a16668f77df7227d57d3 (patch)
treec67b443c57356842bbe2c3992699ff7940f4f8c2 /main.lua
parent79a12413700dca5816d6c27fc4951bdd7579e329 (diff)
downloadtext.love-c875f7be46d76650e1c6a16668f77df7227d57d3.tar.gz
stop saving the entire file when modifying drawings
Now we just disallow that entirely.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index 53751bb..ddde651 100644
--- a/main.lua
+++ b/main.lua
@@ -290,6 +290,9 @@ function App.mousepressed(x,y, mouse_button)
       end
     elseif line.mode == 'drawing' then
       if Drawing.in_drawing(line, x, y) then
+        Lines.current_drawing_index = line_index
+        Lines.current_drawing = line
+        Drawing.before = snapshot(line_index)
         Drawing.mouse_pressed(line, x,y, button)
       end
     end
@@ -300,6 +303,11 @@ function App.mousereleased(x,y, button)
   if Search_term then return end
   if Lines.current_drawing then
     Drawing.mouse_released(x,y, button)
+    save_to_disk(Lines, Filename)
+    if Drawing.before then
+      record_undo_event({before=Drawing.before, after=snapshot(Lines.current_drawing_index)})
+      Drawing.before = nil
+    end
   else
     for line_index,line in ipairs(Lines) do
       if line.mode == 'text' then