stop saving the entire file when modifying drawings
Now we just disallow that entirely.
This commit is contained in:
parent
79a1241370
commit
c875f7be46
|
@ -206,7 +206,6 @@ function Drawing.in_drawing(drawing, x,y)
|
|||
end
|
||||
|
||||
function Drawing.mouse_pressed(drawing, x,y, button)
|
||||
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
|
||||
|
@ -226,7 +225,6 @@ function Drawing.mouse_pressed(drawing, x,y, button)
|
|||
print(Current_drawing_mode)
|
||||
assert(false)
|
||||
end
|
||||
Lines.current_drawing = drawing
|
||||
end
|
||||
|
||||
-- a couple of operations on drawings need to constantly check the state of the mouse
|
||||
|
@ -348,11 +346,6 @@ function Drawing.mouse_released(x,y, button)
|
|||
Lines.current_drawing = nil
|
||||
end
|
||||
end
|
||||
save_to_disk(Lines, Filename)
|
||||
if Drawing.before then
|
||||
record_undo_event({before=Drawing.before, after=snapshot()})
|
||||
Drawing.before = nil
|
||||
end
|
||||
end
|
||||
|
||||
function Drawing.keychord_pressed(chord)
|
||||
|
|
8
main.lua
8
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
|
||||
|
|
6
undo.lua
6
undo.lua
|
@ -36,10 +36,8 @@ end
|
|||
-- Make copies of objects; the rest of the app may mutate them in place, but undo requires immutable histories.
|
||||
function snapshot(s,e)
|
||||
-- Snapshot everything by default, but subset if requested.
|
||||
if s == nil and e == nil then
|
||||
s = 1
|
||||
e = #Lines
|
||||
elseif e == nil then
|
||||
assert(s)
|
||||
if e == nil then
|
||||
e = s
|
||||
end
|
||||
assert(#Lines > 0)
|
||||
|
|
Loading…
Reference in New Issue