summaryrefslogtreecommitdiff
path: root/tui/layout
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2025-03-12 04:14:25 +0100
committerJulian Hurst <ark@mansus.space>2025-03-12 04:14:25 +0100
commitfcff38543be6a1b321641f26aa349cf0f02d66bb (patch)
treea265e8c61ecbb3d73293cd47d5dd39b69794578c /tui/layout
downloadhare-tui-fcff38543be6a1b321641f26aa349cf0f02d66bb.tar.gz
Initial commit
Diffstat (limited to 'tui/layout')
-rw-r--r--tui/layout/layout.ha14
-rw-r--r--tui/layout/vlayout.ha26
2 files changed, 40 insertions, 0 deletions
diff --git a/tui/layout/layout.ha b/tui/layout/layout.ha
new file mode 100644
index 0000000..d425891
--- /dev/null
+++ b/tui/layout/layout.ha
@@ -0,0 +1,14 @@
+use tui::widget;
+
+export type printfn = fn(l: *layout) void;
+export type finishfn = fn(l: *layout) void;
+
+export type layout = struct {
+ widgets: []*widget::widget,
+ print: *printfn,
+ finish: *finishfn,
+};
+
+fn finish(l: *layout) void = {
+ free(l.widgets);
+};
diff --git a/tui/layout/vlayout.ha b/tui/layout/vlayout.ha
new file mode 100644
index 0000000..0381a9f
--- /dev/null
+++ b/tui/layout/vlayout.ha
@@ -0,0 +1,26 @@
+use tui::widget;
+
+export type vlayout = struct {
+ layout: layout,
+};
+
+export fn newvlayout(widgets: *widget::widget...) vlayout = {
+ return vlayout {
+ layout = layout {
+ widgets = widgets,
+ print = &printvlayout,
+ finish = &finishvlayout,
+ },
+ };
+};
+
+fn printvlayout(l: *layout) void = {
+ for (let widget .. l.widgets) {
+ widget.print(widget);
+ };
+};
+
+fn finishvlayout(l: *layout) void = {
+ let vl = l: *vlayout;
+ finish(&vl.layout);
+};