core: config: add extra_keys property
According to the layout XML format, keys prefixed with "loc " should have an option to hide or show them. Add a property to facilitate this configuration. Keep the array sorted so it can be binary searched for the existence of an element.
This commit is contained in:
parent
14cd2d930b
commit
d9956baffa
1 changed files with 15 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ pub struct Configuration {
|
|||
longpress: u64,
|
||||
repeat: u64,
|
||||
layout: String,
|
||||
extra_keys: Vec<String>,
|
||||
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<String>
|
||||
{
|
||||
&self.extra_keys
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn wayland_height(&self) -> i32
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue