diff --git a/pretty.zig b/pretty.zig index ce894bc..f8e8009 100644 --- a/pretty.zig +++ b/pretty.zig @@ -38,7 +38,7 @@ pub const Theme = struct { color_true: Io.Terminal.Color = .bright_green, color_false: Io.Terminal.Color = .bright_red, - pub fn getColor(this: Theme, color: Colors) Io.Terminal.Color { + pub inline fn getColor(comptime this: Theme, comptime color: Colors) Io.Terminal.Color { return switch (color) { inline else => |col| @field(this, "color_" ++ @tagName(col)), }; @@ -96,7 +96,11 @@ const RuntimeContext = struct { indent_level: usize = 0, - pub inline fn print(this: *const RuntimeContext, comptime fmt: []const u8, args: anytype) error{WriteFailed}!void { + pub inline fn print( + this: *const RuntimeContext, + comptime fmt: []const u8, + args: anytype, + ) error{WriteFailed}!void { return this.out.print(fmt, args); } @@ -107,7 +111,7 @@ const RuntimeContext = struct { pub inline fn setColor( this: *const RuntimeContext, comptime ctx: ComptimeContext, - color: Theme.Colors, + comptime color: Theme.Colors, ) void { this.tty.setColor(ctx.options.theme.getColor(color)) catch {}; } @@ -205,7 +209,11 @@ inline fn formatBool( rctx: *const RuntimeContext, value: bool, ) !void { - rctx.setColor(cctx, if (value) .true else .false); + if (value) + rctx.setColor(cctx, .true) + else + rctx.setColor(cctx, .false); + try rctx.print("{}", .{value}); rctx.resetColor(); }