mod: bump zterm dependency with required code adaptations
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 1m16s

This commit is contained in:
2026-01-17 12:26:36 +01:00
parent b4836b8d2b
commit bfdaf82626
3 changed files with 15 additions and 29 deletions

View File

@@ -21,25 +21,13 @@ pub fn Content(App: type) type {
};
}
fn minSize(ctx: *anyopaque, size: zterm.Point) zterm.Point {
fn minSize(ctx: *anyopaque, _: *const App.Model, size: zterm.Point) zterm.Point {
const this: *const @This() = @ptrCast(@alignCast(ctx));
const text = this.document.content;
var index: usize = 0;
var new_size: zterm.Point = .{ .x = size.x };
_ = this;
//const text = this.document.content;
//var index: usize = 0;
const new_size: zterm.Point = .{ .x = size.x };
for (0..text.len) |_| rows: {
for (0..size.x - 1) |_| { // assume that there is one cell reserved for the scrollbar
if (index == text.len) break :rows;
const cp = text[index];
index += 1;
switch (cp) {
'\n' => break,
else => {},
}
}
new_size.y += 1;
}
return new_size;
}
@@ -52,7 +40,7 @@ pub fn Content(App: type) type {
model.page = .about;
model.document.deinit(this.allocator);
model.document = .init(try std.fs.cwd().readFileAlloc("./doc/about.md", this.allocator, .unlimited));
model.document = .init(try std.fs.cwd().readFileAlloc(this.allocator, "./doc/about.md", std.math.maxInt(usize)));
this.document = &model.document;
},
.blog => |path| {
@@ -64,7 +52,7 @@ pub fn Content(App: type) type {
model.page = .{ .blog = null };
}
model.document = .init(try std.fs.cwd().readFileAlloc(if (path) |p| p else "./doc/blog.md", this.allocator, .unlimited));
model.document = .init(try std.fs.cwd().readFileAlloc(this.allocator, if (path) |p| p else "./doc/blog.md", std.math.maxInt(usize)));
model.page = .{ .blog = path };
this.document = &model.document;

View File

@@ -20,9 +20,9 @@ pub fn main() !void {
// skip own executable name
_ = arg_it.skip();
var app: App = .init(.{
var app: App = .init(.{}, .{
.page = .about,
.document = .init(try std.fs.cwd().readFileAlloc("./doc/about.md", allocator, .unlimited)),
.document = .init(try std.fs.cwd().readFileAlloc(allocator, "./doc/about.md", std.math.maxInt(usize))),
});
defer app.model.deinit(allocator);
@@ -38,7 +38,6 @@ pub fn main() !void {
}, .{});
defer container.deinit();
var content_container: App.Container = undefined;
defer content_container.deinit();
// header with navigation buttons and content's title
{
@@ -162,9 +161,8 @@ pub fn main() !void {
}
}
container.resize(try renderer.resize());
container.reposition(.{});
container.resize(&app.model, try renderer.resize());
container.reposition(&app.model, .{});
try renderer.render(@TypeOf(container), &container, App.Model, &app.model);
try renderer.flush();
}