mod: each layout and widget now allocates their own instance in memory using the provided allocator (and destroy's themselfes in the end)
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-16 19:56:36 +01:00
parent f4adf53067
commit ec71e34958
14 changed files with 232 additions and 270 deletions

View File

@@ -31,41 +31,26 @@ 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: {
var container = Layout.VContainer.init(allocator, .{
.{
Widget.createFrom(blk: {
var spacer = Widget.Spacer.init();
break :blk &spacer;
}),
45,
},
.{
Layout.createFrom(framing: {
var framing = Layout.Framing.init(allocator, .{}, .{
.widget = Widget.createFrom(blk: {
var widget = Widget.Text.init(.center, &[_]Cell{
.{ .content = "Press " },
.{ .content = "Ctrl+n", .style = .{ .fg = .{ .index = 6 } } },
.{ .content = " to launch $EDITOR" },
});
break :blk &widget;
}),
});
break :framing &framing;
}),
10,
},
.{
Widget.createFrom(blk: {
var spacer = Widget.Spacer.init();
break :blk &spacer;
}),
45,
},
});
break :layout &container;
});
var layout = Layout.createFrom(Layout.VContainer.init(allocator, .{
.{
Widget.createFrom(Widget.Spacer.init(allocator)),
45,
},
.{
Layout.createFrom(Layout.Framing.init(allocator, .{}, .{
.widget = Widget.createFrom(Widget.Text.init(allocator, .center, &[_]Cell{
.{ .content = "Press " },
.{ .content = "Ctrl+n", .style = .{ .fg = .{ .index = 6 } } },
.{ .content = " to launch $EDITOR" },
})),
})),
10,
},
.{
Widget.createFrom(Widget.Spacer.init(allocator)),
45,
},
}));
defer layout.deinit();
try app.start();