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