mod: use unbuffered streaming writer for TUIs
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 15m36s

This commit is contained in:
2026-06-03 17:39:11 +02:00
parent 24a08e0e62
commit cb262aa51f
18 changed files with 131 additions and 116 deletions
+8 -8
View File
@@ -57,7 +57,7 @@ const ErrorNotification = struct {
return .{ .ptr = this, .vtable = &.{ .handle = handle, .content = content } };
}
fn handle(ctx: *anyopaque, _: *App.Model, event: App.Event) !void {
fn handle(ctx: *anyopaque, _: std.Io, _: *App.Model, event: App.Event) !void {
const this: *@This() = @ptrCast(@alignCast(ctx));
switch (event) {
.key => |key| if (!key.isAscii()) return zterm.Error.TooSmall,
@@ -119,21 +119,21 @@ pub fn main(init: std.process.Init) !void {
try container.append(try App.Container.init(allocator, .{}, info_text.element()));
try container.append(try App.Container.init(allocator, .{}, error_notification.element()));
try app.start(.full);
defer app.stop() catch |err| log.err("Failed to stop application: {any}", .{err});
try app.start(.full, w);
defer app.stop(w) catch |err| log.err("Failed to stop application: {any}", .{err});
while (true) {
const event = app.nextEvent();
const event = try app.nextEvent();
log.debug("received event: {s}", .{@tagName(event)});
// pre event handling
switch (event) {
.key => |key| if (key.eql(.{ .cp = 'c', .mod = .{ .ctrl = true } })) app.quit(),
.key => |key| if (key.eql(.{ .cp = 'c', .mod = .{ .ctrl = true } })) try app.quit(),
.err => |err| log.err("Received {s} with message: {s}", .{ @errorName(err.err), err.msg }),
else => {},
}
container.handle(&app.model, event) catch |err| app.postEvent(.{
container.handle(io, &app.model, event) catch |err| try app.postEvent(.{
.err = .{
.err = err,
.msg = "Container Event handling failed",
@@ -146,10 +146,10 @@ pub fn main(init: std.process.Init) !void {
else => {},
}
container.resize(&app.model, try renderer.resize());
container.resize(&app.model, try renderer.resize(w));
container.reposition(&app.model, .{});
try renderer.render(@TypeOf(container), &container, App.Model, &app.model);
try renderer.flush();
try renderer.flush(w);
}
}