feat(debug): render debug support

This commit is contained in:
2025-05-26 15:43:47 +02:00
parent 2572b57697
commit c6d8eec287
3 changed files with 77 additions and 145 deletions

View File

@@ -145,6 +145,13 @@ pub const Rectangle = packed struct {
cells[(row * size.x) + col].style.bg = this.fill;
}
}
// DEBUG render corresponding beginning of the rectangle for this `Container` *red*
if (comptime build_options.debug) {
cells[0].style.fg = .red;
cells[0].style.bg = .black;
cells[0].cp = 'r'; // 'r' for *rectangle*
}
}
test "fill color overwrite parent fill" {
@@ -349,8 +356,11 @@ pub const Layout = packed struct {
}
// DEBUG render corresponding beginning of the separator for this `Container` *red*
// cells[anchor].style.fg = .red;
// cells[anchor].style.bg = .red;
if (comptime build_options.debug) {
cells[anchor].style.fg = .red;
cells[anchor].style.bg = .black;
cells[anchor].cp = 's'; // 's' for *separator*
}
}
}
}
@@ -875,9 +885,21 @@ pub fn Container(comptime Event: type) type {
try this.element.content(cells, this.size);
// DEBUG render corresponding top left corner of this `Container` *red*
// cells[0].style.fg = .red;
// cells[0].style.bg = .red;
// DEBUG render corresponding corners (except top left) of this `Container` *red*
if (comptime build_options.debug) {
// top right
cells[this.size.x -| 1].style.fg = .red;
cells[this.size.x -| 1].style.bg = .black;
cells[this.size.x -| 1].cp = 'c'; // 'c' for *container*
// bottom left
cells[this.size.x * (this.size.y -| 1)].style.fg = .red;
cells[this.size.x * (this.size.y -| 1)].style.bg = .black;
cells[this.size.x * (this.size.y -| 1)].cp = 'c'; // 'c' for *container*
// bottom right
cells[this.size.x * this.size.y -| 1].style.fg = .red;
cells[this.size.x * this.size.y -| 1].style.bg = .black;
cells[this.size.x * this.size.y -| 1].cp = 'c'; // 'c' for *container*
}
return cells;
}
@@ -889,6 +911,7 @@ const log = std.log.scoped(.container);
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const build_options = @import("build_options");
const input = @import("input.zig");
const isTaggedUnion = @import("event.zig").isTaggedUnion;
const Cell = @import("cell.zig");