mod: update zterm dependency and adjust layout
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 49s

This commit is contained in:
2024-11-15 22:24:41 +01:00
parent 9515def4fb
commit 36a4e16535
2 changed files with 67 additions and 34 deletions

View File

@@ -7,6 +7,7 @@ const App = zterm.App(
zterm.Renderer.Direct,
true,
);
const Cell = zterm.Cell;
const Key = zterm.Key;
const Layout = App.Layout;
const Widget = App.Widget;
@@ -30,40 +31,72 @@ pub fn main() !void {
var app: App = .{};
var renderer: App.Renderer = .{};
var layout = Layout.createFrom(vstack: {
var vstack = Layout.VStack.init(allocator, .{
Layout.createFrom(framing: {
var framing = Layout.Framing.init(allocator, .{
.title = .{
.str = "Welcome to my terminal website",
.style = .{
.ul = .{ .index = 6 },
.ul_style = .single,
var layout = Layout.createFrom(vcontainer: {
var vcontainer = Layout.VContainer.init(allocator, .{
.{
Layout.createFrom(framing: {
var framing = Layout.Framing.init(allocator, .{
.title = .{
.str = "Welcome to my terminal website",
.style = .{
.ul = .{ .index = 6 },
.ul_style = .single,
},
},
},
}, .{
.widget = Widget.createFrom(header: {
const doc = try std.fs.cwd().openFile("./doc/home.md", .{});
defer doc.close();
var header = Widget.RawText.init(allocator, doc);
break :header &header;
}),
});
break :framing &framing;
}),
Layout.createFrom(margin: {
var margin = Layout.Margin.init(allocator, .{ .left = 15, .right = 15 }, .{
.widget = Widget.createFrom(body: {
const doc = try std.fs.cwd().openFile("./doc/test.md", .{});
defer doc.close();
var body = Widget.RawText.init(allocator, doc);
break :body &body;
}),
});
break :margin &margin;
}),
}, .{
.layout = Layout.createFrom(hcontainer: {
var hcontainer = Layout.HContainer.init(allocator, .{
.{
Widget.createFrom(header: {
var header = Widget.Text.init(&[1]Cell{
.{ .content = "Yves Biener", .style = .{ .bold = true } },
});
break :header &header;
}),
25,
},
.{
Widget.createFrom(name: {
var name = Widget.Text.init(&[1]Cell{
.{ .content = "File name", .style = .{ .bold = true } },
});
break :name &name;
}),
50,
},
.{
Widget.createFrom(contacts: {
var contacts = Widget.Text.init(&[1]Cell{
.{ .content = "Contact", .style = .{ .bold = true, .ul_style = .single } },
});
break :contacts &contacts;
}),
25,
},
});
break :hcontainer &hcontainer;
}),
});
break :framing &framing;
}),
10,
},
.{
Layout.createFrom(margin: {
var margin = Layout.Margin.init(allocator, .{ .left = 15, .right = 15 }, .{
.widget = Widget.createFrom(body: {
const doc = try std.fs.cwd().openFile("./doc/test.md", .{});
defer doc.close();
var body = Widget.RawText.init(allocator, doc);
break :body &body;
}),
});
break :margin &margin;
}),
90,
},
});
break :vstack &vstack;
break :vcontainer &vcontainer;
});
defer layout.deinit();