mod(benchmark): correct size and provide documentation

This commit is contained in:
2024-11-09 01:33:06 +01:00
parent 817d818d4c
commit 9d711ea047
3 changed files with 32 additions and 7 deletions

View File

@@ -31,12 +31,24 @@ pub fn Layout(comptime Event: type) type {
}
pub fn handle(this: *@This(), event: Event) !*Events {
switch (event) {
else => {},
}
this.events.clearRetainingCapacity();
if (this.widget.handle(event)) |e| {
try this.events.append(e);
switch (event) {
.resize => |size| {
const widget_event: Event = .{
.resize = .{
.cols = size.cols,
.rows = size.rows -| 2, // remove top and bottom rows
},
};
if (this.widget.handle(widget_event)) |e| {
try this.events.append(e);
}
},
else => {
if (this.widget.handle(event)) |e| {
try this.events.append(e);
}
},
}
return &this.events;
}
@@ -44,7 +56,9 @@ pub fn Layout(comptime Event: type) type {
pub fn content(this: *@This()) !*std.ArrayList(u8) {
const widget_content = try this.widget.content();
this.c.clearRetainingCapacity();
try this.c.appendSlice("\n");
try this.c.appendSlice(widget_content);
try this.c.appendSlice("\n");
return &this.c;
}
};