Skip to main content

par_term_config/config/config_struct/
tab_config.rs

1//! Tab and tab bar behaviour settings.
2//!
3//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
4//! All fields serialise at the top level of the YAML config file -- existing
5//! config files remain 100% compatible.
6
7use crate::types::{
8    NewTabPosition, RemoteTabTitleFormat, TabBarMode, TabBarPosition, TabStyle, TabTitleMode,
9};
10use serde::{Deserialize, Serialize};
11
12/// Tab style presets, tab bar placement and new-tab behaviour.
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct TabConfig {
15    /// Tab visual style preset (dark, light, compact, minimal, high_contrast, automatic)
16    /// Applies cosmetic color/size/spacing presets to the tab bar
17    #[serde(default)]
18    pub tab_style: TabStyle,
19
20    /// Tab style to use when system is in light mode (used when tab_style is Automatic)
21    #[serde(default = "crate::defaults::light_tab_style")]
22    pub light_tab_style: TabStyle,
23
24    /// Tab style to use when system is in dark mode (used when tab_style is Automatic)
25    #[serde(default = "crate::defaults::dark_tab_style")]
26    pub dark_tab_style: TabStyle,
27
28    /// Tab bar visibility mode (always, when_multiple, never)
29    #[serde(default)]
30    pub tab_bar_mode: TabBarMode,
31
32    /// Controls how tab titles are automatically updated (auto or osc_only)
33    #[serde(default)]
34    pub tab_title_mode: TabTitleMode,
35
36    /// Format for tab title when shell integration detects a remote host
37    #[serde(default)]
38    pub remote_tab_title_format: RemoteTabTitleFormat,
39
40    /// When true, explicit OSC title sequences override remote_tab_title_format
41    #[serde(default = "crate::defaults::bool_true")]
42    pub remote_tab_title_osc_priority: bool,
43
44    /// Tab bar height in pixels
45    #[serde(default = "crate::defaults::tab_bar_height")]
46    pub tab_bar_height: f32,
47
48    /// Tab bar position (top, bottom, left)
49    #[serde(default)]
50    pub tab_bar_position: TabBarPosition,
51
52    /// Tab bar width in pixels (used when tab_bar_position is Left)
53    #[serde(default = "crate::defaults::tab_bar_width")]
54    pub tab_bar_width: f32,
55
56    /// Show close button on tabs
57    #[serde(default = "crate::defaults::bool_true")]
58    pub tab_show_close_button: bool,
59
60    /// Show tab index numbers (for Cmd+1-9)
61    #[serde(default = "crate::defaults::bool_false")]
62    pub tab_show_index: bool,
63
64    /// New tab inherits working directory from active tab
65    #[serde(default = "crate::defaults::bool_true")]
66    pub tab_inherit_cwd: bool,
67
68    /// Maximum tabs per window (0 = unlimited)
69    #[serde(default = "crate::defaults::zero")]
70    pub max_tabs: usize,
71
72    /// Show the profile drawer toggle button on the right edge of the terminal
73    /// When disabled, the profile drawer can still be opened via keyboard shortcut
74    #[serde(default = "crate::defaults::bool_false")]
75    pub show_profile_drawer_button: bool,
76
77    /// When true, the new-tab keyboard shortcut (Cmd+T / Ctrl+Shift+T) shows the
78    /// profile selection dropdown instead of immediately opening a default tab
79    #[serde(default = "crate::defaults::bool_false")]
80    pub new_tab_shortcut_shows_profiles: bool,
81
82    /// Where to insert new tabs in the tab bar.
83    /// `end` appends to the end (default); `after_active` inserts right of the active tab.
84    #[serde(default)]
85    pub new_tab_position: NewTabPosition,
86}
87
88impl Default for TabConfig {
89    fn default() -> Self {
90        Self {
91            tab_style: TabStyle::default(),
92            light_tab_style: crate::defaults::light_tab_style(),
93            dark_tab_style: crate::defaults::dark_tab_style(),
94            tab_bar_mode: TabBarMode::default(),
95            tab_title_mode: TabTitleMode::default(),
96            remote_tab_title_format: RemoteTabTitleFormat::default(),
97            remote_tab_title_osc_priority: true,
98            tab_bar_height: crate::defaults::tab_bar_height(),
99            tab_bar_position: TabBarPosition::default(),
100            tab_bar_width: crate::defaults::tab_bar_width(),
101            tab_show_close_button: crate::defaults::bool_true(),
102            tab_show_index: crate::defaults::bool_false(),
103            tab_inherit_cwd: crate::defaults::bool_true(),
104            max_tabs: crate::defaults::zero(),
105            show_profile_drawer_button: crate::defaults::bool_false(),
106            new_tab_shortcut_shows_profiles: crate::defaults::bool_false(),
107            new_tab_position: NewTabPosition::default(),
108        }
109    }
110}