//! Config options around styling. mod battery; mod borders; mod cpu; mod disk_io_graph; mod graphs; mod memory; mod network; mod tables; mod temp_graph; mod themes; mod utils; mod widgets; use std::borrow::Cow; use battery::BatteryStyle; use cpu::CpuStyle; use disk_io_graph::DiskIoGraphStyle; use graphs::GraphStyle; use memory::MemoryStyle; use network::NetworkStyle; use ratatui::{style::Style, widgets::BorderType}; use serde::{Deserialize, Serialize}; use tables::TableStyle; use temp_graph::TempGraphStyle; use utils::{opt, set_colour, set_colour_list, set_style}; use widgets::WidgetStyle; use super::Config; use crate::options::{ OptionError, OptionResult, args::BottomArgs, config::style::utils::set_bg_colour, }; #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(feature = "generate_schema", derive(schemars::JsonSchema))] #[cfg_attr(test, derive(PartialEq, Eq))] pub(crate) struct ColourStr(Cow<'static, str>); /// A style for text. #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(untagged)] #[cfg_attr(feature = "generate_schema", derive(schemars::JsonSchema))] #[cfg_attr(test, serde(deny_unknown_fields), derive(PartialEq, Eq))] pub(crate) enum TextStyleConfig { Colour(ColourStr), TextStyle { /// A built-in ANSI colour, RGB hex, or RGB colour code. #[serde(alias = "color")] colour: Option, /// A built-in ANSI colour, RGB hex, or RGB colour code. #[serde(alias = "bg_color")] bg_colour: Option, /// Whether to make this text bolded or not. If not set, /// will default to built-in defaults. bold: Option, /// Whether to make this text italicized or not. If not set, /// will default to built-in defaults. italics: Option, }, } /// Style-related configs. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[cfg_attr(feature = "generate_schema", derive(schemars::JsonSchema))] #[cfg_attr(test, serde(deny_unknown_fields), derive(PartialEq, Eq))] pub(crate) struct StyleConfig { /// A built-in theme. /// /// If this is and a custom colour are both set, in the config file, /// the custom colour scheme will be prioritized first. If a theme /// is set in the command-line args, however, it will always be /// prioritized first. pub(crate) theme: Option>, /// Styling for the CPU widget. pub(crate) cpu: Option, /// Styling for the memory widget. pub(crate) memory: Option, /// Styling for the network widget. pub(crate) network: Option, /// Styling for the disk I/O graph widget. pub(crate) disk_io_graph: Option, /// Styling for the temperature graph widget. pub(crate) temp_graph: Option, /// Styling for the battery widget. pub(crate) battery: Option, /// Styling for table widgets. pub(crate) tables: Option, /// Styling for graph widgets. pub(crate) graphs: Option, /// Styling for general widgets. pub(crate) widgets: Option, } /// The actual internal representation of the configured styles. #[derive(Debug)] pub struct Styles { pub(crate) ram_style: Style, #[cfg(not(target_os = "windows"))] pub(crate) cache_style: Style, pub(crate) swap_style: Style, #[cfg(feature = "zfs")] pub(crate) arc_style: Style, #[cfg(feature = "gpu")] pub(crate) gpu_colours: Vec