Skip to content

Commit

Permalink
Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnim committed Nov 6, 2024
1 parent 9ca6515 commit f0717a6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib/utils/color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ fn determine_color_level() -> ColorLevel {
return color;
}

// Windows checks
if let Some(color) = windows_color_check() {
return color;
}

// CI check
if let Some(color) = ci_color_check() {
return color;
Expand Down Expand Up @@ -101,6 +106,13 @@ fn force_color_check() -> Option<ColorLevel> {
})
}

fn windows_color_check() -> Option<ColorLevel> {
if std::env::consts::OS == "windows" {
return Some(ColorLevel::Basic);
}
None
}

fn ci_color_check() -> Option<ColorLevel> {
if env::var("CI").is_ok() {
if env::var("GITHUB_ACTIONS").is_ok() || env::var("GITEA_ACTIONS").is_ok() {
Expand All @@ -120,6 +132,7 @@ fn term_color_check() -> Option<ColorLevel> {
Ok("xterm-kitty") | Ok("truecolor") | Ok("ansi") => Some(ColorLevel::TrueColor),
Ok(term) if term.ends_with("-256color") => Some(ColorLevel::Enhanced),
Ok(term) if term.starts_with("xterm") || term.starts_with("screen") => Some(ColorLevel::Basic),
Ok("cygwin") => Some(ColorLevel::Basic),
_ => None,
}
}
Expand All @@ -132,7 +145,6 @@ fn term_program_check() -> Option<ColorLevel> {
}
}


fn tty_color_check() -> Option<ColorLevel> {
if atty::is(atty::Stream::Stdout) {
return Some(ColorLevel::TrueColor);
Expand Down

0 comments on commit f0717a6

Please sign in to comment.