Function supportsAnsiEscapeCodes [src]

Test whether ANSI escape codes will be treated as such without attempting to enable support for ANSI escape codes. See also getOrEnableAnsiEscapeSupport.

Prototype

pub fn supportsAnsiEscapeCodes(self: File) bool

Parameters

self: File

Source

pub fn supportsAnsiEscapeCodes(self: File) bool { if (builtin.os.tag == .windows) { var console_mode: windows.DWORD = 0; if (windows.kernel32.GetConsoleMode(self.handle, &console_mode) != 0) { if (console_mode & windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0) return true; } return self.isCygwinPty(); } if (builtin.os.tag == .wasi) { // WASI sanitizes stdout when fd is a tty so ANSI escape codes // will not be interpreted as actual cursor commands, and // stderr is always sanitized. return false; } if (self.isTty()) { if (self.handle == posix.STDOUT_FILENO or self.handle == posix.STDERR_FILENO) { if (posix.getenvZ("TERM")) |term| { if (std.mem.eql(u8, term, "dumb")) return false; } } return true; } return false; }