Compare commits
3 Commits
db8485d88e
...
1f93e24a37
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f93e24a37 | |||
| 0ec9839cc7 | |||
| 9ae9dcfce2 |
@@ -10,8 +10,8 @@
|
||||
.hash = "zterm-0.3.0-1xmmEH82HABfsn5imAK8lw93LevIaqNV10g6xfkNj_OT",
|
||||
},
|
||||
.zlog = .{
|
||||
.url = "git+https://gitea.yves-biener.de/yves-biener/zlog#40ced30a574118cd76202c07dc4b2291c3321d3a",
|
||||
.hash = "zlog-0.16.0-6JSlR-BIAAAZ4fSbV54zbZZ9hnZSeOPnnFtiVjmIy3ID",
|
||||
.url = "git+https://gitea.yves-biener.de/yves-biener/zlog#b3c8a3ab1ccae1ba50efbdf26d68a18da8594d2c",
|
||||
.hash = "zlog-0.16.0-6JSlRwNJAACVd89xnhXRHzCnCs7qab9Jcmx11VMS2ZpL",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
|
||||
@@ -61,7 +61,6 @@ pub fn main() !void {
|
||||
var button: NavigationButton(.about) = .init(&app.model, &app.queue);
|
||||
try header.append(try .init(allocator, .{
|
||||
.size = .{
|
||||
.dim = .{ .x = 5 + 2 },
|
||||
.grow = .vertical,
|
||||
},
|
||||
}, button.element()));
|
||||
@@ -71,7 +70,6 @@ pub fn main() !void {
|
||||
var button: NavigationButton(.blog) = .init(&app.model, &app.queue);
|
||||
try header.append(try .init(allocator, .{
|
||||
.size = .{
|
||||
.dim = .{ .x = 4 + 2 },
|
||||
.grow = .vertical,
|
||||
},
|
||||
}, button.element()));
|
||||
|
||||
@@ -26,7 +26,7 @@ pub const Document = struct {
|
||||
title: ?[]const u8 = null,
|
||||
date: ?[]const u8 = null,
|
||||
content: []const u8 = undefined,
|
||||
ptr: []const u8,
|
||||
ptr: ?[]const u8,
|
||||
|
||||
const Preemble = enum {
|
||||
title,
|
||||
@@ -36,7 +36,7 @@ pub const Document = struct {
|
||||
pub const invalidPage: @This() = .{
|
||||
.title = "Page not found",
|
||||
.content = "Requested page does not exist",
|
||||
.ptr = undefined,
|
||||
.ptr = null,
|
||||
};
|
||||
|
||||
pub fn init(content: []const u8) @This() {
|
||||
@@ -67,8 +67,8 @@ pub const Document = struct {
|
||||
}
|
||||
|
||||
pub fn deinit(this: *@This(), allocator: Allocator) void {
|
||||
allocator.free(this.ptr);
|
||||
this.* = .{ .ptr = undefined };
|
||||
if (this.ptr) |ptr| allocator.free(ptr);
|
||||
this.* = .{ .ptr = null };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,12 +22,17 @@ pub fn NavigationButton(App: type) fn (std.meta.FieldEnum(App.Event)) type {
|
||||
return .{
|
||||
.ptr = this,
|
||||
.vtable = &.{
|
||||
.minSize = minSize,
|
||||
.handle = handle,
|
||||
.content = content,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
fn minSize(_: *anyopaque, _: *const App.Model, _: zterm.Point) zterm.Point {
|
||||
return .{ .x = @tagName(page).len + 2 };
|
||||
}
|
||||
|
||||
fn handle(ctx: *anyopaque, _: *App.Model, event: App.Event) !void {
|
||||
const this: *@This() = @ptrCast(@alignCast(ctx));
|
||||
switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user