#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum InspectorTab {
#[default]
Transcript,
Steps,
Inbox,
Files,
Config,
Work,
}
impl InspectorTab {
pub fn from_digit(n: u8) -> Option<Self> {
Some(match n {
1 => Self::Transcript,
2 => Self::Steps,
3 => Self::Inbox,
4 => Self::Files,
5 => Self::Config,
6 => Self::Work,
_ => 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::Transcript => "Transcript",
Self::Steps => "Steps",
Self::Inbox => "Inbox",
Self::Files => "Files",
Self::Config => "Config",
Self::Work => "Work",
}
}
pub fn all() -> [Self; 6] {
[
Self::Transcript,
Self::Steps,
Self::Inbox,
Self::Files,
Self::Config,
Self::Work,
]
}
pub fn pinnable(self) -> bool {
!matches!(self, Self::Work)
}
}