authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-15 09:59:22+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-15 13:44:52-04:00
log7a4b53fdee89f2d61cedbb3cef3bda24dacf2a57
treee8bf09f0d0ef5196823eb9df5d2ac6882a0955ef
parent36da8d02b56e06c92279b4df21fbfaa0273e6c7b

std: Avoid using white color when printing stacktraces

Use .bold instead of .white, the effect is the same for light-on-dark terminals but greatly improves the readability for dark-on-light ones. Closes #8761

1 files changed, 4 insertions(+), 2 deletions(-)

lib/std/debug.zig+4-2
...@@ -306,6 +306,7 @@ const RED = "\x1b[31;1m";...@@ -306,6 +306,7 @@ const RED = "\x1b[31;1m";
306const GREEN = "\x1b[32;1m";306const GREEN = "\x1b[32;1m";
307const CYAN = "\x1b[36;1m";307const CYAN = "\x1b[36;1m";
308const WHITE = "\x1b[37;1m";308const WHITE = "\x1b[37;1m";
309const BOLD = "\x1b[1m";
309const DIM = "\x1b[2m";310const DIM = "\x1b[2m";
310const RESET = "\x1b[0m";311const RESET = "\x1b[0m";
311312
...@@ -476,8 +477,9 @@ pub const TTY = struct {...@@ -476,8 +477,9 @@ pub const TTY = struct {
476 .Red => out_stream.writeAll(RED) catch return,477 .Red => out_stream.writeAll(RED) catch return,
477 .Green => out_stream.writeAll(GREEN) catch return,478 .Green => out_stream.writeAll(GREEN) catch return,
478 .Cyan => out_stream.writeAll(CYAN) catch return,479 .Cyan => out_stream.writeAll(CYAN) catch return,
479 .White, .Bold => out_stream.writeAll(WHITE) catch return,480 .White => out_stream.writeAll(WHITE) catch return,
480 .Dim => out_stream.writeAll(DIM) catch return,481 .Dim => out_stream.writeAll(DIM) catch return,
482 .Bold => out_stream.writeAll(BOLD) catch return,
481 .Reset => out_stream.writeAll(RESET) catch return,483 .Reset => out_stream.writeAll(RESET) catch return,
482 },484 },
483 .windows_api => if (builtin.os.tag == .windows) {485 .windows_api => if (builtin.os.tag == .windows) {
...@@ -629,7 +631,7 @@ fn printLineInfo(...@@ -629,7 +631,7 @@ fn printLineInfo(
629 comptime printLineFromFile: anytype,631 comptime printLineFromFile: anytype,
630) !void {632) !void {
631 nosuspend {633 nosuspend {
632 tty_config.setColor(out_stream, .White);634 tty_config.setColor(out_stream, .Bold);
633635
634 if (line_info) |*li| {636 if (line_info) |*li| {
635 try out_stream.print("{s}:{d}:{d}", .{ li.file_name, li.line, li.column });637 try out_stream.print("{s}:{d}:{d}", .{ li.file_name, li.line, li.column });