add(widget/Spacer): empty widget implementation
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 32s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 32s
This commit is contained in:
@@ -34,15 +34,18 @@ pub fn main() !void {
|
|||||||
var appFileText = App.Widget.RawText.init(allocator, appFile);
|
var appFileText = App.Widget.RawText.init(allocator, appFile);
|
||||||
appFile.close();
|
appFile.close();
|
||||||
|
|
||||||
|
var spacer = App.Widget.Spacer.init();
|
||||||
var framing = App.Layout.Framing.init(allocator, .{
|
var framing = App.Layout.Framing.init(allocator, .{
|
||||||
.widget = App.Widget.createFrom(&mainFileText),
|
.widget = App.Widget.createFrom(&mainFileText),
|
||||||
});
|
});
|
||||||
var hstack = App.Layout.HStack.init(allocator, .{
|
var hstack = App.Layout.HStack.init(allocator, .{
|
||||||
App.Layout.createFrom(&framing),
|
App.Layout.createFrom(&framing),
|
||||||
});
|
});
|
||||||
|
// TODO: corresponding contents need to be filled out by the layout accordingly!
|
||||||
var vstack = App.Layout.VStack.init(allocator, .{
|
var vstack = App.Layout.VStack.init(allocator, .{
|
||||||
App.Widget.createFrom(&appFileText),
|
App.Widget.createFrom(&appFileText),
|
||||||
App.Layout.createFrom(&hstack),
|
App.Layout.createFrom(&hstack),
|
||||||
|
App.Widget.createFrom(&spacer),
|
||||||
});
|
});
|
||||||
var layout = App.Layout.createFrom(&vstack);
|
var layout = App.Layout.createFrom(&vstack);
|
||||||
defer layout.deinit();
|
defer layout.deinit();
|
||||||
|
|||||||
@@ -74,5 +74,6 @@ pub fn Widget(comptime Event: type) type {
|
|||||||
|
|
||||||
// TODO: import and export of `Widget` implementations (with corresponding initialization using `Event`)
|
// TODO: import and export of `Widget` implementations (with corresponding initialization using `Event`)
|
||||||
pub const RawText = @import("widget/RawText.zig").Widget(Event);
|
pub const RawText = @import("widget/RawText.zig").Widget(Event);
|
||||||
|
pub const Spacer = @import("widget/Spacer.zig").Widget(Event);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/widget/Spacer.zig
Normal file
33
src/widget/Spacer.zig
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const terminal = @import("../terminal.zig");
|
||||||
|
|
||||||
|
const isTaggedUnion = @import("../event.zig").isTaggedUnion;
|
||||||
|
const Error = @import("../event.zig").Error;
|
||||||
|
|
||||||
|
const log = std.log.scoped(.widget_spacer);
|
||||||
|
|
||||||
|
pub fn Widget(comptime Event: type) type {
|
||||||
|
if (!isTaggedUnion(Event)) {
|
||||||
|
@compileError("Provided user event `Event` for `Layout(comptime Event: type)` is not of type `union(enum)`.");
|
||||||
|
}
|
||||||
|
return struct {
|
||||||
|
pub fn init() @This() {
|
||||||
|
return .{};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(this: *@This()) void {
|
||||||
|
this.* = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn handle(this: *@This(), event: Event) ?Event {
|
||||||
|
_ = this;
|
||||||
|
_ = event;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn content(this: *@This()) ![]u8 {
|
||||||
|
_ = this;
|
||||||
|
return &[0]u8{};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user