From 99dba44e463b354e5cacdf23932ba7f10f866925 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 9 Feb 2026 11:38:56 +0100 Subject: [PATCH] Rename min_refresh_delta option to animation_frame_delay (closes #925) Signed-off-by: AnErrupTion --- res/config.ini | 6 +++--- src/config/Config.zig | 2 +- src/config/migrator.zig | 8 ++++++++ src/main.zig | 12 ++++++------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/res/config.ini b/res/config.ini index 31ffce6..9e917f1 100644 --- a/res/config.ini +++ b/res/config.ini @@ -27,6 +27,9 @@ allow_empty_password = true # dur_file -> .dur file format (https://github.com/cmang/durdraw/tree/master) animation = none +# Delay between each animation frame in milliseconds +animation_frame_delay = 5 + # Stop the animation after some time # 0 -> Run forever # 1..2e12 -> Stop the animation after this many seconds @@ -291,9 +294,6 @@ margin_box_h = 2 # Main box vertical margin margin_box_v = 1 -# Event timeout in milliseconds -min_refresh_delta = 5 - # Set numlock on/off at startup numlock = false diff --git a/src/config/Config.zig b/src/config/Config.zig index 51dca91..1672dbb 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -9,6 +9,7 @@ const DurOffsetAlignment = enums.DurOffsetAlignment; allow_empty_password: bool = true, animation: Animation = .none, +animation_frame_delay: u16 = 5, animation_timeout_sec: u12 = 0, asterisk: ?u32 = '*', auth_fails: u64 = 10, @@ -73,7 +74,6 @@ logout_cmd: ?[]const u8 = null, ly_log: []const u8 = "/var/log/ly.log", margin_box_h: u8 = 2, margin_box_v: u8 = 1, -min_refresh_delta: u16 = 5, numlock: bool = false, path: ?[]const u8 = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", restart_cmd: []const u8 = "/sbin/shutdown -r now", diff --git a/src/config/migrator.zig b/src/config/migrator.zig index 7761d70..5e6394d 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -153,6 +153,14 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie return field; } + if (std.mem.eql(u8, field.key, "min_refresh_delta")) { + // The option has simply been renamed + var mapped_field = field; + mapped_field.key = "animation_frame_delay"; + + return mapped_field; + } + return field; } diff --git a/src/main.zig b/src/main.zig index 3c8456e..4c1614e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -916,7 +916,7 @@ pub fn main() !void { // Calculate the maximum timeout based on current animations, or the (big) clock. If there's none, we wait for the event indefinitely instead if (state.animate and !state.animation_timed_out) { - timeout = config.min_refresh_delta; + timeout = config.animation_frame_delay; // Check how long we've been running so we can turn off the animation const time = try interop.getTimeOfDay(); @@ -1132,7 +1132,7 @@ fn authenticate(ptr: *anyopaque) !bool { ); }; state.info_line.label.draw(); - _ = TerminalBuffer.presentBufferStatic(); + TerminalBuffer.presentBufferStatic(); return false; } @@ -1154,7 +1154,7 @@ fn authenticate(ptr: *anyopaque) !bool { ); }; state.info_line.label.draw(); - _ = TerminalBuffer.presentBufferStatic(); + TerminalBuffer.presentBufferStatic(); if (state.config.save) save_last_settings: { // It isn't worth cluttering the code with precise error @@ -1301,7 +1301,7 @@ fn authenticate(ptr: *anyopaque) !bool { // Restore the cursor TerminalBuffer.setCursorStatic(0, 0); - _ = TerminalBuffer.presentBufferStatic(); + TerminalBuffer.presentBufferStatic(); return false; } @@ -1439,7 +1439,7 @@ fn drawUi(state: *UiState) !bool { state.auth_fails = 0; } - _ = TerminalBuffer.presentBufferStatic(); + TerminalBuffer.presentBufferStatic(); return false; } @@ -1482,7 +1482,7 @@ fn drawUi(state: *UiState) !bool { state.login.label.draw(); state.password.draw(); - _ = TerminalBuffer.presentBufferStatic(); + TerminalBuffer.presentBufferStatic(); return true; }