diff options
| author | xxanqw <[email protected]> | 2025-11-30 00:36:35 +0200 |
|---|---|---|
| committer | xxanqw <[email protected]> | 2025-11-30 00:36:35 +0200 |
| commit | d0350658ac3df17e1b4661cbbb103063721d5f31 (patch) | |
| tree | 9e125b93180b71b81a57a4390ff123d04274017b | |
| parent | 28e212e0ac79ce54526815437c2428deed252079 (diff) | |
| download | mikusays-c-d0350658ac3df17e1b4661cbbb103063721d5f31.tar.gz mikusays-c-d0350658ac3df17e1b4661cbbb103063721d5f31.zip | |
Fix Windows ANSI detection and enhance color debugging output
| -rw-r--r-- | src/color.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/color.rs b/src/color.rs index ba79353..809c66f 100644 --- a/src/color.rs +++ b/src/color.rs @@ -520,6 +520,9 @@ pub fn detect_color_mode() -> ColorMode { } // Default fallback + #[cfg(windows)] + let mut mode = ColorMode::Ansi16; + #[cfg(not(windows))] let mode = ColorMode::Ansi16; // If running on Windows, try to enable ANSI (virtual terminal processing) diff --git a/src/main.rs b/src/main.rs index 90fc061..23683b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -167,7 +167,7 @@ pub fn parse_color_args(args: &Args) -> Result<ColorConfig, Box<dyn Error>> { // Determine if ANSI is enabled (Windows toggle helper) — don't enable if --no-color #[cfg(windows)] - let ansi_enabled = !args.no_color && enable_windows_ansi(); + let ansi_enabled = !args.no_color && color::enable_windows_ansi(); #[cfg(not(windows))] let ansi_enabled = false; @@ -505,6 +505,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { // Parse color-related arguments let mut color_config = parse_color_args(&args)?; + if color_config.debug { + println!("Detected color mode: {:?}", color_config.mode); + println!("ANSI enabled: {}", color_config.ansi_enabled); + println!("NO_COLOR: {:?}", std::env::var("NO_COLOR").ok()); + println!("COLORTERM: {:?}", std::env::var("COLORTERM").ok()); + println!("TERM: {:?}", std::env::var("TERM").ok()); + #[cfg(windows)] + { + println!("Windows shell hint: {:?}", color::detect_windows_shell()); + } + return Ok(()); + } + // If color debug is requested, print information and exit if args.color_debug { eprintln!("Color Debug: mode={:?}, ansi_enabled={}, rainbow={}, saturation={}, brightness={}", |
