diff options
author | Christian Duerr <contact@christianduerr.com> | 2019-11-03 21:59:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-03 21:59:28 +0100 |
commit | b47a88b142a8987f1d0d48db8c0db1e5f3048a76 (patch) | |
tree | 0863fb40b8e081ccc40f1437e74c49a68f4e6c59 /alacritty_terminal/src/url.rs | |
parent | fa6ceacfa4158c568c55dff85621788ff1df4099 (diff) | |
download | r-alacritty-b47a88b142a8987f1d0d48db8c0db1e5f3048a76.tar.gz r-alacritty-b47a88b142a8987f1d0d48db8c0db1e5f3048a76.tar.bz2 r-alacritty-b47a88b142a8987f1d0d48db8c0db1e5f3048a76.zip |
Fix URL highlighting
Fixes #2898.
Fixes #2479.
Diffstat (limited to 'alacritty_terminal/src/url.rs')
-rw-r--r-- | alacritty_terminal/src/url.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/alacritty_terminal/src/url.rs b/alacritty_terminal/src/url.rs deleted file mode 100644 index 9e8ecd4b..00000000 --- a/alacritty_terminal/src/url.rs +++ /dev/null @@ -1,44 +0,0 @@ -use crate::ansi::TermInfo; -use crate::index::{Column, Linear, Point}; -use crate::term::Term; -use std::ops::RangeInclusive; - -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd)] -pub struct Url { - pub start: Point<usize>, - pub end: Point<usize>, -} - -impl Url { - pub fn new(start: Point<usize>, length: usize, num_cols: usize) -> Self { - let unwrapped_end_col = start.col.0 + length - 1; - let end_col = unwrapped_end_col % num_cols; - let end_line = start.line - unwrapped_end_col / num_cols; - - Url { end: Point::new(end_line, Column(end_col)), start } - } - - /// Check if point is within this URL - pub fn contains(&self, point: impl Into<Point<usize>>) -> bool { - let point = point.into(); - - point.line <= self.start.line - && point.line >= self.end.line - && (point.line != self.start.line || point.col >= self.start.col) - && (point.line != self.end.line || point.col <= self.end.col) - } - - /// Convert URLs bounding points to linear indices - pub fn linear_bounds<T>(&self, terminal: &Term<T>) -> RangeInclusive<Linear> { - let mut start = self.start; - let mut end = self.end; - - start = terminal.buffer_to_visible(start); - end = terminal.buffer_to_visible(end); - - let start = Linear::from_point(terminal.cols(), start); - let end = Linear::from_point(terminal.cols(), end); - - RangeInclusive::new(start, end) - } -} |