aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-01-02 20:42:57 -0800
committerJoe Wilm <joe@jwilm.com>2017-01-02 20:42:57 -0800
commit1edfef4a32d27af907525c49f01b87be0d94bfb3 (patch)
tree4311bad5dee20cacd1e57928fd9a1992e99082cf
parentedd5dc7da5047767562f320cabe1b1a56524880e (diff)
downloadalacritty-1edfef4a32d27af907525c49f01b87be0d94bfb3.tar.gz
alacritty-1edfef4a32d27af907525c49f01b87be0d94bfb3.zip
Have default mouse and key bindings
This improves the situation where the user has not installed the default configuration file. Resolves #42.
-rw-r--r--src/config.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs
index 55e69c90..afbae8a3 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -188,17 +188,32 @@ pub struct Config {
colors: ColorList,
/// Keybindings
- #[serde(default)]
+ #[serde(default="default_key_bindings")]
key_bindings: Vec<KeyBinding>,
/// Bindings for the mouse
- #[serde(default)]
+ #[serde(default="default_mouse_bindings")]
mouse_bindings: Vec<MouseBinding>,
/// Path where config was loaded from
config_path: Option<PathBuf>,
}
+static DEFAULT_ALACRITTY_CONFIG: &'static str = include_str!("../alacritty.yml");
+
+fn default_config() -> Config {
+ serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG)
+ .expect("default config is valid")
+}
+
+fn default_key_bindings() -> Vec<KeyBinding> {
+ default_config().key_bindings
+}
+
+fn default_mouse_bindings() -> Vec<MouseBinding> {
+ default_config().mouse_bindings
+}
+
impl Default for Config {
fn default() -> Config {
Config {
@@ -1158,6 +1173,12 @@ mod tests {
println!("config: {:#?}", config);
}
+
+ #[test]
+ fn defaults_are_ok() {
+ super::default_key_bindings();
+ super::default_mouse_bindings();
+ }
}
#[cfg_attr(feature = "clippy", allow(enum_variant_names))]
@@ -1478,3 +1499,4 @@ impl Key {
}
}
}
+