From 35209dd064fc70805a86508af0ed2a3af2093e25 Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Tue, 5 May 2026 13:58:17 +0200 Subject: [PATCH] Expose tick interval constant and simplify handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the 33 ms tick interval into `tick` as a public constant `TICK_MS` and drop the parameter from `handle_tick_event`. Update re‑exports and callers accordingly --- src/app/threads/mod.rs | 2 +- src/app/threads/tick.rs | 6 ++++-- src/main.rs | 4 +--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/threads/mod.rs b/src/app/threads/mod.rs index 24050fd..99579a6 100644 --- a/src/app/threads/mod.rs +++ b/src/app/threads/mod.rs @@ -4,4 +4,4 @@ mod tick; pub use audio::{AudioCmd, SoundrackParts, Soundtrack, handle_audio}; pub use events::handle_ct_events; -pub use tick::handle_tick_event; +pub use tick::{TICK_MS, handle_tick_event}; diff --git a/src/app/threads/tick.rs b/src/app/threads/tick.rs index 3eb0a1f..58a457c 100644 --- a/src/app/threads/tick.rs +++ b/src/app/threads/tick.rs @@ -4,8 +4,10 @@ use std::{ time::{Duration, Instant}, }; -pub fn handle_tick_event(tx: Sender<()>, tick_ms: u8) { - let interval: Duration = Duration::from_millis(tick_ms as u64); +pub const TICK_MS: u8 = 33; + +pub fn handle_tick_event(tx: Sender<()>) { + let interval: Duration = Duration::from_millis(TICK_MS as u64); loop { if tx.send(()).is_err() { break; diff --git a/src/main.rs b/src/main.rs index 0483af5..b5989b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,6 @@ use war_in_tunnels::{ cli::{Cli, get_args}, }; -const TICK_MS: u8 = 33; - /// Starts the terminal UI application. /// /// The function follows the steps outlined in the module‑level documentation. @@ -28,7 +26,7 @@ fn main() -> Result<()> { let (audio_tx, audio_rx) = channel::(); thread::spawn(move || handle_ct_events(input_tx, resize_tx)); - thread::spawn(move || handle_tick_event(tick_tx, TICK_MS)); + thread::spawn(move || handle_tick_event(tick_tx)); thread::spawn(move || handle_audio(audio_rx, args.mute, args.soundtrack)); let mut terminal: Terminal> = ratatui::init();