Completed terminal hyperlink clicking functionality. Just need to display it now
This commit is contained in:
parent
f706cbe143
commit
5cd56584b4
3 changed files with 12 additions and 8 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5386,6 +5386,7 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"mio-extras",
|
"mio-extras",
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
|
|
|
@ -29,6 +29,8 @@ shellexpand = "2.1.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -64,6 +64,7 @@ use crate::mappings::{
|
||||||
colors::{get_color_at_index, to_alac_rgb},
|
colors::{get_color_at_index, to_alac_rgb},
|
||||||
keys::to_esc_str,
|
keys::to_esc_str,
|
||||||
};
|
};
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
///Initialize and register all of our action handlers
|
///Initialize and register all of our action handlers
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
|
@ -83,8 +84,11 @@ const DEBUG_TERMINAL_HEIGHT: f32 = 30.;
|
||||||
const DEBUG_CELL_WIDTH: f32 = 5.;
|
const DEBUG_CELL_WIDTH: f32 = 5.;
|
||||||
const DEBUG_LINE_HEIGHT: f32 = 5.;
|
const DEBUG_LINE_HEIGHT: f32 = 5.;
|
||||||
|
|
||||||
/// Copied from alacritty's ui_config.rs
|
// Regex Copied from alacritty's ui_config.rs
|
||||||
static URL_REGEX: RegexSearch = RegexSearch::new("(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>\"\\s{-}\\^⟨⟩`]+").unwrap();
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref URL_REGEX: RegexSearch = RegexSearch::new("(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>\"\\s{-}\\^⟨⟩`]+").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
///Upward flowing events, for changing the title and such
|
///Upward flowing events, for changing the title and such
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -659,6 +663,7 @@ impl Terminal {
|
||||||
|
|
||||||
if let Some(url_match) = regex_match_at(term, point, &URL_REGEX) {
|
if let Some(url_match) = regex_match_at(term, point, &URL_REGEX) {
|
||||||
let url = term.bounds_to_string(*url_match.start(), *url_match.end());
|
let url = term.bounds_to_string(*url_match.start(), *url_match.end());
|
||||||
|
dbg!(&url, &url_match, open);
|
||||||
|
|
||||||
if *open {
|
if *open {
|
||||||
open_uri(&url).log_err();
|
open_uri(&url).log_err();
|
||||||
|
@ -956,12 +961,8 @@ impl Terminal {
|
||||||
let position = e.position.sub(origin);
|
let position = e.position.sub(origin);
|
||||||
if !self.mouse_mode(e.shift) {
|
if !self.mouse_mode(e.shift) {
|
||||||
if e.cmd {
|
if e.cmd {
|
||||||
if let Some(link) = self.last_content.cells
|
let mouse_cell_index = content_index_for_mouse(position, &self.last_content);
|
||||||
[content_index_for_mouse(position, &self.last_content)]
|
if let Some(link) = self.last_content.cells[mouse_cell_index].hyperlink() {
|
||||||
.hyperlink()
|
|
||||||
{
|
|
||||||
dbg!(&link);
|
|
||||||
dbg!(&self.last_hovered_hyperlink);
|
|
||||||
open_uri(link.uri()).log_err();
|
open_uri(link.uri()).log_err();
|
||||||
} else {
|
} else {
|
||||||
self.events
|
self.events
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue