use std::time::Duration;
use serde::Deserialize;
use crate::config::failure_default;
use crate::term::color::Rgb;
#[serde(default)]
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct VisualBellConfig {
#[serde(deserialize_with = "failure_default")]
pub animation: VisualBellAnimation,
#[serde(deserialize_with = "failure_default")]
pub duration: u16,
#[serde(deserialize_with = "failure_default")]
pub color: Rgb,
}
impl Default for VisualBellConfig {
fn default() -> VisualBellConfig {
VisualBellConfig {
animation: Default::default(),
duration: Default::default(),
color: default_visual_bell_color(),
}
}
}
impl VisualBellConfig {
#[inline]
pub fn duration(&self) -> Duration {
Duration::from_millis(u64::from(self.duration))
}
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq)]
pub enum VisualBellAnimation {
Ease, EaseOut, EaseOutSine, EaseOutQuad, EaseOutCubic, EaseOutQuart, EaseOutQuint, EaseOutExpo, EaseOutCirc, Linear,
}
impl Default for VisualBellAnimation {
fn default() -> Self {
VisualBellAnimation::EaseOutExpo
}
}
fn default_visual_bell_color() -> Rgb {
Rgb { r: 255, g: 255, b: 255 }
}