mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-10-31 17:15:28 +08:00 
			
		
		
		
	Fix console detection for Cygwin/WSL-Shell on Windows
This commit is contained in:
		| @@ -54,6 +54,11 @@ namespace Spectre.Console.Internal | ||||
|                 return (supportsAnsi, legacyConsole); | ||||
|             } | ||||
|  | ||||
|             return DetectFromTerm(); | ||||
|         } | ||||
|  | ||||
|         private static (bool SupportsAnsi, bool LegacyConsole) DetectFromTerm() | ||||
|         { | ||||
|             // Check if the terminal is of type ANSI/VT100/xterm compatible. | ||||
|             var term = Environment.GetEnvironmentVariable("TERM"); | ||||
|             if (!string.IsNullOrWhiteSpace(term)) | ||||
| @@ -101,8 +106,11 @@ namespace Spectre.Console.Internal | ||||
|                     var @out = GetStdHandle(STD_OUTPUT_HANDLE); | ||||
|                     if (!GetConsoleMode(@out, out var mode)) | ||||
|                     { | ||||
|                         // Could not get console mode. | ||||
|                         return false; | ||||
|                         // Could not get console mode, try TERM (set in cygwin, WSL-Shell). | ||||
|                         var (ansiFromTerm, legacyFromTerm) = DetectFromTerm(); | ||||
|  | ||||
|                         isLegacy = ansiFromTerm ? legacyFromTerm : isLegacy; | ||||
|                         return ansiFromTerm; | ||||
|                     } | ||||
|  | ||||
|                     if ((mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Matt Constable
					Matt Constable