summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-12-17 19:06:07 +0000
committerGitHub <noreply@github.com>2018-12-17 19:06:07 +0000
commitcf9d94eb1256881d48b1a3dc63db6caf32bfb841 (patch)
treedaae5794b13ba42cdfe57b431eedd76aa8a12b49 /src/config.rs
parent0c3e28617a95b4ca30ad9bdbb9114f1e4d41dce5 (diff)
downloadalacritty-cf9d94eb1256881d48b1a3dc63db6caf32bfb841.tar.gz
alacritty-cf9d94eb1256881d48b1a3dc63db6caf32bfb841.zip
Add color option to visual bell
This adds the option to specify the color of the visual bell using the `visual_bell.color` configuration setting. This is done by rendering a big quad over the entire screen, which also opens up options to draw other arbitrary rectangles on the screen in the future.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs24
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,
}
}
}