MCPcopy Create free account
hub / github.com/GCWing/BitFun / resolve_effective_color_scheme

Function resolve_effective_color_scheme

src/apps/cli/src/ui/theme.rs:70–90  ·  view source on GitHub ↗
(preference: &str)

Source from the content-addressed store, hash-verified

68}
69
70pub fn resolve_effective_color_scheme(preference: &str) -> EffectiveColorScheme {
71 if std::env::var_os("NO_COLOR").is_some() {
72 return EffectiveColorScheme::Monochrome;
73 }
74 if matches!(std::env::var("CLICOLOR").ok().as_deref(), Some("0")) {
75 return EffectiveColorScheme::Monochrome;
76 }
77
78 match preference.trim().to_ascii_lowercase().as_str() {
79 "mono" | "monochrome" | "nocolor" | "no_color" => EffectiveColorScheme::Monochrome,
80 "ansi" | "ansi16" => EffectiveColorScheme::Ansi16,
81 "truecolor" | "24bit" => EffectiveColorScheme::Truecolor,
82 "" | "default" | "auto" | _ => {
83 if terminal_supports_truecolor() {
84 EffectiveColorScheme::Truecolor
85 } else {
86 EffectiveColorScheme::Ansi16
87 }
88 }
89 }
90}
91
92fn terminal_supports_truecolor() -> bool {
93 if !std::io::stdout().is_terminal() {

Callers 5

newMethod · 0.85
current_base_themeMethod · 0.85
runMethod · 0.85
apply_theme_selectionMethod · 0.85

Calls 3

trimMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected