libvaxis/examples/main.zig
Tim Culverhouse a9c97d051b tty: implement winch handling
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2024-01-18 22:37:48 -06:00

31 lines
739 B
Zig

const std = @import("std");
const odditui = @import("odditui");
const log = std.log.scoped(.main);
pub fn main() !void {
var app: odditui.App(Event) = try odditui.App(Event).init(.{});
defer app.deinit();
try app.start();
defer app.stop();
outer: while (true) {
const event = app.nextEvent();
switch (event) {
.key_press => |key| {
if (key.codepoint == 'c' and key.mods.ctrl) {
break :outer;
}
},
.winsize => {},
else => {},
}
log.debug("event: {}\r\n", .{event});
}
}
const Event = union(enum) {
key_press: odditui.Key,
winsize: std.os.system.winsize,
mouse: u8,
};