From d270ee8d1664222c19877ea31e5751f756f3bd65 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Thu, 18 Jun 2026 20:51:00 -0500 Subject: [PATCH] Creating scripts --- kiln-tui/src/editor.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kiln-tui/src/editor.rs b/kiln-tui/src/editor.rs index 141e2e1..a6ccbbc 100644 --- a/kiln-tui/src/editor.rs +++ b/kiln-tui/src/editor.rs @@ -211,19 +211,17 @@ impl EditorState { fn open_scripts_dialog(&mut self) { let mut names: Vec = self.world.scripts.keys().cloned().collect(); names.sort(); - self.dialog = Some(Dialog::list("Scripts", names, false, |resp, ed: &mut EditorState| { - if let ListDialogResponse::Select(name) = resp { - ed.open_script_editor(&name); + self.dialog = Some(Dialog::list("Scripts", names, true, |resp, ed: &mut EditorState| { + match resp { + ListDialogResponse::Select(name) | ListDialogResponse::Create(name) => { + let source = ed.world.scripts.get(&name).cloned().unwrap_or_default(); + ed.code_editor = Some(CodeEditor::new(&name, &source)); + } + ListDialogResponse::Cancel => {} } })); } - /// Opens the code editor on the named script (empty if the name is unknown). - fn open_script_editor(&mut self, name: &str) { - let source = self.world.scripts.get(name).cloned().unwrap_or_default(); - self.code_editor = Some(CodeEditor::new(name, &source)); - } - /// Closes the code editor, saving its text back into the in-memory script pool /// (mirrors how the Name/Entry-board dialogs mutate the loaded `World`). pub(crate) fn close_script_editor(&mut self) {