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
+10 -10
View File
@@ -212,31 +212,31 @@ pub fn main(init: std.process.Init) !void {
}, text_styles.element()), .enabled(.white, true));
try container.append(try App.Container.init(allocator, .{}, scrollable.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});
// event loop
loop: while (true) {
// batch events since last iteration
const len = blk: {
app.queue.poll();
app.queue.lock();
defer app.queue.unlock();
try app.queue.poll(io);
try app.queue.lock(io);
defer app.queue.unlock(io);
break :blk app.queue.len();
};
// handle events
for (0..len) |_| {
const event = app.queue.pop();
const event = app.queue.drain() orelse break;
log.debug("handling 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",
@@ -250,10 +250,10 @@ pub fn main(init: std.process.Init) !void {
}
}
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);
}
}