From ffcbd48a1220ce6d652ee762001d88baa385de49 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 9 Dec 2025 22:10:12 -0800 Subject: std: rework TTY detection and printing This commit sketches an idea for how to deal with detection of file streams as being terminals. When a File stream is a terminal, writes through the stream should have their escapes stripped unless the programmer explicitly enables terminal escapes. Furthermore, the programmer needs a convenient API for intentionally outputting escapes into the stream. In particular it should be possible to set colors that are silently discarded when the stream is not a terminal. This commit makes `Io.File.Writer` track the terminal mode in the already-existing `mode` field, making it the appropriate place to implement escape stripping. `Io.lockStderrWriter` returns a `*Io.File.Writer` with terminal detection already done by default. This is a higher-level application layer stream for writing to stderr. Meanwhile, `std.debug.lockStderrWriter` also returns a `*Io.File.Writer` but a lower-level one that is hard-coded to use a static single-threaded `std.Io.Threaded` instance. This is the same instance that is used for collecting debug information and iterating the unwind info. --- src/main.zig | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index bb940a1fe7..2eebb6d060 100644 --- a/src/main.zig +++ b/src/main.zig @@ -247,8 +247,6 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { threaded.stack_size = thread_stack_size; const io = threaded.io(); - debug_allocator.tty_config = .detect(io, .stderr()); - const cmd = args[1]; const cmd_args = args[2..]; if (mem.eql(u8, cmd, "build-exe")) { -- cgit v1.2.3