mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
windows: detect ANSI support in more terminals
This commit is contained in:
parent
729a051e9e
commit
59a12cd293
@ -230,6 +230,13 @@ pub const File = struct {
|
||||
/// Test whether ANSI escape codes will be treated as such.
|
||||
pub fn supportsAnsiEscapeCodes(self: File) bool {
|
||||
if (builtin.os.tag == .windows) {
|
||||
if (!os.isatty(self.handle)) return false;
|
||||
|
||||
var console_mode: os.windows.DWORD = 0;
|
||||
if (os.windows.kernel32.GetConsoleMode(self.handle, &console_mode) != 0) {
|
||||
if (console_mode & os.windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0) return true;
|
||||
}
|
||||
|
||||
return os.isCygwinPty(self.handle);
|
||||
}
|
||||
if (builtin.os.tag == .wasi) {
|
||||
|
||||
@ -3387,6 +3387,8 @@ pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
|
||||
dwMaximumWindowSize: COORD,
|
||||
};
|
||||
|
||||
pub const ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4;
|
||||
|
||||
pub const FOREGROUND_BLUE = 1;
|
||||
pub const FOREGROUND_GREEN = 2;
|
||||
pub const FOREGROUND_RED = 4;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user