From 1890345ed937082187b872197d84c6afc9ae5718 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 22 Nov 2023 21:22:34 -0800 Subject: [PATCH] remember when someone deletes an example --- 0076-delete_pane_button | 3 +++ 0077-example_pane | 2 +- 0078-Example_panes | 2 ++ 0098-on.save_settings | 3 ++- 0099-on.load_settings | 1 + 0112-load_example_panes | 4 +++- 0113-Deleted_example_panes | 1 + 7 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 0113-Deleted_example_panes diff --git a/0076-delete_pane_button b/0076-delete_pane_button index 5b2ad3e..fce475c 100644 --- a/0076-delete_pane_button +++ b/0076-delete_pane_button @@ -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()) diff --git a/0077-example_pane b/0077-example_pane index 4c1936b..932cfb7 100644 --- a/0077-example_pane +++ b/0077-example_pane @@ -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 diff --git a/0078-Example_panes b/0078-Example_panes index 174199c..60cf6f2 100644 --- a/0078-Example_panes +++ b/0078-Example_panes @@ -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', diff --git a/0098-on.save_settings b/0098-on.save_settings index 01818a9..bdb634f 100644 --- a/0098-on.save_settings +++ b/0098-on.save_settings @@ -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 \ No newline at end of file diff --git a/0099-on.load_settings b/0099-on.load_settings index b4ee970..ae23708 100644 --- a/0099-on.load_settings +++ b/0099-on.load_settings @@ -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 \ No newline at end of file diff --git a/0112-load_example_panes b/0112-load_example_panes index 258772a..5247744 100644 --- a/0112-load_example_panes +++ b/0112-load_example_panes @@ -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 \ No newline at end of file diff --git a/0113-Deleted_example_panes b/0113-Deleted_example_panes new file mode 100644 index 0000000..07d5041 --- /dev/null +++ b/0113-Deleted_example_panes @@ -0,0 +1 @@ +Deleted_example_panes = {} -- array of names of example panes \ No newline at end of file