diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/config.rs b/src/config.rs index 39a5c024..d5eadcf8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -157,13 +157,12 @@ pub struct VisualBellConfig { animation: VisualBellAnimation, /// Visual bell duration in milliseconds - #[serde(deserialize_with = "deserialize_visual_bell_duration")] - #[serde(default="default_visual_bell_duration")] + #[serde(default, deserialize_with = "deserialize_visual_bell_duration")] duration: u16, -} -fn default_visual_bell_duration() -> u16 { - 150 + /// Visual bell flash color + #[serde(default="default_visual_bell_color", deserialize_with = "rgb_from_hex")] + color: Rgb, } fn deserialize_visual_bell_duration<'a, D>(deserializer: D) -> ::std::result::Result<u16, D::Error> @@ -173,11 +172,15 @@ fn deserialize_visual_bell_duration<'a, D>(deserializer: D) -> ::std::result::Re Ok(duration) => Ok(duration), Err(err) => { error!("problem with config: {}; Using default value", err); - Ok(default_visual_bell_duration()) + Ok(0) }, } } +fn default_visual_bell_color() -> Rgb { + Rgb { r: 255, g: 255, b: 255 } +} + impl VisualBellConfig { /// Visual bell animation #[inline] @@ -190,13 +193,20 @@ impl VisualBellConfig { pub fn duration(&self) -> Duration { Duration::from_millis(u64::from(self.duration)) } + + /// Visual bell flash color + #[inline] + pub fn color(&self) -> Rgb { + self.color + } } impl Default for VisualBellConfig { fn default() -> VisualBellConfig { VisualBellConfig { animation: VisualBellAnimation::default(), - duration: default_visual_bell_duration(), + color: default_visual_bell_color(), + duration: 0, } } } |