assume true color for any Windows Terminal session.

This commit is contained in:
David Wiesen
2025-10-06 16:10:47 -07:00
parent 5d1e66f7b5
commit 3d3ca6475d

View File

@@ -24,10 +24,18 @@ pub fn user_message_bg(terminal_bg: (u8, u8, u8)) -> Color {
(255, 255, 255)
};
let bottom = terminal_bg;
let Some(color_level) = supports_color::on_cached(supports_color::Stream::Stdout) else {
let Some(mut color_level) = supports_color::on_cached(supports_color::Stream::Stdout) else {
return Color::default();
};
#[cfg(windows)]
// Windows Terminal has been the default shell application for Windows since October 2022
// and has supported truecolor even longer. However it usually does not set COLORTERM to indicate that.
// so this is a pretty safe heuristic.
if std::env::var_os("WT_SESSION").is_some() {
color_level.has_16m = true;
}
let target = blend(top, bottom, 0.1);
if color_level.has_16m {
// In truecolor terminals we can use the exact RGB value.