diff options
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 348db610..ce89625b 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -103,6 +103,7 @@ pub trait ActionContext<T: EventListener> { fn advance_search_origin(&mut self, direction: Direction); fn search_direction(&self) -> Direction; fn search_active(&self) -> bool; + fn on_typing_start(&mut self); } trait Execute<T: EventListener> { @@ -138,9 +139,7 @@ impl<T: EventListener> Execute<T> for Action { fn execute<A: ActionContext<T>>(&self, ctx: &mut A) { match *self { Action::Esc(ref s) => { - if ctx.config().ui_config.mouse.hide_when_typing { - ctx.window_mut().set_mouse_visible(false); - } + ctx.on_typing_start(); ctx.clear_selection(); ctx.scroll(Scroll::Bottom); @@ -167,10 +166,7 @@ impl<T: EventListener> Execute<T> for Action { Action::ClearSelection => ctx.clear_selection(), Action::ToggleViMode => ctx.terminal_mut().toggle_vi_mode(), Action::ViMotion(motion) => { - if ctx.config().ui_config.mouse.hide_when_typing { - ctx.window_mut().set_mouse_visible(false); - } - + ctx.on_typing_start(); ctx.terminal_mut().vi_motion(motion) }, Action::ViAction(ViAction::ToggleNormalSelection) => { @@ -870,6 +866,13 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { self.ctx.window_mut().set_mouse_cursor(mouse_state.into()); } + /// Reset mouse cursor based on modifier and terminal state. + #[inline] + pub fn reset_mouse_cursor(&mut self) { + let mouse_state = self.mouse_state(); + self.ctx.window_mut().set_mouse_cursor(mouse_state.into()); + } + /// Process a received character. pub fn received_char(&mut self, c: char) { let suppress_chars = *self.ctx.suppress_chars(); @@ -890,9 +893,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { return; } - if self.ctx.config().ui_config.mouse.hide_when_typing { - self.ctx.window_mut().set_mouse_visible(false); - } + self.ctx.on_typing_start(); self.ctx.scroll(Scroll::Bottom); self.ctx.clear_selection(); @@ -917,13 +918,6 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { *self.ctx.received_count() += 1; } - /// Reset mouse cursor based on modifier and terminal state. - #[inline] - pub fn reset_mouse_cursor(&mut self) { - let mouse_state = self.mouse_state(); - self.ctx.window_mut().set_mouse_cursor(mouse_state.into()); - } - /// Attempt to find a binding and execute its action. /// /// The provided mode, mods, and key must match what is allowed by a binding @@ -1270,6 +1264,10 @@ mod tests { fn scheduler_mut(&mut self) -> &mut Scheduler { unimplemented!(); } + + fn on_typing_start(&mut self) { + unimplemented!(); + } } macro_rules! test_clickstate { |