Implement some more environment functions for WASI.
This commit is contained in:
@@ -110,27 +110,28 @@ pub fn getSelfDebugInfo() !*DebugInfo {
|
||||
}
|
||||
|
||||
pub fn detectTTYConfig(file: std.fs.File) TTY.Config {
|
||||
if (process.hasEnvVarConstant("ZIG_DEBUG_COLOR")) {
|
||||
if (builtin.os.tag == .wasi) {
|
||||
// Per https://github.com/WebAssembly/WASI/issues/162 ANSI codes
|
||||
// aren't currently supported.
|
||||
return .no_color;
|
||||
} else if (process.hasEnvVarConstant("ZIG_DEBUG_COLOR")) {
|
||||
return .escape_codes;
|
||||
} else if (process.hasEnvVarConstant("NO_COLOR")) {
|
||||
return .no_color;
|
||||
} else {
|
||||
if (file.supportsAnsiEscapeCodes()) {
|
||||
return .escape_codes;
|
||||
} else if (native_os == .windows and file.isTty()) {
|
||||
var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
|
||||
if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) {
|
||||
// TODO: Should this return an error instead?
|
||||
return .no_color;
|
||||
}
|
||||
return .{ .windows_api = .{
|
||||
.handle = file.handle,
|
||||
.reset_attributes = info.wAttributes,
|
||||
} };
|
||||
} else {
|
||||
} else if (file.supportsAnsiEscapeCodes()) {
|
||||
return .escape_codes;
|
||||
} else if (native_os == .windows and file.isTty()) {
|
||||
var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
|
||||
if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) {
|
||||
// TODO: Should this return an error instead?
|
||||
return .no_color;
|
||||
}
|
||||
return .{ .windows_api = .{
|
||||
.handle = file.handle,
|
||||
.reset_attributes = info.wAttributes,
|
||||
} };
|
||||
}
|
||||
return .no_color;
|
||||
}
|
||||
|
||||
/// Tries to print the current stack trace to stderr, unbuffered, and ignores any error returned.
|
||||
|
||||
Reference in New Issue
Block a user