| author | |
| committer | |
| log | 28862dd30c7152e6033abdb5daee3230ac39500a |
| tree | b23c538fc3af1bb8a4b88416ce775ec89748fa96 |
| parent | 3ef91233caf2c637797d84527a4e78f870e4b4b9 |
| parent | 5439f36c976ac31f7faa27cc1536a0ecd3c4469f |
| signature |
windows: detect ANSI support in more terminals2 files changed, 7 insertions(+), 0 deletions(-)
lib/std/fs/file.zig+5| ... | @@ -230,6 +230,11 @@ pub const File = struct { | ... | @@ -230,6 +230,11 @@ pub const File = struct { |
| 230 | /// Test whether ANSI escape codes will be treated as such. | 230 | /// Test whether ANSI escape codes will be treated as such. |
| 231 | pub fn supportsAnsiEscapeCodes(self: File) bool { | 231 | pub fn supportsAnsiEscapeCodes(self: File) bool { |
| 232 | if (builtin.os.tag == .windows) { | 232 | if (builtin.os.tag == .windows) { |
| 233 | var console_mode: os.windows.DWORD = 0; | ||
| 234 | if (os.windows.kernel32.GetConsoleMode(self.handle, &console_mode) != 0) { | ||
| 235 | if (console_mode & os.windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0) return true; | ||
| 236 | } | ||
| 237 | |||
| 233 | return os.isCygwinPty(self.handle); | 238 | return os.isCygwinPty(self.handle); |
| 234 | } | 239 | } |
| 235 | if (builtin.os.tag == .wasi) { | 240 | if (builtin.os.tag == .wasi) { |
lib/std/os/windows.zig+2| ... | @@ -3387,6 +3387,8 @@ pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct { | ... | @@ -3387,6 +3387,8 @@ pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct { |
| 3387 | dwMaximumWindowSize: COORD, | 3387 | dwMaximumWindowSize: COORD, |
| 3388 | }; | 3388 | }; |
| 3389 | 3389 | ||
| 3390 | pub const ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4; | ||
| 3391 | |||
| 3390 | pub const FOREGROUND_BLUE = 1; | 3392 | pub const FOREGROUND_BLUE = 1; |
| 3391 | pub const FOREGROUND_GREEN = 2; | 3393 | pub const FOREGROUND_GREEN = 2; |
| 3392 | pub const FOREGROUND_RED = 4; | 3394 | pub const FOREGROUND_RED = 4; |