Skip to content

Commit

Permalink
Add command entry to open editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Sep 7, 2024
1 parent fd2947c commit e9c2819
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data/src/isupport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
11 changes: 11 additions & 0 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
},
};

Expand Down
11 changes: 5 additions & 6 deletions src/screen/dashboard/command_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub enum Ui {
#[derive(Debug, Clone)]
pub enum Theme {
Switch(data::Theme),
OpenEditor,
}

impl Command {
Expand Down Expand Up @@ -234,12 +235,9 @@ impl Ui {

impl Theme {
fn list(config: &Config) -> Vec<Self> {
config
.themes
.all
.iter()
.cloned()
.map(Self::Switch)
Some(Self::OpenEditor)
.into_iter()
.chain(config.themes.all.iter().cloned().map(Self::Switch))
.collect()
}
}
Expand Down Expand Up @@ -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"),
}
}
}

0 comments on commit e9c2819

Please sign in to comment.