Skip to main content

par_term_config/config/config_struct/
image_config.rs

1//! Inline image and terminal background 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::{BackgroundMode, ImageScalingMode};
8use serde::{Deserialize, Serialize};
9
10/// Inline image scaling (Sixel/iTerm2/Kitty) and the terminal background source.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct ImageConfig {
13    /// Scaling quality for inline images (nearest = sharp/pixel art, linear = smooth)
14    #[serde(default)]
15    pub image_scaling_mode: ImageScalingMode,
16
17    /// Preserve aspect ratio when scaling inline images to fit terminal cells
18    #[serde(default = "crate::defaults::bool_true")]
19    pub image_preserve_aspect_ratio: bool,
20
21    /// Background mode selection (default, color, or image)
22    #[serde(default)]
23    pub background_mode: BackgroundMode,
24
25    /// Per-pane background image configurations
26    #[serde(default)]
27    pub pane_backgrounds: Vec<crate::config::PaneBackgroundConfig>,
28
29    /// Custom solid background color [R, G, B] (0-255)
30    /// Used when background_mode is "color"
31    /// Transparency is controlled by window_opacity
32    #[serde(default = "crate::defaults::background_color")]
33    pub background_color: [u8; 3],
34}
35
36impl Default for ImageConfig {
37    fn default() -> Self {
38        Self {
39            image_scaling_mode: ImageScalingMode::default(),
40            image_preserve_aspect_ratio: crate::defaults::bool_true(),
41            background_mode: BackgroundMode::default(),
42            pane_backgrounds: Vec::new(),
43            background_color: crate::defaults::background_color(),
44        }
45    }
46}