summaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-10-22 19:39:26 +0000
committerGitHub <noreply@github.com>2018-10-22 19:39:26 +0000
commit8ee0d2b5b26faacb5f2663bae1fc056ac5ee26bf (patch)
tree093022ebdb474b891c8946ae42972dc23f73fefe /src/event.rs
parent4380d0864b1098909bdcfec132b866c34924517e (diff)
downloadalacritty-8ee0d2b5b26faacb5f2663bae1fc056ac5ee26bf.tar.gz
alacritty-8ee0d2b5b26faacb5f2663bae1fc056ac5ee26bf.zip
Add option to open URLs on click
This adds the option to automatically launch URLs with a specified program when clicking on them. The config option `mouse.url_launcher` has been added to specify which program should be used to open the URL. The URL is always passed as the last parameter to the specified command. It is not always desired for URLs to open automatically when clicking on them. To resolve this a new `modifiers` field has been introduced to the config, which allows specifying which keyboard modifiers need to be held down to launch URLs in the specified launcher. Some tests have been added to make sure that the edge-cases of the URL parsing are protected against future regressions. To make testing easier the parsing method has been moved into the `SemanticSearch` trait. The name of the trait has also been changed to just `Search` and it has been moved to `src/term/mod.rs` to fit the additional functionality. This fixes #113.
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/event.rs b/src/event.rs
index eef04a8c..185a7d70 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -19,7 +19,7 @@ use index::{Line, Column, Side, Point};
use input::{self, MouseBinding, KeyBinding};
use selection::Selection;
use sync::FairMutex;
-use term::{Term, SizeInfo, TermMode};
+use term::{Term, SizeInfo, TermMode, Search};
use util::limit;
use util::fmt::Red;
use window::Window;
@@ -76,6 +76,10 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
}
}
+ fn selection_is_empty(&self) -> bool {
+ self.terminal.selection().as_ref().map(|s| s.is_empty()).unwrap_or(true)
+ }
+
fn clear_selection(&mut self) {
*self.terminal.selection_mut() = None;
self.terminal.dirty = true;
@@ -104,6 +108,10 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
self.terminal.dirty = true;
}
+ fn url(&self, point: Point<usize>) -> Option<String> {
+ self.terminal.url_search(point)
+ }
+
fn line_selection(&mut self, point: Point) {
let point = self.terminal.visible_to_buffer(point);
*self.terminal.selection_mut() = Some(Selection::lines(point));
@@ -196,6 +204,7 @@ pub struct Mouse {
pub column: Column,
pub cell_side: Side,
pub lines_scrolled: f32,
+ pub block_url_launcher: bool,
}
impl Default for Mouse {
@@ -213,6 +222,7 @@ impl Default for Mouse {
column: Column(0),
cell_side: Side::Left,
lines_scrolled: 0.0,
+ block_url_launcher: false,
}
}
}