clean up some final bifold code

This commit is contained in:
Kartik K. Agaram 2023-04-01 20:39:39 -07:00
parent c87e4a3bab
commit 86517606a1
2 changed files with 3 additions and 19 deletions

View File

@ -1,7 +1,5 @@
-- primitives for saving to file and loading from file
Fold = '\x1e' -- ASCII RS (record separator)
function file_exists(filename)
local infile = App.open_for_reading(filename)
if infile then
@ -28,13 +26,7 @@ function load_from_file(infile)
if line == '```lines' then -- inflexible with whitespace since these files are always autogenerated
table.insert(result, load_drawing(infile_next_line))
else
local line_info = {mode='text'}
if line:find(Fold) then
_, _, line_info.data, line_info.dataB = line:find('([^'..Fold..']*)'..Fold..'([^'..Fold..']*)')
else
line_info.data = line
end
table.insert(result, line_info)
table.insert(result, {mode='text', data=line})
end
end
end
@ -54,10 +46,6 @@ function save_to_disk(State)
store_drawing(outfile, line)
else
outfile:write(line.data)
if line.dataB and #line.dataB > 0 then
outfile:write(Fold)
outfile:write(line.dataB)
end
outfile:write('\n')
end
end
@ -147,11 +135,7 @@ function load_array(a)
else
--? print('inserting text')
local line_info = {mode='text'}
if line:find(Fold) then
_, _, line_info.data, line_info.dataB = line:find('([^'..Fold..']*)'..Fold..'([^'..Fold..']*)')
else
line_info.data = line
end
line_info.data = line
table.insert(result, line_info)
end
end

View File

@ -61,7 +61,7 @@ function snapshot(State, s,e)
for i=s,e do
local line = State.lines[i]
if line.mode == 'text' then
table.insert(event.lines, {mode='text', data=line.data, dataB=line.dataB})
table.insert(event.lines, {mode='text', data=line.data})
elseif line.mode == 'drawing' then
local points=deepcopy(line.points)
--? print('copying', line.points, 'with', #line.points, 'points into', points)