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
|
end
|
||||||
|
|
||||||
function Drawing.mouse_pressed(drawing, x,y, button)
|
function Drawing.mouse_pressed(drawing, x,y, button)
|
||||||
Drawing.before = snapshot()
|
|
||||||
if Current_drawing_mode == 'freehand' then
|
if Current_drawing_mode == 'freehand' then
|
||||||
drawing.pending = {mode=Current_drawing_mode, points={{x=Drawing.coord(x-16), y=Drawing.coord(y-drawing.y)}}}
|
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
|
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)
|
print(Current_drawing_mode)
|
||||||
assert(false)
|
assert(false)
|
||||||
end
|
end
|
||||||
Lines.current_drawing = drawing
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- a couple of operations on drawings need to constantly check the state of the mouse
|
-- 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
|
Lines.current_drawing = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
save_to_disk(Lines, Filename)
|
|
||||||
if Drawing.before then
|
|
||||||
record_undo_event({before=Drawing.before, after=snapshot()})
|
|
||||||
Drawing.before = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Drawing.keychord_pressed(chord)
|
function Drawing.keychord_pressed(chord)
|
||||||
|
|
8
main.lua
8
main.lua
|
@ -290,6 +290,9 @@ function App.mousepressed(x,y, mouse_button)
|
||||||
end
|
end
|
||||||
elseif line.mode == 'drawing' then
|
elseif line.mode == 'drawing' then
|
||||||
if Drawing.in_drawing(line, x, y) 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)
|
Drawing.mouse_pressed(line, x,y, button)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -300,6 +303,11 @@ function App.mousereleased(x,y, button)
|
||||||
if Search_term then return end
|
if Search_term then return end
|
||||||
if Lines.current_drawing then
|
if Lines.current_drawing then
|
||||||
Drawing.mouse_released(x,y, button)
|
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
|
else
|
||||||
for line_index,line in ipairs(Lines) do
|
for line_index,line in ipairs(Lines) do
|
||||||
if line.mode == 'text' then
|
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.
|
-- Make copies of objects; the rest of the app may mutate them in place, but undo requires immutable histories.
|
||||||
function snapshot(s,e)
|
function snapshot(s,e)
|
||||||
-- Snapshot everything by default, but subset if requested.
|
-- Snapshot everything by default, but subset if requested.
|
||||||
if s == nil and e == nil then
|
assert(s)
|
||||||
s = 1
|
if e == nil then
|
||||||
e = #Lines
|
|
||||||
elseif e == nil then
|
|
||||||
e = s
|
e = s
|
||||||
end
|
end
|
||||||
assert(#Lines > 0)
|
assert(#Lines > 0)
|
||||||
|
|
Loading…
Reference in New Issue