Skip to main content

par_term_config/config/config_struct/
progress_bar_config.rs

1//! Progress bar overlay settings (OSC 9;4 and OSC 934).
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::{ProgressBarPosition, ProgressBarStyle};
8use serde::{Deserialize, Serialize};
9
10/// Progress bar overlay style, placement and state colours.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct ProgressBarConfig {
13    /// Enable progress bar overlay
14    /// When enabled, progress bars from OSC 9;4 and OSC 934 sequences are displayed
15    #[serde(default = "crate::defaults::bool_true")]
16    pub progress_bar_enabled: bool,
17
18    /// Progress bar visual style
19    /// - bar: Simple thin bar (default)
20    /// - bar_with_text: Bar with percentage text and labels
21    #[serde(default)]
22    pub progress_bar_style: ProgressBarStyle,
23
24    /// Progress bar position
25    /// - top: Display at the top of the terminal (default)
26    /// - bottom: Display at the bottom of the terminal
27    #[serde(default)]
28    pub progress_bar_position: ProgressBarPosition,
29
30    /// Progress bar height in pixels
31    #[serde(default = "crate::defaults::progress_bar_height")]
32    pub progress_bar_height: f32,
33
34    /// Progress bar opacity (0.0-1.0)
35    #[serde(default = "crate::defaults::progress_bar_opacity")]
36    pub progress_bar_opacity: f32,
37
38    /// Color for normal progress state [R, G, B] (0-255)
39    #[serde(default = "crate::defaults::progress_bar_normal_color")]
40    pub progress_bar_normal_color: [u8; 3],
41
42    /// Color for warning progress state [R, G, B] (0-255)
43    #[serde(default = "crate::defaults::progress_bar_warning_color")]
44    pub progress_bar_warning_color: [u8; 3],
45
46    /// Color for error progress state [R, G, B] (0-255)
47    #[serde(default = "crate::defaults::progress_bar_error_color")]
48    pub progress_bar_error_color: [u8; 3],
49
50    /// Color for indeterminate progress state [R, G, B] (0-255)
51    #[serde(default = "crate::defaults::progress_bar_indeterminate_color")]
52    pub progress_bar_indeterminate_color: [u8; 3],
53}
54
55impl Default for ProgressBarConfig {
56    fn default() -> Self {
57        Self {
58            progress_bar_enabled: crate::defaults::bool_true(),
59            progress_bar_style: ProgressBarStyle::default(),
60            progress_bar_position: ProgressBarPosition::default(),
61            progress_bar_height: crate::defaults::progress_bar_height(),
62            progress_bar_opacity: crate::defaults::progress_bar_opacity(),
63            progress_bar_normal_color: crate::defaults::progress_bar_normal_color(),
64            progress_bar_warning_color: crate::defaults::progress_bar_warning_color(),
65            progress_bar_error_color: crate::defaults::progress_bar_error_color(),
66            progress_bar_indeterminate_color: crate::defaults::progress_bar_indeterminate_color(),
67        }
68    }
69}