authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-11-13 17:41:20+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-10 10:29:16+03:00
logc4e3a49898fbfaf5fe890385656dac62ef3028fc
tree8a61fe0fd6131c2940888cf9c6d6ff5e8d749d67
parente69caaa39f06b7ddf00c1e439c3df91f4efbdef3

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) {
7070 reset_attributes: u16,
7171 };
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 {
7479 nosuspend switch (conf) {
7580 .no_color => return,
7681 .escape_codes => {
......@@ -95,7 +100,7 @@ pub const Config = union(enum) {
95100 .dim => "\x1b[2m",
96101 .reset => "\x1b[0m",
97102 };
98 try out_stream.writeAll(color_string);
103 try writer.writeAll(color_string);
99104 },
100105 .windows_api => |ctx| if (native_os == .windows) {
101106 const attributes = switch (color) {