mod: use allocators for Layout and Widget types

This commit is contained in:
2024-11-19 22:56:37 +01:00
parent cd12fb12e6
commit 1c703a196a
18 changed files with 264 additions and 153 deletions

View File

@@ -30,7 +30,7 @@ pub fn main() !void {
// TODO: when not running fullscreen, the application needs to screen down accordingly to display the contents
// -> size hint how much should it use?
var layout = Layout.createFrom(Layout.Framing.init(allocator, .{
var layout = Layout.createFrom(allocator, Layout.Framing.init(allocator, .{
.style = .{
.fg = .{
.index = 6,
@@ -46,9 +46,9 @@ pub fn main() !void {
},
},
}, .{
.layout = Layout.createFrom(Layout.HStack.init(allocator, .{
Widget.createFrom(Widget.Spacer.init(allocator)),
Layout.createFrom(Layout.Framing.init(
.layout = Layout.createFrom(allocator, Layout.HStack.init(allocator, .{
Widget.createFrom(allocator, Widget.Spacer.init(allocator)),
Layout.createFrom(allocator, Layout.Framing.init(
allocator,
.{
.style = .{
@@ -67,18 +67,18 @@ pub fn main() !void {
},
},
.{
.layout = Layout.createFrom(Layout.Margin.init(allocator, .{
.layout = Layout.createFrom(allocator, Layout.Margin.init(allocator, .{
.margin = 10,
}, .{
.layout = Layout.createFrom(Layout.VStack.init(allocator, .{
Widget.createFrom(blk: {
.layout = Layout.createFrom(allocator, Layout.VStack.init(allocator, .{
Widget.createFrom(allocator, blk: {
const file = try std.fs.cwd().openFile("./examples/stack.zig", .{});
defer file.close();
const widget = Widget.RawText.init(allocator, file);
break :blk widget;
}),
Widget.createFrom(Widget.Spacer.init(allocator)),
Widget.createFrom(blk: {
Widget.createFrom(allocator, Widget.Spacer.init(allocator)),
Widget.createFrom(allocator, blk: {
const file = try std.fs.cwd().openFile("./examples/stack.zig", .{});
defer file.close();
const widget = Widget.RawText.init(allocator, file);
@@ -88,7 +88,7 @@ pub fn main() !void {
})),
},
)),
Widget.createFrom(Widget.Spacer.init(allocator)),
Widget.createFrom(allocator, Widget.Spacer.init(allocator)),
})),
}));
defer layout.deinit();