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

@@ -6,12 +6,12 @@
.minimum_zig_version = "0.16.0-dev.463+f624191f9",
.dependencies = .{
.zterm = .{
.url = "git+https://gitea.yves-biener.de/yves-biener/zterm#ad32e46bc9fd6d1d9b7a3615979a3b80877c9300",
.hash = "zterm-0.3.0-1xmmEO8PHABP4tE6BnEZllJTh6Hpza_5C9wS8s2vjwou",
.url = "git+https://gitea.yves-biener.de/yves-biener/zterm#4874252e8c3a5d645ac2c37bbfd0e669964912fc",
.hash = "zterm-0.3.0-1xmmEH82HABfsn5imAK8lw93LevIaqNV10g6xfkNj_OT",
},
.zlog = .{
.url = "git+https://gitea.yves-biener.de/yves-biener/zlog#f43034cea9a0863e618c3d0a43706ce38c8791cf",
.hash = "zlog-0.16.0-6JSlRx1JAADasbK5FS6Qaf0Iq1SCQaH5VZRxT2SRE2xs",
.url = "git+https://gitea.yves-biener.de/yves-biener/zlog#40ced30a574118cd76202c07dc4b2291c3321d3a",
.hash = "zlog-0.16.0-6JSlR-BIAAAZ4fSbV54zbZZ9hnZSeOPnnFtiVjmIy3ID",
},
},
.paths = .{

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();
}