use crossterm::style::Color;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ColorConfig {
pub enabled: bool,
#[serde(flatten)]
pub settings: ColorSettings,
}
impl Default for ColorSettings {
fn default() -> Self {
Self {
link: Color::Green,
unlink: Color::Red,
list: Color::Cyan,
remove: Color::Red,
create: Color::Green,
arrow: Color::Blue,
source: Color::Yellow,
target: Color::Magenta,
}
}
}
impl Display for ColorSettings {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"ColorSettings {{ link_color: {:?}, unlink_color: {:?}, list_color: {:?}, remove_color: {:?}, create_color: {:?}, arrow_color: {:?}, source_color: {:?}, target_color: {:?} }}",
self.link, self.unlink, self.list, self.remove, self.create, self.arrow, self.source, self.target
)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ColorSettings {
pub link: Color,
pub unlink: Color,
pub list: Color,
pub remove: Color,
pub create: Color,
pub arrow: Color,
pub source: Color,
pub target: Color,
}
impl Default for ColorConfig {
fn default() -> Self {
Self {
enabled: true,
settings: ColorSettings::default(),
}
}
}
impl Display for ColorConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"ColorConfig {{ enabled: {}, settings: {} }}",
self.enabled, self.settings
)
}
}