summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/input.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-08-03 13:19:33 +0000
committerGitHub <noreply@github.com>2019-08-03 13:19:33 +0000
commit5a40149069c91f63f9dcbf5fb46b36144b30eb95 (patch)
tree8503ba4ad05ac7e77268a29809c2800cd24da1b0 /alacritty_terminal/src/input.rs
parent9dddf649a15d103295f4ce97b8ae4c178c9623e0 (diff)
downloadalacritty-5a40149069c91f63f9dcbf5fb46b36144b30eb95.tar.gz
alacritty-5a40149069c91f63f9dcbf5fb46b36144b30eb95.zip
Move modifier check before URL search
This makes sure that the URL search is only initiated when all required modifiers are held down. This should improve performance with long URLs.
Diffstat (limited to 'alacritty_terminal/src/input.rs')
-rw-r--r--alacritty_terminal/src/input.rs45
1 files changed, 24 insertions, 21 deletions
diff --git a/alacritty_terminal/src/input.rs b/alacritty_terminal/src/input.rs
index 8eceef16..3cf6247c 100644
--- a/alacritty_terminal/src/input.rs
+++ b/alacritty_terminal/src/input.rs
@@ -389,23 +389,34 @@ enum MousePosition {
}
impl<'a, A: ActionContext + 'a> Processor<'a, A> {
- fn mouse_position(&mut self, point: Point) -> MousePosition {
+ fn mouse_position(&mut self, point: Point, modifiers: ModifiersState) -> MousePosition {
+ let mouse_mode =
+ TermMode::MOUSE_MOTION | TermMode::MOUSE_DRAG | TermMode::MOUSE_REPORT_CLICK;
+
let buffer_point = self.ctx.terminal().visible_to_buffer(point);
// Check message bar before URL to ignore URLs in the message bar
if let Some(message) = self.message_at_point(Some(point)) {
if self.message_close_at_point(point, message) {
- MousePosition::MessageBarButton
+ return MousePosition::MessageBarButton;
} else {
- MousePosition::MessageBar
+ return MousePosition::MessageBar;
}
- } else if let Some(url) =
- self.ctx.terminal().urls().drain(..).find(|url| url.contains(buffer_point))
+ }
+
+ // Check for URL at point with required modifiers held
+ if self.mouse_config.url.mods().relaxed_eq(modifiers)
+ && (!self.ctx.terminal().mode().intersects(mouse_mode) || modifiers.shift)
+ && self.mouse_config.url.launcher.is_some()
{
- MousePosition::Url(url)
- } else {
- MousePosition::Terminal
+ if let Some(url) =
+ self.ctx.terminal().urls().drain(..).find(|url| url.contains(buffer_point))
+ {
+ return MousePosition::Url(url);
+ }
}
+
+ MousePosition::Terminal
}
#[inline]
@@ -435,20 +446,12 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
// Don't launch URLs if mouse has moved
self.ctx.mouse_mut().block_url_launcher = true;
- match self.mouse_position(point) {
+ match self.mouse_position(point, modifiers) {
MousePosition::Url(url) => {
- let mouse_mode =
- TermMode::MOUSE_MOTION | TermMode::MOUSE_DRAG | TermMode::MOUSE_REPORT_CLICK;
-
- if self.mouse_config.url.mods().relaxed_eq(modifiers)
- && (!self.ctx.terminal().mode().intersects(mouse_mode) || modifiers.shift)
- && self.mouse_config.url.launcher.is_some()
- {
- let url_bounds = url.linear_bounds(self.ctx.terminal());
- self.ctx.terminal_mut().set_url_highlight(url_bounds);
- self.ctx.terminal_mut().set_mouse_cursor(MouseCursor::Hand);
- self.ctx.terminal_mut().dirty = true;
- }
+ let url_bounds = url.linear_bounds(self.ctx.terminal());
+ self.ctx.terminal_mut().set_url_highlight(url_bounds);
+ self.ctx.terminal_mut().set_mouse_cursor(MouseCursor::Hand);
+ self.ctx.terminal_mut().dirty = true;
},
MousePosition::MessageBar => {
self.ctx.terminal_mut().reset_url_highlight();