From e9c2819e1b101eab7d4a00bdf1e9c1efa1077921 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Sat, 7 Sep 2024 10:05:46 -0700 Subject: [PATCH] Add command entry to open editor --- data/src/isupport.rs | 2 +- src/screen/dashboard.rs | 11 +++++++++++ src/screen/dashboard/command_bar.rs | 11 +++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/data/src/isupport.rs b/data/src/isupport.rs index fc533b3b..ac4c9447 100644 --- a/data/src/isupport.rs +++ b/data/src/isupport.rs @@ -225,7 +225,7 @@ impl FromStr for Operation { None, types.to_string(), ))) - } else if prefix.chars().all(|c| c.is_ascii()) { + } else if prefix.is_ascii() { Ok(Operation::Add(Parameter::EXTBAN( prefix.chars().next(), types.to_string(), diff --git a/src/screen/dashboard.rs b/src/screen/dashboard.rs index bc5b3074..2b648125 100644 --- a/src/screen/dashboard.rs +++ b/src/screen/dashboard.rs @@ -451,6 +451,17 @@ impl Dashboard { *theme = Theme::from(new); (Task::none(), None) } + command_bar::Theme::OpenEditor => { + if let Some(editor) = &self.theme_editor { + (window::gain_focus(editor.id), None) + } else { + let (editor, task) = ThemeEditor::open(main_window); + + self.theme_editor = Some(editor); + + (task.then(|_| Task::none()), None) + } + } }, }; diff --git a/src/screen/dashboard/command_bar.rs b/src/screen/dashboard/command_bar.rs index 99f940f7..a71ed352 100644 --- a/src/screen/dashboard/command_bar.rs +++ b/src/screen/dashboard/command_bar.rs @@ -141,6 +141,7 @@ pub enum Ui { #[derive(Debug, Clone)] pub enum Theme { Switch(data::Theme), + OpenEditor, } impl Command { @@ -234,12 +235,9 @@ impl Ui { impl Theme { fn list(config: &Config) -> Vec { - config - .themes - .all - .iter() - .cloned() - .map(Self::Switch) + Some(Self::OpenEditor) + .into_iter() + .chain(config.themes.all.iter().cloned().map(Self::Switch)) .collect() } } @@ -311,6 +309,7 @@ impl std::fmt::Display for Theme { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Theme::Switch(theme) => write!(f, "Switch to {}", theme.name), + Theme::OpenEditor => write!(f, "Open editor"), } } }