fix(widget): respect size for RawText and Spacer Widgets
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 36s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 36s
This commit is contained in:
@@ -142,25 +142,12 @@ pub fn Layout(comptime Event: type, comptime Renderer: type) type {
|
||||
|
||||
pub fn render(this: *@This(), renderer: Renderer) !void {
|
||||
// FIX: renderer should clear only what is going to change! (i.e. the 'active' widget / layout)
|
||||
try renderer.clear(this.anchor, this.size);
|
||||
var overflow = this.size.rows % this.elements.items.len;
|
||||
for (this.elements.items, 0..) |*element, i| {
|
||||
const row_mul: u16 = @truncate(i);
|
||||
var row = row_mul * this.element_rows + 1;
|
||||
if (i > 0 and overflow > 0) {
|
||||
overflow -|= 1;
|
||||
row += 1;
|
||||
}
|
||||
// TODO: that's the anchor of each component (only necessary for each widget rendering)
|
||||
const pos: terminal.Position = .{ .col = 1, .row = row };
|
||||
// TODO: do this using the renderer
|
||||
try terminal.setCursorPosition(pos);
|
||||
for (this.elements.items) |*element| {
|
||||
switch (element.*) {
|
||||
.layout => |*layout| {
|
||||
try layout.render(renderer);
|
||||
},
|
||||
.widget => |*widget| {
|
||||
// TODO: clear per widget if necesary (i.e. can I query that?)
|
||||
try widget.render(renderer);
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user