diff options
author | Joe Wilm <joe@jwilm.com> | 2017-01-02 20:42:57 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2017-01-02 20:42:57 -0800 |
commit | 1edfef4a32d27af907525c49f01b87be0d94bfb3 (patch) | |
tree | 4311bad5dee20cacd1e57928fd9a1992e99082cf | |
parent | edd5dc7da5047767562f320cabe1b1a56524880e (diff) | |
download | alacritty-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.rs | 26 |
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 { } } } + |