use crate::config::theme::indexed_fallback_theme;
use crate::config::{Config, ThemeFile};
use crate::terminal::{Capabilities, ColorDepth};
pub(super) struct Downgrade {
pub theme_file: ThemeFile,
pub configured: String,
pub substituted: &'static str,
}
pub(super) fn apply(config: &mut Config, caps: &Capabilities) -> Option<Downgrade> {
if caps.full_color() || caps.color_depth == ColorDepth::NoColor {
return None;
}
let substituted = indexed_fallback_theme(&config.theme, config.appearance)?;
let (theme_file, _) = Config::load_theme(substituted, false);
let configured = config.theme.clone();
config.theme_downgraded_from = Some(configured.clone());
config.theme = substituted.to_owned();
Some(Downgrade {
theme_file,
configured,
substituted,
})
}