diff options
author | Dettorer <Dettorer@users.noreply.github.com> | 2020-11-24 00:11:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 23:11:03 +0000 |
commit | 2fd2db4afa232ebd15dbfff88160224badeaa669 (patch) | |
tree | ef0cdf3311df017da5fff4d29ce898d690980a3e /alacritty/src/input.rs | |
parent | 07cfe8bbba0851ff4989f6aaf082d72130cd0f5b (diff) | |
download | r-alacritty-2fd2db4afa232ebd15dbfff88160224badeaa669.tar.gz r-alacritty-2fd2db4afa232ebd15dbfff88160224badeaa669.tar.bz2 r-alacritty-2fd2db4afa232ebd15dbfff88160224badeaa669.zip |
Add blinking cursor support
This adds support for blinking the terminal cursor. This can be
controlled either using the configuration file, or using escape
sequences.
The supported control sequences for changing the blinking state are
`CSI Ps SP q` and private mode 12.
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 { |