use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum TabStyle {
#[default]
Dark,
Light,
Compact,
Minimal,
HighContrast,
Automatic,
}
impl TabStyle {
pub fn display_name(&self) -> &'static str {
match self {
TabStyle::Dark => "Dark",
TabStyle::Light => "Light",
TabStyle::Compact => "Compact",
TabStyle::Minimal => "Minimal",
TabStyle::HighContrast => "High Contrast",
TabStyle::Automatic => "Automatic",
}
}
pub fn all() -> &'static [TabStyle] {
&[
TabStyle::Dark,
TabStyle::Light,
TabStyle::Compact,
TabStyle::Minimal,
TabStyle::HighContrast,
TabStyle::Automatic,
]
}
pub fn all_concrete() -> &'static [TabStyle] {
&[
TabStyle::Dark,
TabStyle::Light,
TabStyle::Compact,
TabStyle::Minimal,
TabStyle::HighContrast,
]
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum TabBarPosition {
#[default]
Top,
Bottom,
Left,
}
impl TabBarPosition {
pub fn display_name(&self) -> &'static str {
match self {
TabBarPosition::Top => "Top",
TabBarPosition::Bottom => "Bottom",
TabBarPosition::Left => "Left",
}
}
pub fn all() -> &'static [TabBarPosition] {
&[
TabBarPosition::Top,
TabBarPosition::Bottom,
TabBarPosition::Left,
]
}
pub fn is_horizontal(&self) -> bool {
matches!(self, TabBarPosition::Top | TabBarPosition::Bottom)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum TabBarMode {
#[default]
Always,
WhenMultiple,
Never,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum TabTitleMode {
#[default]
Auto,
OscOnly,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum RemoteTabTitleFormat {
#[default]
UserAtHost,
Host,
HostAndCwd,
}
impl RemoteTabTitleFormat {
pub fn display_name(&self) -> &'static str {
match self {
RemoteTabTitleFormat::UserAtHost => "user@host",
RemoteTabTitleFormat::Host => "host",
RemoteTabTitleFormat::HostAndCwd => "host:~/cwd",
}
}
pub fn all() -> &'static [RemoteTabTitleFormat] {
&[
RemoteTabTitleFormat::UserAtHost,
RemoteTabTitleFormat::Host,
RemoteTabTitleFormat::HostAndCwd,
]
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum WindowType {
#[default]
Normal,
Fullscreen,
EdgeTop,
EdgeBottom,
EdgeLeft,
EdgeRight,
}
impl WindowType {
pub fn display_name(&self) -> &'static str {
match self {
WindowType::Normal => "Normal",
WindowType::Fullscreen => "Fullscreen",
WindowType::EdgeTop => "Edge (Top)",
WindowType::EdgeBottom => "Edge (Bottom)",
WindowType::EdgeLeft => "Edge (Left)",
WindowType::EdgeRight => "Edge (Right)",
}
}
pub fn all() -> &'static [WindowType] {
&[
WindowType::Normal,
WindowType::Fullscreen,
WindowType::EdgeTop,
WindowType::EdgeBottom,
WindowType::EdgeLeft,
WindowType::EdgeRight,
]
}
pub fn is_edge(&self) -> bool {
matches!(
self,
WindowType::EdgeTop
| WindowType::EdgeBottom
| WindowType::EdgeLeft
| WindowType::EdgeRight
)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)]
#[serde(rename_all = "lowercase")]
pub enum StatusBarPosition {
Top,
#[default]
Bottom,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum NewTabPosition {
#[default]
End,
AfterActive,
}
impl NewTabPosition {
pub fn display_name(&self) -> &'static str {
match self {
Self::End => "End of tab bar",
Self::AfterActive => "After active tab",
}
}
pub fn all() -> &'static [Self] {
&[Self::End, Self::AfterActive]
}
}
#[cfg(test)]
mod remote_format_tests {
use super::*;
#[test]
fn all_returns_three_variants() {
assert_eq!(RemoteTabTitleFormat::all().len(), 3);
}
#[test]
fn display_name_covers_all_variants() {
for v in RemoteTabTitleFormat::all() {
assert!(!v.display_name().is_empty());
}
}
#[test]
fn default_is_user_at_host() {
assert_eq!(
RemoteTabTitleFormat::default(),
RemoteTabTitleFormat::UserAtHost
);
}
}
#[cfg(test)]
mod new_tab_position_tests {
use super::*;
#[test]
fn default_is_end() {
assert_eq!(NewTabPosition::default(), NewTabPosition::End);
}
#[test]
fn all_has_two_variants() {
assert_eq!(NewTabPosition::all().len(), 2);
}
#[test]
fn display_name_non_empty() {
for v in NewTabPosition::all() {
assert!(!v.display_name().is_empty());
}
}
#[test]
fn serde_round_trip() {
let end: NewTabPosition = serde_json::from_str("\"end\"").unwrap();
assert_eq!(end, NewTabPosition::End);
let after: NewTabPosition = serde_json::from_str("\"after_active\"").unwrap();
assert_eq!(after, NewTabPosition::AfterActive);
}
}