remember when someone deletes an example

This commit is contained in:
Kartik K. Agaram 2023-11-22 21:22:34 -08:00
parent 90319082f5
commit 1890345ed9
7 changed files with 13 additions and 3 deletions

View File

@ -16,6 +16,9 @@ delete_pane_button = function(x, y, r)
love.graphics.print('delete', p.x+5,p.y+2)
end,
onpress1 = function()
if Current_pane.example_name then
Deleted_example_panes[Current_pane.example_name] = true
end
table.remove(Panes, Current_pane_index)
if #Panes == 0 then
table.insert(Panes, new_pane())

View File

@ -1,6 +1,6 @@
example_pane = function(name, lines)
local result = new_pane()
result.name = name
result.example_name = name
result.editor_state.lines = load_array(lines)
Text.redraw_all(result.editor_state)
return result

View File

@ -1,5 +1,7 @@
-- some examples that each get loaded into a pane
-- each example has a name, so we can avoid bringing back up an example someone deleted.
-- Be careful not to rename example panes; that will cause them to pop up again and annoy people who've already deleted them.
-- If you delete a name, be careful not to reuse it in future.
Example_panes = {
{
name='expr',

View File

@ -2,6 +2,7 @@ on.save_settings = function()
return {
font_height = Font_height,
foreground_color = Foreground_color,
background_color = Background_color
background_color = Background_color,
deleted_example_panes = Deleted_example_panes,
}
end

View File

@ -7,4 +7,5 @@ on.load_settings = function(settings)
local dest = Foreground_color
dest.r, dest.g, dest.b, dest.a = src.r, src.g, src.b, src.a
end
Deleted_example_panes = settings.deleted_example_panes
end

View File

@ -1,5 +1,7 @@
load_example_panes = function()
for _,ex in ipairs(Example_panes) do
table.insert(Panes, example_pane(ex.name, ex.lines))
if Deleted_example_panes[ex.name] == nil then
table.insert(Panes, example_pane(ex.name, ex.lines))
end
end
end

View File

@ -0,0 +1 @@
Deleted_example_panes = {} -- array of names of example panes