Skip to main content

par_term/app/
bell.rs

1use crate::audio_bell::AudioBell;
2use std::time::Instant;
3
4/// State related to audio and visual bells
5pub struct BellState {
6    pub audio: Option<AudioBell>,      // Audio bell for terminal bell sounds
7    pub last_count: u64,               // Last bell event count from terminal
8    pub visual_flash: Option<Instant>, // When visual bell flash started (None = not flashing)
9}
10
11impl Default for BellState {
12    fn default() -> Self {
13        Self::new()
14    }
15}
16
17impl BellState {
18    pub fn new() -> Self {
19        Self {
20            audio: {
21                match AudioBell::new() {
22                    Ok(bell) => {
23                        log::info!("Audio bell initialized successfully");
24                        Some(bell)
25                    }
26                    Err(e) => {
27                        log::warn!("Failed to initialize audio bell: {}", e);
28                        None
29                    }
30                }
31            },
32            last_count: 0,
33            visual_flash: None,
34        }
35    }
36}