use crate::arrangements::ArrangementId;
use crate::profile::ProfileId;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MenuAction {
NewWindow,
CloseWindow,
CloseWholeWindow,
CycleWindow(i8),
FocusWindowNumber(usize),
Quit,
OpenProfile(ProfileId),
Copy,
Paste,
SelectAll,
OpenSettings,
Minimize,
Zoom,
About,
OpenDocs,
SaveArrangement,
RestoreArrangement(ArrangementId),
InstallShellIntegrationRemote,
Action(&'static str),
}
impl MenuAction {
pub fn keybinding_action(&self) -> Option<std::borrow::Cow<'static, str>> {
let id = match self {
Self::NewWindow => "new_window",
Self::CloseWindow => "close_tab_or_window",
Self::CloseWholeWindow => "close_window",
Self::CycleWindow(1) => "next_window",
Self::CycleWindow(_) => "prev_window",
Self::FocusWindowNumber(n) => {
return Some(std::borrow::Cow::Owned(format!("switch_to_window_{n}")));
}
Self::OpenProfile(id) => {
return Some(std::borrow::Cow::Owned(format!("open_profile:{id}")));
}
Self::Quit => "quit",
Self::SelectAll => "select_all",
Self::OpenSettings => "open_settings",
Self::SaveArrangement => "save_arrangement",
Self::Action(id) => id,
Self::RestoreArrangement(_)
| Self::Copy
| Self::Paste
| Self::Minimize
| Self::Zoom
| Self::About
| Self::OpenDocs
| Self::InstallShellIntegrationRemote => return None,
};
Some(std::borrow::Cow::Borrowed(id))
}
}