1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00
This commit is contained in:
Wez Furlong 2018-08-05 09:14:40 -07:00
parent e2461b2380
commit 18f34545b3
7 changed files with 21 additions and 34 deletions

View File

@ -17,8 +17,8 @@ use std::os::unix::io::{AsRawFd, RawFd};
use std::process::Child; use std::process::Child;
use std::process::Command; use std::process::Command;
use std::rc::Rc; use std::rc::Rc;
use termwiz::hyperlink::Hyperlink;
use term::{self, KeyCode, KeyModifiers, MouseButton, MouseEvent, MouseEventKind}; use term::{self, KeyCode, KeyModifiers, MouseButton, MouseEvent, MouseEventKind};
use termwiz::hyperlink::Hyperlink;
use xcb; use xcb;
/// Holds the terminal state for a tab owned by this window /// Holds the terminal state for a tab owned by this window

View File

@ -1,6 +1,6 @@
use termwiz::hyperlink::Rule;
use std::ops::Range; use std::ops::Range;
use std::str; use std::str;
use termwiz::hyperlink::Rule;
use super::*; use super::*;
@ -266,12 +266,10 @@ impl Line {
// Clear any cells that have implicit hyperlinks // Clear any cells that have implicit hyperlinks
for mut cell in &mut self.cells { for mut cell in &mut self.cells {
let replace = match cell.attrs().hyperlink { let replace = match cell.attrs().hyperlink {
Some(ref link) if link.is_implicit() => { Some(ref link) if link.is_implicit() => Some(Cell::new_grapheme(
Some(Cell::new_grapheme( cell.str(),
cell.str(), cell.attrs().clone().set_hyperlink(None).clone(),
cell.attrs().clone().set_hyperlink(None).clone(), )),
))
}
_ => None, _ => None,
}; };
if let Some(replace) = replace { if let Some(replace) = replace {

View File

@ -1,8 +1,8 @@
use base64; use base64;
use failure::{self, Error}; use failure::{self, Error};
pub use hyperlink::Hyperlink;
use num; use num;
use std::fmt::{Display, Error as FmtError, Formatter}; use std::fmt::{Display, Error as FmtError, Formatter};
pub use hyperlink::Hyperlink;
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum OperatingSystemCommand { pub enum OperatingSystemCommand {

View File

@ -57,7 +57,7 @@ impl Hyperlink {
Self { Self {
uri: uri.into(), uri: uri.into(),
params, params,
implicit:false, implicit: false,
} }
} }
@ -65,7 +65,7 @@ impl Hyperlink {
Self { Self {
uri: uri.into(), uri: uri.into(),
params, params,
implicit:false, implicit: false,
} }
} }
@ -219,9 +219,7 @@ impl Rule {
.into_iter() .into_iter()
.map(|m| { .map(|m| {
let url = m.expand(); let url = m.expand();
let link = Rc::new(Hyperlink::new_implicit( let link = Rc::new(Hyperlink::new_implicit(url));
url
));
RuleMatch { RuleMatch {
link, link,
range: m.range(), range: m.range(),
@ -246,9 +244,7 @@ mod test {
Rule::match_hyperlinks(" http://example.com", &rules), Rule::match_hyperlinks(" http://example.com", &rules),
vec![RuleMatch { vec![RuleMatch {
range: 2..20, range: 2..20,
link: Rc::new(Hyperlink::new_implicit( link: Rc::new(Hyperlink::new_implicit("http://example.com")),
"http://example.com",
)),
}] }]
); );
@ -258,15 +254,11 @@ mod test {
// Longest match first // Longest match first
RuleMatch { RuleMatch {
range: 18..34, range: 18..34,
link: Rc::new(Hyperlink::new_implicit( link: Rc::new(Hyperlink::new_implicit("mailto:woot@example.com")),
"mailto:woot@example.com",
)),
}, },
RuleMatch { RuleMatch {
range: 2..17, range: 2..17,
link: Rc::new(Hyperlink::new_implicit( link: Rc::new(Hyperlink::new_implicit("mailto:foo@example.com")),
"mailto:foo@example.com",
)),
}, },
] ]
); );

View File

@ -1,6 +1,6 @@
use cell::{AttributeChange, CellAttributes}; use cell::{AttributeChange, CellAttributes};
use color::ColorAttribute; use color::ColorAttribute;
use surface::{CursorShape,Position}; use surface::{CursorShape, Position};
/// `Change` describes an update operation to be applied to a `Surface`. /// `Change` describes an update operation to be applied to a `Surface`.
/// Changes to the active attributes (color, style), moving the cursor /// Changes to the active attributes (color, style), moving the cursor

View File

@ -57,12 +57,10 @@ impl Line {
} }
for mut cell in &mut self.cells { for mut cell in &mut self.cells {
let replace = match cell.attrs().hyperlink { let replace = match cell.attrs().hyperlink {
Some(ref link) if link.is_implicit() => { Some(ref link) if link.is_implicit() => Some(Cell::new_grapheme(
Some(Cell::new_grapheme( cell.str(),
cell.str(), cell.attrs().clone().set_hyperlink(None).clone(),
cell.attrs().clone().set_hyperlink(None).clone(), )),
))
}
_ => None, _ => None,
}; };
if let Some(replace) = replace { if let Some(replace) = replace {
@ -71,7 +69,7 @@ impl Line {
} }
self.bits &= !LineBits::HAS_IMPLICIT_HYPERLINKS; self.bits &= !LineBits::HAS_IMPLICIT_HYPERLINKS;
self.bits |= LineBits::SCANNED_IMPLICIT_HYPERLINKS|LineBits::DIRTY; self.bits |= LineBits::SCANNED_IMPLICIT_HYPERLINKS | LineBits::DIRTY;
} }
/// If we're about to modify a cell obscured by a double-width /// If we're about to modify a cell obscured by a double-width

View File

@ -4,12 +4,11 @@ use std::borrow::Cow;
use std::cmp::min; use std::cmp::min;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
pub mod line;
pub mod change; pub mod change;
pub mod line;
pub use self::line::Line;
pub use self::change::Change; pub use self::change::Change;
pub use self::line::Line;
/// Position holds 0-based positioning information, where /// Position holds 0-based positioning information, where
/// Absolute(0) is the start of the line or column, /// Absolute(0) is the start of the line or column,