A pretty printer for zig
zig

reorder

altagos.dev 6da8186d 07bf4d26

verified
+22 -23
+22 -23
pretty.zig
··· 21 21 22 22 inline_arrays: bool = false, 23 23 always_show_index: bool = false, 24 + treat_u8_arrays_as_strings: bool = true, 24 25 25 26 inline_structs: bool = false, 26 27 27 28 show_type_names: bool = true, 28 29 always_show_type_names: bool = false, 29 - 30 - treat_u8_arrays_as_strings: bool = true, 31 30 32 31 theme: Theme = .{}, 33 32 }; ··· 246 245 run.resetColor(); 247 246 } 248 247 248 + inline fn formatType( 249 + comptime ctx: Context, 250 + run: *const Runtime, 251 + value: type, 252 + ) !void { 253 + run.setColor(ctx, .type); 254 + run.setColorRaw(.bold); 255 + try run.write(@typeName(value)); 256 + run.resetColor(); 257 + } 258 + 259 + inline fn formatValue( 260 + comptime ctx: Context, 261 + run: *const Runtime, 262 + value: anytype, 263 + ) !void { 264 + run.setColor(ctx, .value); 265 + try run.print("{}", .{value}); 266 + run.resetColor(); 267 + } 268 + 249 269 inline fn formatOptional( 250 270 comptime T: type, 251 271 comptime ctx: Context, ··· 378 398 val, 379 399 .{ .skip_type_name = true }, 380 400 ); 381 - } 382 - 383 - inline fn formatType( 384 - comptime ctx: Context, 385 - run: *const Runtime, 386 - value: type, 387 - ) !void { 388 - run.setColor(ctx, .type); 389 - run.setColorRaw(.bold); 390 - try run.write(@typeName(value)); 391 - run.resetColor(); 392 - } 393 - 394 - inline fn formatValue( 395 - comptime ctx: Context, 396 - run: *const Runtime, 397 - value: anytype, 398 - ) !void { 399 - run.setColor(ctx, .value); 400 - try run.print("{}", .{value}); 401 - run.resetColor(); 402 401 } 403 402 404 403 inline fn formatFn(