diff --git a/src/core/config.rs b/src/core/config.rs index f2421fc..4fd5755 100644 --- a/src/core/config.rs +++ b/src/core/config.rs @@ -15,6 +15,7 @@ pub struct Configuration { longpress: u64, repeat: u64, layout: String, + extra_keys: Vec, wayland_height: i32, wayland_im_enable: bool, } @@ -46,6 +47,7 @@ impl Configuration { longpress: 600, repeat: 25, layout: String::from("latn_qwerty_us.xml"), + extra_keys: vec![ String::from("alt"), String::from("meta") ], wayland_height: 185, wayland_im_enable: true, }; @@ -80,6 +82,13 @@ impl Configuration { cfg.layout = layout.to_string(); } + let keys = yaml.get(&Yaml::String(String::from("extra_keys"))); + if let Some(keys) = keys { + let keys = keys.as_vec().expect("Extra keys should be a list"); + cfg.extra_keys = keys.iter().map(|y| String::from(y.as_str().unwrap())).collect(); + cfg.extra_keys.sort_unstable(); + } + let wl = yaml.get(&Yaml::String(String::from("wayland"))); if let Some(wl) = wl { let wl = wl.as_hash().expect("Wayland configuration should be a YAML mapping"); @@ -108,6 +117,12 @@ impl Configuration { &self.layout } + #[inline(always)] + pub fn extra_keys(&self) -> &Vec + { + &self.extra_keys + } + #[inline(always)] pub fn wayland_height(&self) -> i32 {