tangled
alpha
login
or
join now
altagos.dev
/
pretty
0
fork
atom
A pretty printer for zig
zig
0
fork
atom
overview
issues
pulls
pipelines
resolve theme colors at comptime
altagos.dev
1 month ago
b657057a
967a7ac2
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+12
-4
1 changed file
expand all
collapse all
unified
split
pretty.zig
+12
-4
pretty.zig
···
38
38
color_true: Io.Terminal.Color = .bright_green,
39
39
color_false: Io.Terminal.Color = .bright_red,
40
40
41
41
-
pub fn getColor(this: Theme, color: Colors) Io.Terminal.Color {
41
41
+
pub inline fn getColor(comptime this: Theme, comptime color: Colors) Io.Terminal.Color {
42
42
return switch (color) {
43
43
inline else => |col| @field(this, "color_" ++ @tagName(col)),
44
44
};
···
96
96
97
97
indent_level: usize = 0,
98
98
99
99
-
pub inline fn print(this: *const RuntimeContext, comptime fmt: []const u8, args: anytype) error{WriteFailed}!void {
99
99
+
pub inline fn print(
100
100
+
this: *const RuntimeContext,
101
101
+
comptime fmt: []const u8,
102
102
+
args: anytype,
103
103
+
) error{WriteFailed}!void {
100
104
return this.out.print(fmt, args);
101
105
}
102
106
···
107
111
pub inline fn setColor(
108
112
this: *const RuntimeContext,
109
113
comptime ctx: ComptimeContext,
110
110
-
color: Theme.Colors,
114
114
+
comptime color: Theme.Colors,
111
115
) void {
112
116
this.tty.setColor(ctx.options.theme.getColor(color)) catch {};
113
117
}
···
205
209
rctx: *const RuntimeContext,
206
210
value: bool,
207
211
) !void {
208
208
-
rctx.setColor(cctx, if (value) .true else .false);
212
212
+
if (value)
213
213
+
rctx.setColor(cctx, .true)
214
214
+
else
215
215
+
rctx.setColor(cctx, .false);
216
216
+
209
217
try rctx.print("{}", .{value});
210
218
rctx.resetColor();
211
219
}