about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-02 16:44:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-02 16:44:18 -0700
commit22817492a3c5dd33c7d34c0c505b2bac2661d0ac (patch)
tree42750e2703719181875f741629160524540c3702
parent477216a0517671f4a5e34f4e66061898f22665c3 (diff)
downloadlines.love-22817492a3c5dd33c7d34c0c505b2bac2661d0ac.tar.gz
rename
-rw-r--r--drawing.lua4
-rw-r--r--main.lua2
-rw-r--r--text.lua24
-rw-r--r--undo.lua2
4 files changed, 16 insertions, 16 deletions
diff --git a/drawing.lua b/drawing.lua
index 6718cf7..cbe2486 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -206,7 +206,7 @@ function Drawing.in_drawing(drawing, x,y)
 end
 
 function Drawing.mouse_pressed(drawing, x,y, button)
-  Drawing.before = snapshot_everything()
+  Drawing.before = snapshot()
   if Current_drawing_mode == 'freehand' then
     drawing.pending = {mode=Current_drawing_mode, points={{x=Drawing.coord(x-16), y=Drawing.coord(y-drawing.y)}}}
   elseif Current_drawing_mode == 'line' or Current_drawing_mode == 'manhattan' then
@@ -349,7 +349,7 @@ function Drawing.mouse_released(x,y, button)
   end
   save_to_disk(Lines, Filename)
   if Drawing.before then
-    record_undo_event({before=Drawing.before, after=snapshot_everything()})
+    record_undo_event({before=Drawing.before, after=snapshot()})
     Drawing.before = nil
   end
 end
diff --git a/main.lua b/main.lua
index 38fafa2..b8f2ee7 100644
--- a/main.lua
+++ b/main.lua
@@ -142,7 +142,7 @@ 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_everything()
+                       Drawing.before = snapshot()
                        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
diff --git a/text.lua b/text.lua
index 05d9f35..ee09011 100644
--- a/text.lua
+++ b/text.lua
@@ -1250,7 +1250,7 @@ end
 function Text.insert_at_cursor(t)
   if Selection1.line then Text.delete_selection() end
   -- Collect what you did in an event that can be undone.
-  local before = snapshot_everything()
+  local before = snapshot()
   local byte_offset
   if Cursor1.pos > 1 then
     byte_offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
@@ -1262,7 +1262,7 @@ function Text.insert_at_cursor(t)
   Lines[Cursor1.line].screen_line_starting_pos = nil
   Cursor1.pos = Cursor1.pos+1
   -- finalize undo event
-  record_undo_event({before=before, after=snapshot_everything()})
+  record_undo_event({before=before, after=snapshot()})
 end
 
 -- Don't handle any keys here that would trigger love.textinput above.
@@ -1270,7 +1270,7 @@ function Text.keychord_pressed(chord)
 --?   print(chord)
   --== shortcuts that mutate text
   if chord == 'return' then
-    local before = snapshot_everything()
+    local before = snapshot()
     local byte_offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
     table.insert(Lines, Cursor1.line+1, {mode='text', data=string.sub(Lines[Cursor1.line].data, byte_offset)})
     local scroll_down = (Cursor_y + math.floor(15*Zoom)) > App.screen.height
@@ -1283,18 +1283,18 @@ function Text.keychord_pressed(chord)
       Screen_top1.line = Cursor1.line
       Text.scroll_up_while_cursor_on_screen()
     end
-    record_undo_event({before=before, after=snapshot_everything()})
+    record_undo_event({before=before, after=snapshot()})
   elseif chord == 'tab' then
-    local before = snapshot_everything()
+    local before = snapshot()
     Text.insert_at_cursor('\t')
     save_to_disk(Lines, Filename)
-    record_undo_event({before=before, after=snapshot_everything()})
+    record_undo_event({before=before, after=snapshot()})
   elseif chord == 'backspace' then
-    local before = snapshot_everything()
+    local before = snapshot()
     if Selection1.line then
       Text.delete_selection()
       save_to_disk(Lines, Filename)
-      record_undo_event({before=before, after=snapshot_everything()})
+      record_undo_event({before=before, after=snapshot()})
       return
     end
     if Cursor1.pos > 1 then
@@ -1328,13 +1328,13 @@ function Text.keychord_pressed(chord)
     end
     assert(Text.le1(Screen_top1, Cursor1))
     save_to_disk(Lines, Filename)
-    record_undo_event({before=before, after=snapshot_everything()})
+    record_undo_event({before=before, after=snapshot()})
   elseif chord == 'delete' then
-    local before = snapshot_everything()
+    local before = snapshot()
     if Selection1.line then
       Text.delete_selection()
       save_to_disk(Lines, Filename)
-      record_undo_event({before=before, after=snapshot_everything()})
+      record_undo_event({before=before, after=snapshot()})
       return
     end
     if Cursor1.pos <= utf8.len(Lines[Cursor1.line].data) then
@@ -1360,7 +1360,7 @@ function Text.keychord_pressed(chord)
       end
     end
     save_to_disk(Lines, Filename)
-    record_undo_event({before=before, after=snapshot_everything()})
+    record_undo_event({before=before, after=snapshot()})
   -- undo/redo really belongs in main.lua, but it's here so I can test the
   -- text-specific portions of it
   elseif chord == 'M-z' then
diff --git a/undo.lua b/undo.lua
index abf5f33..bc47f05 100644
--- a/undo.lua
+++ b/undo.lua
@@ -33,7 +33,7 @@ function redo_event()
 end
 
 -- Make copies of objects; the rest of the app may mutate them in place, but undo requires immutable histories.
-function snapshot_everything()
+function snapshot()
   -- compare with App.initialize_globals
   local event = {
     screen_top=deepcopy(Screen_top1),