Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

supportsAnsiEscapeCodes

Private Function
std.Io.Threaded.supportsAnsiEscapeCodes
fn supportsAnsiEscapeCodes(t: *Threaded, file: File) Io.Cancelable!bool

Params

File

Io/Threaded.zig:8964
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
fn supportsAnsiEscapeCodes(t: *Threaded, file: File) Io.Cancelable!bool {
    if (is_windows) {
        var get_console_mode = windows.CONSOLE.USER_IO.GET_MODE;
        return switch ((try deviceIoControl(&.{
            .file = .{
                .handle = windows.peb().ProcessParameters.ConsoleHandle,
                .flags = .{ .nonblocking = false },
            },
            .code = windows.IOCTL.CONDRV.ISSUE_USER_IO,
            .in = @ptrCast(&get_console_mode.request(file, 0, .{}, 0, .{})),
        })).u.Status) {
            .SUCCESS => get_console_mode.Data & windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0,
            .CANCELLED => unreachable,
            .INVALID_HANDLE => isCygwinPty(file),
            else => false,
        };
    }

    if (native_os == .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 (try isTty(file)) {
        if (file.handle == posix.STDOUT_FILENO or file.handle == posix.STDERR_FILENO) {
            t.scanEnviron();
            if (t.environ.string.TERM) |term| {
                if (std.mem.eql(u8, term, "dumb")) {
                    return false;
                }
            }
        }

        return true;
    }

    return false;
}