mod: bump zig version to 0.16.0

This commit is contained in:
2026-05-14 11:05:55 +02:00
parent bdf58f5102
commit 24a08e0e62
25 changed files with 721 additions and 701 deletions
+17 -15
View File
@@ -69,15 +69,17 @@ const Prompt = struct {
}
};
pub fn main() !void {
pub fn main(init: std.process.Init) !void {
errdefer |err| log.err("Application Error: {any}", .{err});
const gpa = init.gpa;
const io = init.io;
var allocator: std.heap.DebugAllocator(.{}) = .init;
defer if (allocator.deinit() == .leak) log.err("memory leak", .{});
var app: App = .init(gpa, io, .{});
var stdout = std.Io.File.stdout();
var buffer: [4096]u8 = undefined;
var writer = stdout.writerStreaming(io, &buffer);
const w = &writer.interface;
const gpa = allocator.allocator();
var app: App = .init(gpa, .{}, .{});
var renderer = zterm.Renderer.Direct.init(gpa);
defer renderer.deinit();
@@ -127,16 +129,16 @@ pub fn main() !void {
},
}, prompt.element()));
try app.start(.direct); // needs to become configurable, as what should be enabled / disabled (i.e. show cursor, hide cursor, use alternate screen, etc.)
defer app.stop() catch |err| log.err("Failed to stop application: {any}", .{err});
try app.start(.direct, w); // needs to become configurable, as what should be enabled / disabled (i.e. show cursor, hide cursor, use alternate screen, etc.)
defer app.stop(w) catch |err| log.err("Failed to stop application: {any}", .{err});
// event loop
event: 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();
};
@@ -149,14 +151,14 @@ pub fn main() !void {
switch (event) {
// NOTE draw the character with the ctrl indication and a newline to make sure the rendering stays consistent
.cancel => {
app.quit();
try app.quit();
break :event;
},
.line => |line| {
defer gpa.free(line);
log.debug("{s}", .{line});
if (std.mem.eql(u8, line, "q\n")) app.quit();
if (std.mem.eql(u8, line, "q\n")) try app.quit();
},
// NOTE errors could be displayed in another container in case one was received, etc. to provide the user with feedback
.err => |err| log.err("Received {s} with message: {s}", .{ @errorName(err.err), err.msg }),
@@ -164,7 +166,7 @@ pub fn main() !void {
}
// NOTE returned errors should be propagated back to the application
container.handle(&app.model, event) catch |err| app.postEvent(.{
container.handle(&app.model, event) catch |err| try app.postEvent(.{
.err = .{
.err = err,
.msg = "Container Event handling failed",
@@ -175,7 +177,7 @@ pub fn main() !void {
container.resize(&app.model, try renderer.resize());
container.reposition(&app.model, .{});
try renderer.render(@TypeOf(container), &container, App.Model, &app.model);
try renderer.flush();
try renderer.flush(w);
}
}