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:45:53 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-10 11:45:53 -0700
commit79a12413700dca5816d6c27fc4951bdd7579e329 (patch)
tree0c49c32a68c411320a7f65ce8bf323a9b1679d73 /main.lua
parentfcacb6e63d1aefd7aedc858e6efa39d8102eb6ba (diff)
downloadtext.love-79a12413700dca5816d6c27fc4951bdd7579e329.tar.gz
undo creating new drawings
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/main.lua b/main.lua
index 7be15cf..53751bb 100644
--- a/main.lua
+++ b/main.lua
@@ -219,11 +219,13 @@ function App.draw()
         button('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},
           icon = icon.insert_drawing,
           onpress1 = function()
-                       Drawing.before = snapshot()
+                       Drawing.before = snapshot(line_index-1, line_index)
                        table.insert(Lines, line_index, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}})
                        if Cursor1.line >= line_index then
                          Cursor1.line = Cursor1.line+1
                        end
+                       save_to_disk(Lines, Filename)
+                       record_undo_event({before=Drawing.before, after=snapshot(line_index-1, line_index+1)})
                      end})
           if Search_term == nil then
             if line_index == Cursor1.line then