feat(config): introduce image matches options
This commit is contained in:
parent
7b9e01c1db
commit
7a8e39fdad
|
@ -17,7 +17,7 @@
|
||||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::{counter::next_id, matches::{Match, Params, TextFormat, UpperCasingStyle, Value, Variable, group::{path::resolve_imports, MatchGroup}}};
|
use crate::{counter::next_id, matches::{ImageEffect, Match, Params, TextFormat, UpperCasingStyle, Value, Variable, group::{path::resolve_imports, MatchGroup}}};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use parse::YAMLMatchGroup;
|
use parse::YAMLMatchGroup;
|
||||||
|
@ -198,6 +198,10 @@ impl TryFrom<YAMLMatch> for Match {
|
||||||
vars,
|
vars,
|
||||||
format: TextFormat::Plain,
|
format: TextFormat::Plain,
|
||||||
})
|
})
|
||||||
|
} else if let Some(image_path) = yaml_match.image_path { // TODO: test image case
|
||||||
|
MatchEffect::Image(ImageEffect {
|
||||||
|
path: image_path,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
MatchEffect::None
|
MatchEffect::None
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{collections::HashMap, path::Path};
|
use std::{path::Path};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml::{Mapping, Value};
|
use serde_yaml::{Mapping};
|
||||||
|
|
||||||
use crate::util::is_yaml_empty;
|
use crate::util::is_yaml_empty;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ pub struct YAMLMatch {
|
||||||
pub replace: Option<String>,
|
pub replace: Option<String>,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub image_path: Option<String>, // TODO: map
|
pub image_path: Option<String>,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub form: Option<String>,
|
pub form: Option<String>,
|
||||||
|
|
|
@ -94,7 +94,7 @@ pub enum UpperCasingStyle {
|
||||||
pub enum MatchEffect {
|
pub enum MatchEffect {
|
||||||
None,
|
None,
|
||||||
Text(TextEffect),
|
Text(TextEffect),
|
||||||
// TODO: image
|
Image(ImageEffect),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -121,6 +121,19 @@ impl Default for TextEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
pub struct ImageEffect {
|
||||||
|
pub path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ImageEffect {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
path: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Variable {
|
pub struct Variable {
|
||||||
pub id: StructId,
|
pub id: StructId,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user