···7272 .target = target,
7373 .optimize = optimize,
7474 });
7575-7575+7676 // add vaxis dependency to module
7777 const vaxis = b.dependency("vaxis", .{
7878 .target = target,
7979 .optimize = optimize,
8080 });
8181 exe_mod.addImport("vaxis", vaxis.module("vaxis"));
8282-8282+8383 //create executable
8484 const exe = b.addExecutable(.{
8585 .name = "project_foo",
···330330331331 // Sends queries to terminal to detect certain features. This should always
332332 // be called after entering the alt screen, if you are using the alt screen
333333- try vx.queryTerminal(tty.writer(), 1 * std.time.ns_per_s);
333333+ try vx.queryTerminal(tty.writer(), .fromSeconds(1));
334334335335 while (true) {
336336 // nextEvent blocks until an event is in the queue
···21212222 // Optionally enter the alternate screen
2323 try vx.enterAltScreen(tty.writer());
2424- try vx.queryTerminal(tty.writer(), 1 * std.time.ns_per_s);
2424+ try vx.queryTerminal(tty.writer(), .fromSeconds(1));
25252626 // We'll adjust the color index every keypress
2727 var color_idx: u8 = 0;
···6060 try writer.flush();
6161 // Sends queries to terminal to detect certain features. This should
6262 // _always_ be called, but is left to the application to decide when
6363- try vx.queryTerminal(tty.writer(), 1 * std.time.ns_per_s);
6363+ try vx.queryTerminal(tty.writer(), .fromSeconds(1));
64646565 // The main event loop. Vaxis provides a thread safe, blocking, buffered
6666 // queue which can serve as the primary event queue for an application
···275275 else => {
276276 switch (event) {
277277 .key_press => |key| {
278278- // Check for a cursor position response for our explicity width query. This will
278278+ // Check for a cursor position response for our explicitly width query. This will
279279 // always be an F3 key with shift = true, and we must be looking for queries
280280 if (key.codepoint == vaxis.Key.f3 and
281281 key.mods.shift and
···433433 var vx = try vaxis.init(io, std.testing.allocator, &env_map, .{});
434434 defer vx.deinit(std.testing.allocator, tty.writer());
435435436436- var loop: vaxis.Loop(Event) = .{ .tty = &tty, .vaxis = &vx };
437437- try loop.init(io);
436436+ var loop: vaxis.Loop(Event) = .init(io, &tty, &vx);
438437439438 try loop.start();
440439 defer loop.stop();
441440442441 // Optionally enter the alternate screen
443442 try vx.enterAltScreen(tty.writer());
444444- try vx.queryTerminal(tty.writer(), 1 * std.time.ns_per_ms);
443443+ try vx.queryTerminal(tty.writer(), .fromSeconds(1));
445444}
+13-3
src/Vaxis.zig
···254254///
255255/// This call will block until Vaxis.query_futex is woken up, or the timeout.
256256/// Event loops can wake up this futex when cap_da1 is received
257257-pub fn queryTerminal(self: *Vaxis, tty: *std.Io.Writer, timeout_ns: u64) !void {
257257+pub fn queryTerminal(self: *Vaxis, tty: *std.Io.Writer, timeout: std.Io.Duration) !void {
258258 try self.queryTerminalSend(tty);
259259- // 1 second timeout
260260- try std.Io.futexWaitTimeout(self.io, atomic.Value(u32), &self.query_futex, .init(0), .{ .duration = .{ .clock = .real, .raw = .fromNanoseconds(timeout_ns) } });
259259+ try std.Io.futexWaitTimeout(
260260+ self.io,
261261+ atomic.Value(u32),
262262+ &self.query_futex,
263263+ .init(0),
264264+ .{
265265+ .duration = .{
266266+ .clock = .real,
267267+ .raw = timeout,
268268+ },
269269+ },
270270+ );
261271 self.queries_done.store(true, .unordered);
262272 try self.enableDetectedFeatures(tty);
263273}