|
|
|
@ -14,10 +14,10 @@ pub enum Action {
|
|
|
|
|
Remap(HashMap<KeyPress, Vec<Action>>),
|
|
|
|
|
#[serde(deserialize_with = "deserialize_launch")]
|
|
|
|
|
Launch(Vec<String>),
|
|
|
|
|
#[serde(deserialize_with = "deserialize_with_mark")]
|
|
|
|
|
WithMark(KeyPress),
|
|
|
|
|
#[serde(deserialize_with = "deserialize_set_mark")]
|
|
|
|
|
SetMark(bool),
|
|
|
|
|
#[serde(deserialize_with = "deserialize_with_mark")]
|
|
|
|
|
WithMark(KeyPress),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn deserialize_remap<'de, D>(deserializer: D) -> Result<HashMap<KeyPress, Vec<Action>>, D::Error>
|
|
|
|
@ -46,30 +46,30 @@ where
|
|
|
|
|
Err(de::Error::custom("not a map with a single \"launch\" key"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn deserialize_with_mark<'de, D>(deserializer: D) -> Result<KeyPress, D::Error>
|
|
|
|
|
fn deserialize_set_mark<'de, D>(deserializer: D) -> Result<bool, D::Error>
|
|
|
|
|
where
|
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
|
{
|
|
|
|
|
let mut action = HashMap::<String, KeyPress>::deserialize(deserializer)?;
|
|
|
|
|
if let Some(key_press) = action.remove("with_mark") {
|
|
|
|
|
let mut action = HashMap::<String, bool>::deserialize(deserializer)?;
|
|
|
|
|
if let Some(set) = action.remove("set_mark") {
|
|
|
|
|
if action.is_empty() {
|
|
|
|
|
return Ok(key_press);
|
|
|
|
|
return Ok(set);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Err(de::Error::custom("not a map with a single \"with_mark\" key"))
|
|
|
|
|
Err(de::Error::custom("not a map with a single \"set_mark\" key"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn deserialize_set_mark<'de, D>(deserializer: D) -> Result<bool, D::Error>
|
|
|
|
|
fn deserialize_with_mark<'de, D>(deserializer: D) -> Result<KeyPress, D::Error>
|
|
|
|
|
where
|
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
|
{
|
|
|
|
|
let mut action = HashMap::<String, bool>::deserialize(deserializer)?;
|
|
|
|
|
if let Some(set) = action.remove("set_mark") {
|
|
|
|
|
let mut action = HashMap::<String, KeyPress>::deserialize(deserializer)?;
|
|
|
|
|
if let Some(key_press) = action.remove("with_mark") {
|
|
|
|
|
if action.is_empty() {
|
|
|
|
|
return Ok(set);
|
|
|
|
|
return Ok(key_press);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Err(de::Error::custom("not a map with a single \"set_mark\" key"))
|
|
|
|
|
Err(de::Error::custom("not a map with a single \"with_mark\" key"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Used only for deserializing Vec<Action>
|
|
|
|
|