diff options
author | Jason Heard <jasonh@pandell.com> | 2021-07-29 09:40:51 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-29 15:40:51 +0000 |
commit | 3c309a0953566fe6f726b84eb117fd9cfa42df3d (patch) | |
tree | d6f4c6200bc4f9a6abb192adeee5bb15b4603815 /alacritty/src/event.rs | |
parent | 96a098c358870e8be41921f19ed72810651106ae (diff) | |
download | r-alacritty-3c309a0953566fe6f726b84eb117fd9cfa42df3d.tar.gz r-alacritty-3c309a0953566fe6f726b84eb117fd9cfa42df3d.tar.bz2 r-alacritty-3c309a0953566fe6f726b84eb117fd9cfa42df3d.zip |
Add ExpandSelection mouse binding action
Fixes #4132.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r-- | alacritty/src/event.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 37d28bb9..bc9c305a 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -671,6 +671,42 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon } } + /// Expand the selection to the current mouse cursor position. + #[inline] + fn expand_selection(&mut self) { + let selection_type = match self.mouse().click_state { + ClickState::Click => { + if self.modifiers().ctrl() { + SelectionType::Block + } else { + SelectionType::Simple + } + }, + ClickState::DoubleClick => SelectionType::Semantic, + ClickState::TripleClick => SelectionType::Lines, + ClickState::None => return, + }; + + // Load mouse point, treating message bar and padding as the closest cell. + let display_offset = self.terminal().grid().display_offset(); + let point = self.mouse().point(&self.size_info(), display_offset); + + let cell_side = self.mouse().cell_side; + + let selection = match &mut self.terminal_mut().selection { + Some(selection) => selection, + None => return, + }; + + selection.ty = selection_type; + self.update_selection(point, cell_side); + + // Move vi mode cursor to mouse click position. + if self.terminal().mode().contains(TermMode::VI) && !self.search_active() { + self.terminal_mut().vi_mode_cursor.point = point; + } + } + /// Paste a text into the terminal. fn paste(&mut self, text: &str) { if self.search_active() { |