mod: use unbuffered streaming writer for TUIs
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 15m36s
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 15m36s
This commit is contained in:
@@ -37,7 +37,7 @@ const MouseDraw = struct {
|
||||
};
|
||||
}
|
||||
|
||||
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) {
|
||||
.mouse => |mouse| this.position = .{ .x = mouse.x, .y = mouse.y },
|
||||
@@ -115,17 +115,17 @@ pub fn main(init: std.process.Init) !void {
|
||||
}, second_mouse_draw.element()));
|
||||
try container.append(nested_container);
|
||||
|
||||
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
|
||||
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(),
|
||||
.accept => |input| {
|
||||
defer allocator.free(input);
|
||||
log.debug("Accepted input '{s}'", .{input});
|
||||
@@ -134,7 +134,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",
|
||||
@@ -147,10 +147,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user