Skip to main content

par_term/pane/
bell.rs

1use crate::audio_bell::AudioBell;
2use std::time::Instant;
3
4/// State related to audio and visual bells
5pub struct BellState {
6    /// Shared process-wide audio output (see [`crate::audio_bell::shared`]);
7    /// `None` when no device could be opened.
8    pub(crate) audio: Option<&'static AudioBell>,
9    pub(crate) last_count: u64, // Last bell event count from terminal
10    pub(crate) visual_flash: Option<Instant>, // When visual bell flash started (None = not flashing)
11}
12
13impl Default for BellState {
14    fn default() -> Self {
15        Self::new()
16    }
17}
18
19impl BellState {
20    pub(crate) fn new() -> Self {
21        Self {
22            audio: crate::audio_bell::shared(),
23            last_count: 0,
24            visual_flash: None,
25        }
26    }
27}