aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/lib.rs')
-rw-r--r--helix-term/src/lib.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs
index a94c5e49..a1d60329 100644
--- a/helix-term/src/lib.rs
+++ b/helix-term/src/lib.rs
@@ -12,7 +12,11 @@ pub mod keymap;
pub mod ui;
use std::path::Path;
+use futures_util::Future;
use ignore::DirEntry;
+use url::Url;
+
+pub use keymap::macros::*;
#[cfg(not(windows))]
fn true_color() -> bool {
@@ -46,3 +50,22 @@ fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> b
true
}
+
+/// Opens URL in external program.
+fn open_external_url_callback(
+ url: Url,
+) -> impl Future<Output = Result<job::Callback, anyhow::Error>> + Send + 'static {
+ let commands = open::commands(url.as_str());
+ async {
+ for cmd in commands {
+ let mut command = tokio::process::Command::new(cmd.get_program());
+ command.args(cmd.get_args());
+ if command.output().await.is_ok() {
+ return Ok(job::Callback::Editor(Box::new(|_| {})));
+ }
+ }
+ Ok(job::Callback::Editor(Box::new(move |editor| {
+ editor.set_error("Opening URL in external program failed")
+ })))
+ }
+}