feat(core): wire up backspace_limit option
This commit is contained in:
parent
ddbfa06881
commit
05920fbebc
|
@ -129,9 +129,7 @@ impl<'a> super::engine::dispatch::executor::clipboard_injector::ClipboardParamsP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> super::engine::dispatch::executor::InjectParamsProvider
|
impl<'a> super::engine::dispatch::executor::InjectParamsProvider for ConfigManager<'a> {
|
||||||
for ConfigManager<'a>
|
|
||||||
{
|
|
||||||
fn get(&self) -> super::engine::dispatch::executor::InjectParams {
|
fn get(&self) -> super::engine::dispatch::executor::InjectParams {
|
||||||
let active = self.active();
|
let active = self.active();
|
||||||
super::engine::dispatch::executor::InjectParams {
|
super::engine::dispatch::executor::InjectParams {
|
||||||
|
@ -140,4 +138,10 @@ impl<'a> super::engine::dispatch::executor::InjectParamsProvider
|
||||||
key_delay: active.key_delay(),
|
key_delay: active.key_delay(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> crate::engine::process::MatcherMiddlewareConfigProvider for ConfigManager<'a> {
|
||||||
|
fn max_history_size(&self) -> usize {
|
||||||
|
self.default().backspace_limit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ pub fn initialize_and_spawn(
|
||||||
&sequencer,
|
&sequencer,
|
||||||
&path_provider,
|
&path_provider,
|
||||||
disable_options,
|
disable_options,
|
||||||
|
&config_manager,
|
||||||
);
|
);
|
||||||
|
|
||||||
let event_injector = EventInjectorAdapter::new(&*injector, &config_manager);
|
let event_injector = EventInjectorAdapter::new(&*injector, &config_manager);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
use log::trace;
|
use log::trace;
|
||||||
|
|
||||||
use super::{DisableOptions, MatchFilter, MatchInfoProvider, MatchSelector, Matcher, Middleware, Multiplexer, PathProvider, Processor, Renderer, middleware::{
|
use super::{DisableOptions, MatchFilter, MatchInfoProvider, MatchSelector, Matcher, MatcherMiddlewareConfigProvider, Middleware, Multiplexer, PathProvider, Processor, Renderer, middleware::{
|
||||||
match_select::MatchSelectMiddleware, matcher::MatcherMiddleware, multiplex::MultiplexMiddleware,
|
match_select::MatchSelectMiddleware, matcher::MatcherMiddleware, multiplex::MultiplexMiddleware,
|
||||||
render::RenderMiddleware, action::{ActionMiddleware, EventSequenceProvider}, cursor_hint::CursorHintMiddleware, cause::CauseCompensateMiddleware,
|
render::RenderMiddleware, action::{ActionMiddleware, EventSequenceProvider}, cursor_hint::CursorHintMiddleware, cause::CauseCompensateMiddleware,
|
||||||
delay_modifiers::{DelayForModifierReleaseMiddleware, ModifierStatusProvider}, markdown::MarkdownMiddleware,
|
delay_modifiers::{DelayForModifierReleaseMiddleware, ModifierStatusProvider}, markdown::MarkdownMiddleware,
|
||||||
|
@ -45,6 +45,7 @@ impl<'a> DefaultProcessor<'a> {
|
||||||
event_sequence_provider: &'a dyn EventSequenceProvider,
|
event_sequence_provider: &'a dyn EventSequenceProvider,
|
||||||
path_provider: &'a dyn PathProvider,
|
path_provider: &'a dyn PathProvider,
|
||||||
disable_options: DisableOptions,
|
disable_options: DisableOptions,
|
||||||
|
matcher_options_provider: &'a dyn MatcherMiddlewareConfigProvider,
|
||||||
) -> DefaultProcessor<'a> {
|
) -> DefaultProcessor<'a> {
|
||||||
Self {
|
Self {
|
||||||
event_queue: VecDeque::new(),
|
event_queue: VecDeque::new(),
|
||||||
|
@ -52,7 +53,7 @@ impl<'a> DefaultProcessor<'a> {
|
||||||
Box::new(PastEventsDiscardMiddleware::new()),
|
Box::new(PastEventsDiscardMiddleware::new()),
|
||||||
Box::new(DisableMiddleware::new(disable_options)),
|
Box::new(DisableMiddleware::new(disable_options)),
|
||||||
Box::new(IconStatusMiddleware::new()),
|
Box::new(IconStatusMiddleware::new()),
|
||||||
Box::new(MatcherMiddleware::new(matchers)),
|
Box::new(MatcherMiddleware::new(matchers, matcher_options_provider)),
|
||||||
Box::new(ContextMenuMiddleware::new()),
|
Box::new(ContextMenuMiddleware::new()),
|
||||||
Box::new(MatchSelectMiddleware::new(match_filter, match_selector)),
|
Box::new(MatchSelectMiddleware::new(match_filter, match_selector)),
|
||||||
Box::new(CauseCompensateMiddleware::new()),
|
Box::new(CauseCompensateMiddleware::new()),
|
||||||
|
|
|
@ -30,19 +30,26 @@ use crate::engine::{
|
||||||
process::{Matcher, MatcherEvent},
|
process::{Matcher, MatcherEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAX_HISTORY: usize = 3; // TODO: get as parameter
|
pub trait MatcherMiddlewareConfigProvider {
|
||||||
|
fn max_history_size(&self) -> usize;
|
||||||
|
}
|
||||||
|
|
||||||
pub struct MatcherMiddleware<'a, State> {
|
pub struct MatcherMiddleware<'a, State> {
|
||||||
matchers: &'a [&'a dyn Matcher<'a, State>],
|
matchers: &'a [&'a dyn Matcher<'a, State>],
|
||||||
|
|
||||||
matcher_states: RefCell<VecDeque<Vec<State>>>,
|
matcher_states: RefCell<VecDeque<Vec<State>>>,
|
||||||
|
|
||||||
|
max_history_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, State> MatcherMiddleware<'a, State> {
|
impl<'a, State> MatcherMiddleware<'a, State> {
|
||||||
pub fn new(matchers: &'a [&'a dyn Matcher<'a, State>]) -> Self {
|
pub fn new(matchers: &'a [&'a dyn Matcher<'a, State>], options_provider: &'a dyn MatcherMiddlewareConfigProvider) -> Self {
|
||||||
|
let max_history_size = options_provider.max_history_size();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
matchers,
|
matchers,
|
||||||
matcher_states: RefCell::new(VecDeque::new()),
|
matcher_states: RefCell::new(VecDeque::new()),
|
||||||
|
max_history_size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +99,7 @@ impl<'a, State> Middleware for MatcherMiddleware<'a, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
matcher_states.push_back(new_states);
|
matcher_states.push_back(new_states);
|
||||||
if matcher_states.len() > MAX_HISTORY {
|
if matcher_states.len() > self.max_history_size {
|
||||||
matcher_states.pop_front();
|
matcher_states.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ pub use middleware::action::{MatchInfoProvider, EventSequenceProvider};
|
||||||
pub use middleware::delay_modifiers::ModifierStatusProvider;
|
pub use middleware::delay_modifiers::ModifierStatusProvider;
|
||||||
pub use middleware::image_resolve::PathProvider;
|
pub use middleware::image_resolve::PathProvider;
|
||||||
pub use middleware::disable::DisableOptions;
|
pub use middleware::disable::DisableOptions;
|
||||||
|
pub use middleware::matcher::MatcherMiddlewareConfigProvider;
|
||||||
|
|
||||||
pub fn default<'a, MatcherState>(
|
pub fn default<'a, MatcherState>(
|
||||||
matchers: &'a [&'a dyn Matcher<'a, MatcherState>],
|
matchers: &'a [&'a dyn Matcher<'a, MatcherState>],
|
||||||
|
@ -108,6 +109,7 @@ pub fn default<'a, MatcherState>(
|
||||||
event_sequence_provider: &'a dyn EventSequenceProvider,
|
event_sequence_provider: &'a dyn EventSequenceProvider,
|
||||||
path_provider: &'a dyn PathProvider,
|
path_provider: &'a dyn PathProvider,
|
||||||
disable_options: DisableOptions,
|
disable_options: DisableOptions,
|
||||||
|
matcher_options_provider: &'a dyn MatcherMiddlewareConfigProvider,
|
||||||
) -> impl Processor + 'a {
|
) -> impl Processor + 'a {
|
||||||
default::DefaultProcessor::new(
|
default::DefaultProcessor::new(
|
||||||
matchers,
|
matchers,
|
||||||
|
@ -120,5 +122,6 @@ pub fn default<'a, MatcherState>(
|
||||||
event_sequence_provider,
|
event_sequence_provider,
|
||||||
path_provider,
|
path_provider,
|
||||||
disable_options,
|
disable_options,
|
||||||
|
matcher_options_provider,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user