authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-11-13 17:41:20+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-22 07:02:54-07:00
log1216050520008b9cbd5b287a3eb0b2eba4cf5056
treeac910f0847eed66ceda7e2ef520e2ec0dec49a92
parent8832314acf1c330c18027c77967ffc4a5df9fe2c

define an error set for `std.io.tty.Config.setColor`


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

lib/std/io/tty.zig+7-2
...@@ -70,7 +70,12 @@ pub const Config = union(enum) {...@@ -70,7 +70,12 @@ pub const Config = union(enum) {
70 reset_attributes: u16,70 reset_attributes: u16,
71 };71 };
7272
73 pub fn setColor(conf: Config, out_stream: anytype, color: Color) !void {73 pub fn setColor(
74 conf: Config,
75 writer: anytype,
76 color: Color,
77 ) (@typeInfo(@TypeOf(writer.writeAll(""))).ErrorUnion.error_set ||
78 windows.SetConsoleTextAttributeError)!void {
74 nosuspend switch (conf) {79 nosuspend switch (conf) {
75 .no_color => return,80 .no_color => return,
76 .escape_codes => {81 .escape_codes => {
...@@ -95,7 +100,7 @@ pub const Config = union(enum) {...@@ -95,7 +100,7 @@ pub const Config = union(enum) {
95 .dim => "\x1b[2m",100 .dim => "\x1b[2m",
96 .reset => "\x1b[0m",101 .reset => "\x1b[0m",
97 };102 };
98 try out_stream.writeAll(color_string);103 try writer.writeAll(color_string);
99 },104 },
100 .windows_api => |ctx| if (native_os == .windows) {105 .windows_api => |ctx| if (native_os == .windows) {
101 const attributes = switch (color) {106 const attributes = switch (color) {