add: signal handling WINCH, user input thread with waiting blocking

This commit is contained in:
2024-11-06 01:38:55 +01:00
parent b0b262ae0b
commit 9ddbb19336
7 changed files with 113 additions and 80 deletions

View File

@@ -5,7 +5,7 @@ const zlog = @import("zlog");
const App = @import("app.zig").App(union(enum) {});
pub const std_options = zlog.std_options;
const log = std.log.scoped(.main);
const log = std.log.scoped(.default);
pub fn main() !void {
errdefer |err| log.err("Application Error: {any}", .{err});
@@ -39,7 +39,6 @@ pub fn main() !void {
const event = app.nextEvent();
switch (event) {
.none => continue,
.quit => break,
.resize => |size| {
// NOTE: draw actions should not happen here (still here for testing)
@@ -52,8 +51,9 @@ pub fn main() !void {
},
.key => |key| {
log.debug("received key: {any}", .{key});
if (terminal.Key.matches(key, .{ .cp = 'q' })) {
app.quit = true; // TODO: who should emit the .quit event?
// ctrl+c to quit
if (terminal.Key.matches(key, .{ .cp = 'c', .mod = .{ .ctrl = true } })) {
app.quit.set();
}
},
else => {},