save the list of open files across restart

This commit is contained in:
Kartik K. Agaram 2023-11-26 12:26:22 -08:00
parent 6aa19f1086
commit f3965c61e8
6 changed files with 28 additions and 1 deletions

View File

@ -8,7 +8,10 @@ on.initialize = function()
Menu_height = 5 + Line_height + 5
Menu_bottom = Menu_top + Menu_height
load_example_panes()
table.insert(Panes, new_pane())
load_panes_from_previous_session()
if #Panes == 0 then
table.insert(Panes, new_pane())
end
Current_pane_index = 1
Current_pane = Panes[Current_pane_index]
end

View File

@ -4,5 +4,6 @@ on.save_settings = function()
foreground_color = Foreground_color,
background_color = Background_color,
deleted_example_panes = Deleted_example_panes,
loaded_filenames = filenames_from_all_panes(),
}
end

View File

@ -8,4 +8,5 @@ on.load_settings = function(settings)
dest.r, dest.g, dest.b, dest.a = src.r, src.g, src.b, src.a
end
Deleted_example_panes = settings.deleted_example_panes
Initial_load_filenames = settings.loaded_filenames
end

View File

@ -0,0 +1,9 @@
filenames_from_all_panes = function()
local result = {}
for _,pane in ipairs(Panes) do
if pane.filename then
table.insert(result, pane.filename)
end
end
return result
end

View File

@ -0,0 +1,3 @@
-- List of filenames loaded from settings that on.initialize will load into Panes.
-- It's particularly unfortunate that this is a global.
Initial_load_filenames = nil

View File

@ -0,0 +1,10 @@
load_panes_from_previous_session = function()
if Initial_load_filenames == nil then return end
for _,filename in ipairs(Initial_load_filenames) do
table.insert(Panes, new_pane())
Current_pane_index = #Panes
Current_pane = Panes[Current_pane_index]
Current_pane.filename = filename
one_time_load()
end
end