Skip to main content

par_term_config/config/config_struct/
status_bar_config.rs

1//! [`StatusBarConfig`]: Status bar settings.
2
3use crate::types::StatusBarPosition;
4use serde::{Deserialize, Serialize};
5
6/// Configuration for the status bar displayed at the top or bottom of the terminal.
7///
8/// Extracted from the monolithic `Config` struct via `#[serde(flatten)]`.
9/// All fields that were previously `status_bar_*` on `Config` are now
10/// grouped here, keeping the YAML format fully backward-compatible.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12#[serde(default)]
13pub struct StatusBarConfig {
14    /// Enable the status bar
15    #[serde(default = "default_status_bar_enabled")]
16    pub status_bar_enabled: bool,
17
18    /// Status bar position (top or bottom)
19    #[serde(default)]
20    pub status_bar_position: StatusBarPosition,
21
22    /// Status bar height in pixels
23    #[serde(default = "default_status_bar_height")]
24    pub status_bar_height: f32,
25
26    /// Status bar background color [R, G, B] (0-255)
27    #[serde(default = "default_status_bar_bg_color")]
28    pub status_bar_bg_color: [u8; 3],
29
30    /// Status bar background alpha (0.0-1.0)
31    #[serde(default = "default_status_bar_bg_alpha")]
32    pub status_bar_bg_alpha: f32,
33
34    /// Status bar foreground (text) color [R, G, B] (0-255)
35    #[serde(default = "default_status_bar_fg_color")]
36    pub status_bar_fg_color: [u8; 3],
37
38    /// Status bar font family (empty string = use terminal font)
39    #[serde(default)]
40    pub status_bar_font: String,
41
42    /// Status bar font size in points
43    #[serde(default = "default_status_bar_font_size")]
44    pub status_bar_font_size: f32,
45
46    /// Separator string between widgets
47    #[serde(default = "default_status_bar_separator")]
48    pub status_bar_separator: String,
49
50    /// Auto-hide the status bar when in fullscreen mode
51    #[serde(default = "default_status_bar_auto_hide_fullscreen")]
52    pub status_bar_auto_hide_fullscreen: bool,
53
54    /// Auto-hide the status bar when mouse is inactive
55    #[serde(default = "default_status_bar_auto_hide_mouse_inactive")]
56    pub status_bar_auto_hide_mouse_inactive: bool,
57
58    /// Timeout in seconds before hiding status bar after last mouse activity
59    #[serde(default = "default_status_bar_mouse_inactive_timeout")]
60    pub status_bar_mouse_inactive_timeout: f32,
61
62    /// Polling interval in seconds for system monitor data (CPU, memory, network)
63    #[serde(default = "default_status_bar_system_poll_interval")]
64    pub status_bar_system_poll_interval: f32,
65
66    /// Polling interval in seconds for git branch detection
67    #[serde(default = "default_status_bar_git_poll_interval")]
68    pub status_bar_git_poll_interval: f32,
69
70    /// Polling interval in seconds for disk free-space data
71    #[serde(default = "default_status_bar_disk_poll_interval")]
72    pub status_bar_disk_poll_interval: f32,
73
74    /// Whether the disk widget follows the active tab's CWD (true) or uses the
75    /// disk par-term was launched from (false, default).
76    #[serde(default = "default_status_bar_disk_follow_cwd")]
77    pub status_bar_disk_follow_cwd: bool,
78
79    /// Time format string for the Clock widget (chrono strftime syntax)
80    #[serde(default = "default_status_bar_time_format")]
81    pub status_bar_time_format: String,
82
83    /// Show ahead/behind and dirty indicators on the Git Branch widget
84    #[serde(default = "default_status_bar_git_show_status")]
85    pub status_bar_git_show_status: bool,
86
87    /// Widget configuration list
88    #[serde(default = "crate::status_bar::default_widgets")]
89    pub status_bar_widgets: Vec<crate::status_bar::StatusBarWidgetConfig>,
90}
91
92// ── Default value functions ────────────────────────────────────────────────
93
94fn default_status_bar_enabled() -> bool {
95    false
96}
97
98fn default_status_bar_height() -> f32 {
99    22.0
100}
101
102fn default_status_bar_bg_color() -> [u8; 3] {
103    [30, 30, 30]
104}
105
106fn default_status_bar_bg_alpha() -> f32 {
107    0.95
108}
109
110fn default_status_bar_fg_color() -> [u8; 3] {
111    [200, 200, 200]
112}
113
114fn default_status_bar_font_size() -> f32 {
115    12.0
116}
117
118fn default_status_bar_separator() -> String {
119    " \u{2502} ".to_string() // " │ "
120}
121
122fn default_status_bar_auto_hide_fullscreen() -> bool {
123    true
124}
125
126fn default_status_bar_auto_hide_mouse_inactive() -> bool {
127    false
128}
129
130fn default_status_bar_mouse_inactive_timeout() -> f32 {
131    3.0
132}
133
134fn default_status_bar_system_poll_interval() -> f32 {
135    2.0
136}
137
138fn default_status_bar_git_poll_interval() -> f32 {
139    5.0
140}
141
142fn default_status_bar_disk_poll_interval() -> f32 {
143    60.0
144}
145
146fn default_status_bar_disk_follow_cwd() -> bool {
147    false
148}
149
150fn default_status_bar_time_format() -> String {
151    "%H:%M:%S".to_string()
152}
153
154fn default_status_bar_git_show_status() -> bool {
155    true
156}
157
158impl Default for StatusBarConfig {
159    fn default() -> Self {
160        Self {
161            status_bar_enabled: default_status_bar_enabled(),
162            status_bar_position: StatusBarPosition::default(),
163            status_bar_height: default_status_bar_height(),
164            status_bar_bg_color: default_status_bar_bg_color(),
165            status_bar_bg_alpha: default_status_bar_bg_alpha(),
166            status_bar_fg_color: default_status_bar_fg_color(),
167            status_bar_font: String::new(),
168            status_bar_font_size: default_status_bar_font_size(),
169            status_bar_separator: default_status_bar_separator(),
170            status_bar_auto_hide_fullscreen: default_status_bar_auto_hide_fullscreen(),
171            status_bar_auto_hide_mouse_inactive: default_status_bar_auto_hide_mouse_inactive(),
172            status_bar_mouse_inactive_timeout: default_status_bar_mouse_inactive_timeout(),
173            status_bar_system_poll_interval: default_status_bar_system_poll_interval(),
174            status_bar_git_poll_interval: default_status_bar_git_poll_interval(),
175            status_bar_disk_poll_interval: default_status_bar_disk_poll_interval(),
176            status_bar_disk_follow_cwd: default_status_bar_disk_follow_cwd(),
177            status_bar_time_format: default_status_bar_time_format(),
178            status_bar_git_show_status: default_status_bar_git_show_status(),
179            status_bar_widgets: crate::status_bar::default_widgets(),
180        }
181    }
182}