71 lines
1.5 KiB
Rust
71 lines
1.5 KiB
Rust
use std::time::Duration;
|
|
|
|
use alacritty_config_derive::ConfigDeserialize;
|
|
|
|
use crate::config::Program;
|
|
use crate::term::color::Rgb;
|
|
|
|
#[derive(ConfigDeserialize, Clone, Debug, PartialEq, Eq)]
|
|
pub struct BellConfig {
|
|
/// Visual bell animation function.
|
|
pub animation: BellAnimation,
|
|
|
|
/// Command to run on bell.
|
|
pub command: Option<Program>,
|
|
|
|
/// Visual bell flash color.
|
|
pub color: Rgb,
|
|
|
|
/// Visual bell duration in milliseconds.
|
|
duration: u16,
|
|
}
|
|
|
|
impl Default for BellConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
color: Rgb { r: 255, g: 255, b: 255 },
|
|
animation: Default::default(),
|
|
command: Default::default(),
|
|
duration: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl BellConfig {
|
|
pub fn duration(&self) -> Duration {
|
|
Duration::from_millis(self.duration as u64)
|
|
}
|
|
}
|
|
|
|
/// `VisualBellAnimations` are modeled after a subset of CSS transitions and Robert
|
|
/// Penner's Easing Functions.
|
|
#[derive(ConfigDeserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum BellAnimation {
|
|
// CSS animation.
|
|
Ease,
|
|
// CSS animation.
|
|
EaseOut,
|
|
// Penner animation.
|
|
EaseOutSine,
|
|
// Penner animation.
|
|
EaseOutQuad,
|
|
// Penner animation.
|
|
EaseOutCubic,
|
|
// Penner animation.
|
|
EaseOutQuart,
|
|
// Penner animation.
|
|
EaseOutQuint,
|
|
// Penner animation.
|
|
EaseOutExpo,
|
|
// Penner animation.
|
|
EaseOutCirc,
|
|
// Penner animation.
|
|
Linear,
|
|
}
|
|
|
|
impl Default for BellAnimation {
|
|
fn default() -> Self {
|
|
BellAnimation::EaseOutExpo
|
|
}
|
|
}
|