mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-11-03 21:49:42 -09:00
Zig 0.16: timer
This commit is contained in:
parent
ffa44be7a4
commit
e93eacd755
2 changed files with 5 additions and 5 deletions
|
|
@ -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) |_| {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue