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
optimize print statements in printType
altagos.dev
1 month ago
85e3cdf9
94f031c1
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+18
-18
1 changed file
expand all
collapse all
unified
split
pretty.zig
+18
-18
pretty.zig
···
59
59
60
60
indent_level: usize = 0,
61
61
62
62
-
pub fn print(this: RuntimeContext, comptime fmt: []const u8, args: anytype) error{WriteFailed}!void {
62
62
+
pub inline fn print(this: RuntimeContext, comptime fmt: []const u8, args: anytype) error{WriteFailed}!void {
63
63
return this.out.print(fmt, args);
64
64
}
65
65
66
66
-
pub fn setColor(this: RuntimeContext, color: Io.Terminal.Color) void {
66
66
+
pub inline fn write(this: RuntimeContext, text: []const u8) error{WriteFailed}!void {
67
67
+
return this.out.writeAll(text);
68
68
+
}
69
69
+
70
70
+
pub inline fn setColor(this: RuntimeContext, color: Io.Terminal.Color) void {
67
71
this.tty.setColor(color) catch {};
68
72
}
69
73
70
70
-
pub fn resetColor(this: RuntimeContext) void {
74
74
+
pub inline fn resetColor(this: RuntimeContext) void {
71
75
this.tty.setColor(.reset) catch {};
72
76
}
73
77
};
···
125
129
126
130
if (cctx.options.show_type_names) {
127
131
switch (info) {
128
128
-
.bool => try rctx.print("bool{s}", .{cctx.options.type_value_seperator}),
129
129
-
.comptime_int => try rctx.print("comptime_int{s}", .{cctx.options.type_value_seperator}),
130
130
-
.comptime_float => try rctx.print("comptime_float{s}", .{cctx.options.type_value_seperator}),
132
132
+
.bool => try rctx.write("bool"),
133
133
+
.comptime_int => try rctx.write("comptime_int"),
134
134
+
.comptime_float => try rctx.write("comptime_float"),
131
135
.int => |int| try rctx.print(
132
132
-
"{s}{}{s}",
133
133
-
.{
134
134
-
if (int.signedness == .signed) "i" else "u",
135
135
-
int.bits,
136
136
-
cctx.options.type_value_seperator,
137
137
-
},
136
136
+
"{s}{}",
137
137
+
.{ if (int.signedness == .signed) "i" else "u", int.bits },
138
138
),
139
139
-
.float => |float| try rctx.print("f{}{s}", .{ float.bits, cctx.options.type_value_seperator }),
140
140
-
.enum_literal => try rctx.print("enum literal{s}", .{cctx.options.type_value_seperator}),
141
141
-
.@"enum" => try rctx.print("{s}{s}", .{ @typeName(T), cctx.options.type_value_seperator }),
142
142
-
else => try rctx.print("missing {}{s}", .{ info, cctx.options.type_value_seperator }),
139
139
+
.float => |float| try rctx.print("f{}", .{float.bits}),
140
140
+
.enum_literal => try rctx.write("enum literal"),
141
141
+
.@"enum" => try rctx.write(@typeName(T)),
142
142
+
else => try rctx.print("missing type {}", .{info}),
143
143
}
144
144
-
} else {
145
145
-
try rctx.print("{s}", .{cctx.options.type_value_seperator});
146
144
}
145
145
+
146
146
+
try rctx.write(cctx.options.type_value_seperator);
147
147
148
148
rctx.resetColor();
149
149
}