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

This commit is contained in:
2024-11-10 16:02:49 +01:00
parent a201f2b653
commit 8ae9129403
4 changed files with 15 additions and 24 deletions

View File

@@ -11,6 +11,8 @@ pub fn Widget(comptime Event: type, comptime Renderer: type) type {
@compileError("Provided user event `Event` for `Layout(comptime Event: type)` is not of type `union(enum)`.");
}
return struct {
size: terminal.Size = undefined,
pub fn init() @This() {
return .{};
}
@@ -20,15 +22,17 @@ pub fn Widget(comptime Event: type, comptime Renderer: type) type {
}
pub fn handle(this: *@This(), event: Event) ?Event {
_ = this;
_ = event;
switch (event) {
.resize => |size| {
this.size = size;
},
else => {},
}
return null;
}
pub fn render(this: *@This(), renderer: Renderer) !void {
// FIX: this should rather clear the `terminal.Size` provided through the event system using the _renderer_.
_ = this;
_ = renderer;
try renderer.clear(this.size);
}
};
}