Add option to force clipboard use on a per-match basis. Fix #217

This commit is contained in:
Federico Terzi 2020-04-03 19:20:57 +02:00
parent 2dac99fde3
commit 30273c1f68
2 changed files with 9 additions and 1 deletions

View File

@ -189,7 +189,9 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
None
};
let backend = if config.backend == BackendType::Auto {
let backend = if m.force_clipboard {
&BackendType::Clipboard
}else if config.backend == BackendType::Auto {
if cfg!(target_os = "linux") {
let all_ascii = target_string.chars().all(|c| c.is_ascii());
if all_ascii {

View File

@ -34,6 +34,7 @@ pub struct Match {
pub word: bool,
pub passive_only: bool,
pub propagate_case: bool,
pub force_clipboard: bool,
// Automatically calculated from the triggers, used by the matcher to check for correspondences.
#[serde(skip_serializing)]
@ -170,6 +171,7 @@ impl<'a> From<&'a AutoMatch> for Match{
passive_only: other.passive_only,
_trigger_sequences: trigger_sequences,
propagate_case: other.propagate_case,
force_clipboard: other.force_clipboard,
}
}
}
@ -200,6 +202,9 @@ struct AutoMatch {
#[serde(default = "default_propagate_case")]
pub propagate_case: bool,
#[serde(default = "default_force_clipboard")]
pub force_clipboard: bool,
}
fn default_trigger() -> String {"".to_owned()}
@ -210,6 +215,7 @@ fn default_passive_only() -> bool {false}
fn default_replace() -> Option<String> {None}
fn default_image_path() -> Option<String> {None}
fn default_propagate_case() -> bool {false}
fn default_force_clipboard() -> bool {false}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MatchVariable {