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::Command;
use std::rc::Rc;
use termwiz::hyperlink::Hyperlink;
use term::{self, KeyCode, KeyModifiers, MouseButton, MouseEvent, MouseEventKind};
use termwiz::hyperlink::Hyperlink;
use xcb;
/// 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::str;
use termwiz::hyperlink::Rule;
use super::*;
@ -266,12 +266,10 @@ impl Line {
// Clear any cells that have implicit hyperlinks
for mut cell in &mut self.cells {
let replace = match cell.attrs().hyperlink {
Some(ref link) if link.is_implicit() => {
Some(Cell::new_grapheme(
cell.str(),
cell.attrs().clone().set_hyperlink(None).clone(),
))
}
Some(ref link) if link.is_implicit() => Some(Cell::new_grapheme(
cell.str(),
cell.attrs().clone().set_hyperlink(None).clone(),
)),
_ => None,
};
if let Some(replace) = replace {

View File

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

View File

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

View File

@ -1,6 +1,6 @@
use cell::{AttributeChange, CellAttributes};
use color::ColorAttribute;
use surface::{CursorShape,Position};
use surface::{CursorShape, Position};
/// `Change` describes an update operation to be applied to a `Surface`.
/// 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 {
let replace = match cell.attrs().hyperlink {
Some(ref link) if link.is_implicit() => {
Some(Cell::new_grapheme(
cell.str(),
cell.attrs().clone().set_hyperlink(None).clone(),
))
}
Some(ref link) if link.is_implicit() => Some(Cell::new_grapheme(
cell.str(),
cell.attrs().clone().set_hyperlink(None).clone(),
)),
_ => None,
};
if let Some(replace) = replace {
@ -71,7 +69,7 @@ impl Line {
}
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

View File

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