use std::collections::BTreeMap;
use crate::theme::GlyphVariant;
pub const CALCLI_THEME: &str = "calcli";
pub const DEFAULT_CURSOR_COLOR: &str = "#d65c5c";
pub const DEFAULT_INPUT_BG: &str = "#100e15";
pub const DEFAULT_INPUT_BG_ACTIVE: &str = "#262336";
pub const DEFAULT_SELECTION_COLOR: &str = "#354440";
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Appearance {
pub theme: String,
pub colors: BTreeMap<String, String>,
pub glyphs: GlyphVariant,
}
impl Default for Appearance {
fn default() -> Self {
Appearance {
theme: CALCLI_THEME.to_string(),
colors: BTreeMap::from([
("cursor".to_string(), DEFAULT_CURSOR_COLOR.to_string()),
("input_bg".to_string(), DEFAULT_INPUT_BG.to_string()),
(
"input_bg_active".to_string(),
DEFAULT_INPUT_BG_ACTIVE.to_string(),
),
("selection".to_string(), DEFAULT_SELECTION_COLOR.to_string()),
]),
glyphs: GlyphVariant::default(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn defaults_select_the_calcli_theme_and_a_red_cursor() {
let appearance = Appearance::default();
assert_eq!(appearance.theme, CALCLI_THEME);
assert_eq!(
appearance.colors.get("cursor").map(String::as_str),
Some(DEFAULT_CURSOR_COLOR),
);
assert_eq!(appearance.glyphs, GlyphVariant::Unicode);
}
#[test]
fn the_selection_tint_is_defaulted_rather_than_derived() {
let appearance = Appearance::default();
assert_eq!(
appearance.colors.get("selection").map(String::as_str),
Some(DEFAULT_SELECTION_COLOR),
);
}
#[test]
fn the_input_fills_are_defaulted_rather_than_derived() {
let appearance = Appearance::default();
assert_eq!(
appearance.colors.get("input_bg").map(String::as_str),
Some(DEFAULT_INPUT_BG),
);
assert_eq!(
appearance.colors.get("input_bg_active").map(String::as_str),
Some(DEFAULT_INPUT_BG_ACTIVE),
);
}
}