rem(element): template Element moved into wiki documentation
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 45s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 45s
This commit is contained in:
@@ -46,39 +46,6 @@ pub fn Element(Event: type) type {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is an empty template implementation for an Element type which `zterm` may provide.
|
|
||||||
///
|
|
||||||
/// TODO: Should elements need to be composible with each other, such that they may build complexer outputs?
|
|
||||||
/// - the goal would rather be to have re-usable parts of handlers and/or content functions which serve similar functionalities.
|
|
||||||
/// - composible through empty `Container`'s? -> make sense for the `Scrollable` `Element`
|
|
||||||
pub fn Template(Event: type) type {
|
|
||||||
return packed struct {
|
|
||||||
pub fn element(this: *@This()) Element(Event) {
|
|
||||||
return .{
|
|
||||||
.ptr = this,
|
|
||||||
.vtable = &.{
|
|
||||||
.handle = handle,
|
|
||||||
.content = content,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle(ctx: *anyopaque, event: Event) !void {
|
|
||||||
const this: *@This() = @ptrCast(@alignCast(ctx));
|
|
||||||
_ = this;
|
|
||||||
switch (event) {
|
|
||||||
else => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn content(ctx: *anyopaque, cells: []Cell, size: Size) !void {
|
|
||||||
const this: *@This() = @ptrCast(@alignCast(ctx));
|
|
||||||
std.debug.assert(cells.len == @as(usize, size.cols) * @as(usize, size.rows));
|
|
||||||
_ = this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn Scrollable(Event: type) type {
|
pub fn Scrollable(Event: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
/// `Size` of the actual contents where the anchor and the size is
|
/// `Size` of the actual contents where the anchor and the size is
|
||||||
|
|||||||
Reference in New Issue
Block a user