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
+11 -11
View File
@@ -88,8 +88,8 @@ pub fn main(init: std.process.Init) !void {
});
try container.append(try App.Container.init(allocator, .{}, progress.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});
var framerate: u64 = 60;
var tick_ms: u64 = @divFloor(time.ms_per_s, framerate);
@@ -100,11 +100,11 @@ pub fn main(init: std.process.Init) !void {
// Continuous drawing
// draw loop
draw: while (true) {
const now_ms: u64 = @intCast(time.milliTimestamp());
const now_ms: u64 = @intCast(std.Io.Timestamp.now(io, .real).toMilliseconds());
if (now_ms >= next_frame_ms) {
next_frame_ms = now_ms + tick_ms;
} else {
std.Thread.sleep((next_frame_ms - now_ms) * time.ns_per_ms);
try io.sleep(.{ .nanoseconds = (next_frame_ms - now_ms) * time.ns_per_ms }, .real);
next_frame_ms += tick_ms;
}
@@ -114,12 +114,12 @@ pub fn main(init: std.process.Init) !void {
increase_progress = 10;
progress_percent += 1;
if (progress_percent > 100) progress_percent = 0;
app.postEvent(.{ .progress = progress_percent });
try app.postEvent(.{ .progress = progress_percent });
}
const len = blk: {
app.queue.lock();
defer app.queue.unlock();
try app.queue.lock(io);
defer app.queue.unlock(io);
break :blk app.queue.len();
};
@@ -130,7 +130,7 @@ pub fn main(init: std.process.Init) !void {
// pre event handling
switch (event) {
.key => |key| {
if (key.eql(.{ .cp = 'c', .mod = .{ .ctrl = true } })) app.quit();
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 }),
.focus => |b| {
@@ -141,7 +141,7 @@ pub fn main(init: std.process.Init) !void {
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",
@@ -155,10 +155,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);
}
}