mirror of
https://github.com/ziglang/zig.git
synced 2025-12-17 11:43:16 +00:00
define an error set for std.io.tty.Config.setColor
This commit is contained in:
parent
e69caaa39f
commit
c4e3a49898
@ -70,7 +70,12 @@ pub const Config = union(enum) {
|
|||||||
reset_attributes: u16,
|
reset_attributes: u16,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn setColor(conf: Config, out_stream: anytype, color: Color) !void {
|
pub fn setColor(
|
||||||
|
conf: Config,
|
||||||
|
writer: anytype,
|
||||||
|
color: Color,
|
||||||
|
) (@typeInfo(@TypeOf(writer.writeAll(""))).ErrorUnion.error_set ||
|
||||||
|
windows.SetConsoleTextAttributeError)!void {
|
||||||
nosuspend switch (conf) {
|
nosuspend switch (conf) {
|
||||||
.no_color => return,
|
.no_color => return,
|
||||||
.escape_codes => {
|
.escape_codes => {
|
||||||
@ -95,7 +100,7 @@ pub const Config = union(enum) {
|
|||||||
.dim => "\x1b[2m",
|
.dim => "\x1b[2m",
|
||||||
.reset => "\x1b[0m",
|
.reset => "\x1b[0m",
|
||||||
};
|
};
|
||||||
try out_stream.writeAll(color_string);
|
try writer.writeAll(color_string);
|
||||||
},
|
},
|
||||||
.windows_api => |ctx| if (native_os == .windows) {
|
.windows_api => |ctx| if (native_os == .windows) {
|
||||||
const attributes = switch (color) {
|
const attributes = switch (color) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user