#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum CenterTab {
#[default]
Conversation,
Config,
Login,
Search,
}
impl CenterTab {
pub fn from_digit(n: u8) -> Option<Self> {
Some(match n {
1 => Self::Conversation,
2 => Self::Config,
3 => Self::Login,
4 => Self::Search,
_ => return None,
})
}
pub fn digit(self) -> u8 {
let at = Self::all().iter().position(|tab| *tab == self);
u8::try_from(at.unwrap_or_default() + 1).unwrap_or(1)
}
pub(crate) fn label(self) -> &'static str {
match self {
Self::Conversation => "Conversation",
Self::Config => "Config",
Self::Login => "Login",
Self::Search => "Search",
}
}
pub(crate) fn hint(self) -> &'static str {
match self {
Self::Conversation => {
"The conversation you have selected — its transcript, its inspector and \
the box you talk to it in. Escape from any other tab comes back here."
}
Self::Config => {
"Every setting yog can write: brazen's config.toml, lernie's global \
config, and this workspace's config branches. Focusing the tab re-reads \
all three off disk; nothing is written until you Apply."
}
Self::Login => {
"Sign in to a model provider: one button per row, each opening your \
browser to authorize it and printing everything bz says."
}
Self::Search => {
"What the last /search found across the whole world — balls, workspaces \
and conversations. Pick a result to go there."
}
}
}
pub(crate) fn focus_hover(self) -> String {
format!(
"{} Press Ctrl+Shift+{}: the centre strip is Ctrl+Shift+1 to \
Ctrl+Shift+4.",
self.hint(),
self.digit()
)
}
pub fn all() -> [Self; 4] {
[Self::Conversation, Self::Config, Self::Login, Self::Search]
}
}