Add options to selectively disable active and passive mode

This commit is contained in:
Federico Terzi 2020-01-26 22:30:54 +01:00
parent 9139c9b3b4
commit 025d00ad26
2 changed files with 15 additions and 7 deletions

View File

@ -46,7 +46,6 @@ fn default_parent() -> String{ "self".to_owned() }
fn default_filter_title() -> String{ "".to_owned() } fn default_filter_title() -> String{ "".to_owned() }
fn default_filter_class() -> String{ "".to_owned() } fn default_filter_class() -> String{ "".to_owned() }
fn default_filter_exec() -> String{ "".to_owned() } fn default_filter_exec() -> String{ "".to_owned() }
fn default_disabled() -> bool{ false }
fn default_log_level() -> i32 { 0 } fn default_log_level() -> i32 { 0 }
fn default_conflict_check() -> bool{ true } fn default_conflict_check() -> bool{ true }
fn default_ipc_server_port() -> i32 { 34982 } fn default_ipc_server_port() -> i32 { 34982 }
@ -60,6 +59,8 @@ fn default_passive_match_regex() -> String{ "(?P<name>:\\p{L}+)(/(?P<args>.*)/)?
fn default_passive_arg_delimiter() -> char { '/' } fn default_passive_arg_delimiter() -> char { '/' }
fn default_passive_arg_escape() -> char { '\\' } fn default_passive_arg_escape() -> char { '\\' }
fn default_passive_key() -> KeyModifier { KeyModifier::OFF } fn default_passive_key() -> KeyModifier { KeyModifier::OFF }
fn default_enable_passive() -> bool { false }
fn default_enable_active() -> bool { true }
fn default_action_noop_interval() -> u128 { 500 } fn default_action_noop_interval() -> u128 { 500 }
fn default_backspace_limit() -> i32 { 3 } fn default_backspace_limit() -> i32 { 3 }
fn default_exclude_default_matches() -> bool {false} fn default_exclude_default_matches() -> bool {false}
@ -82,9 +83,6 @@ pub struct Configs {
#[serde(default = "default_filter_exec")] #[serde(default = "default_filter_exec")]
pub filter_exec: String, pub filter_exec: String,
#[serde(default = "default_disabled")]
pub disabled: bool,
#[serde(default = "default_log_level")] #[serde(default = "default_log_level")]
pub log_level: i32, pub log_level: i32,
@ -124,6 +122,12 @@ pub struct Configs {
#[serde(default = "default_passive_key")] #[serde(default = "default_passive_key")]
pub passive_key: KeyModifier, pub passive_key: KeyModifier,
#[serde(default = "default_enable_passive")]
pub enable_passive: bool,
#[serde(default = "default_enable_active")]
pub enable_active: bool,
#[serde(default = "default_action_noop_interval")] #[serde(default = "default_action_noop_interval")]
pub action_noop_interval: u128, pub action_noop_interval: u128,

View File

@ -135,7 +135,7 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
fn on_match(&self, m: &Match, trailing_separator: Option<char>) { fn on_match(&self, m: &Match, trailing_separator: Option<char>) {
let config = self.config_manager.active_config(); let config = self.config_manager.active_config();
if config.disabled { if !config.enable_active {
return; return;
} }
@ -269,6 +269,12 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
return; return;
} }
let config = self.config_manager.active_config();
if !config.enable_passive {
return;
}
info!("Passive mode activated"); info!("Passive mode activated");
// Trigger a copy shortcut to transfer the content of the selection to the clipboard // Trigger a copy shortcut to transfer the content of the selection to the clipboard
@ -281,8 +287,6 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
let clipboard = self.clipboard_manager.get_clipboard(); let clipboard = self.clipboard_manager.get_clipboard();
if let Some(clipboard) = clipboard { if let Some(clipboard) = clipboard {
let config = self.config_manager.active_config();
let rendered = self.renderer.render_passive(&clipboard, let rendered = self.renderer.render_passive(&clipboard,
&config); &config);