From e93eacd7557fb995b9271da805c6c1a758547104 Mon Sep 17 00:00:00 2001 From: LN Liberda Date: Sat, 23 May 2026 00:25:37 +0200 Subject: [PATCH] Zig 0.16: timer --- src/browser.zig | 4 ++-- src/main.zig | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser.zig b/src/browser.zig index c664baf..3d5d86f 100644 --- a/src/browser.zig +++ b/src/browser.zig @@ -137,7 +137,7 @@ pub fn loadDir(next_sel: u64) void { // XXX: The current dir listing is wiped before loading the new one, which // causes the screen to flicker a bit when the loading indicator is drawn. // Should we keep the old listing around? - main.event_delay_timer.reset(); + main.event_delay_timer = .now(main.io, .awake); _ = dir_alloc.reset(.free_all); dir_items.shrinkRetainingCapacity(0); dir_refs.shrinkRetainingCapacity(0); @@ -310,7 +310,7 @@ const Row = struct { max *= bar_size; num *= bar_size; } - + const perblock = std.math.divFloor(u64, max, bar_size) catch unreachable; self.bg.fg(.graph); for (0..bar_size) |_| { diff --git a/src/main.zig b/src/main.zig index 485c803..5ab1085 100644 --- a/src/main.zig +++ b/src/main.zig @@ -88,7 +88,7 @@ pub const config = struct { pub var compress: bool = false; pub var export_block_size: ?usize = null; - pub var update_delay: u64 = 100*std.time.ns_per_ms; + pub var update_delay: u64 = std.Io.Duration.fromMilliseconds(100).nanoseconds; pub var scan_ui: ?enum { none, line, full } = null; pub var si: bool = false; pub var nc_tty: bool = false; @@ -633,7 +633,7 @@ pub var event_delay_timer: std.Io.Timestamp = undefined; pub fn handleEvent(block: bool, force_draw: bool) void { while (ui.oom_threads.load(.monotonic) > 0) ui.oom(); - if (block or force_draw or event_delay_timer.read() > config.update_delay) { + if (block or force_draw or event_delay_timer.untilNow(io, .awake).nanoseconds > config.update_delay) { if (ui.inited) _ = c.erase(); switch (state) { .scan, .refresh => sink.draw(), @@ -642,7 +642,7 @@ pub fn handleEvent(block: bool, force_draw: bool) void { .shell => unreachable, } if (ui.inited) _ = c.refresh(); - event_delay_timer.reset(); + event_delay_timer = .now(io, .awake); } if (!ui.inited) { std.debug.assert(!block);