diff options
Diffstat (limited to 'alacritty/src/url.rs')
-rw-r--r-- | alacritty/src/url.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/alacritty/src/url.rs b/alacritty/src/url.rs index f969c7af..f3f60dd3 100644 --- a/alacritty/src/url.rs +++ b/alacritty/src/url.rs @@ -48,7 +48,7 @@ impl Url { pub struct Urls { locator: UrlLocator, urls: Vec<Url>, - scheme_buffer: Vec<RenderableCell>, + scheme_buffer: Vec<(Point, Rgb)>, last_point: Option<Point>, state: UrlLocation, } @@ -71,10 +71,10 @@ impl Urls { } // Update tracked URLs. - pub fn update(&mut self, num_cols: Column, cell: RenderableCell) { + pub fn update(&mut self, num_cols: Column, cell: &RenderableCell) { // Convert cell to character. - let c = match cell.inner { - RenderableCellContent::Chars(chars) => chars[0], + let c = match &cell.inner { + RenderableCellContent::Chars((c, _zerowidth)) => *c, RenderableCellContent::Cursor(_) => return, }; @@ -109,9 +109,8 @@ impl Urls { self.urls.push(Url { lines: Vec::new(), end_offset, num_cols }); // Push schemes into URL. - for scheme_cell in self.scheme_buffer.split_off(0) { - let point = scheme_cell.into(); - self.extend_url(point, point, scheme_cell.fg, end_offset); + for (scheme_point, scheme_fg) in self.scheme_buffer.split_off(0) { + self.extend_url(scheme_point, scheme_point, scheme_fg, end_offset); } // Push the new cell into URL. @@ -120,7 +119,7 @@ impl Urls { (UrlLocation::Url(_length, end_offset), UrlLocation::Url(..)) => { self.extend_url(point, end, cell.fg, end_offset); }, - (UrlLocation::Scheme, _) => self.scheme_buffer.push(cell), + (UrlLocation::Scheme, _) => self.scheme_buffer.push((cell.into(), cell.fg)), (UrlLocation::Reset, _) => self.reset(), _ => (), } @@ -196,13 +195,12 @@ mod tests { use super::*; use alacritty_terminal::index::{Column, Line}; - use alacritty_terminal::term::cell::MAX_ZEROWIDTH_CHARS; fn text_to_cells(text: &str) -> Vec<RenderableCell> { text.chars() .enumerate() .map(|(i, c)| RenderableCell { - inner: RenderableCellContent::Chars([c; MAX_ZEROWIDTH_CHARS + 1]), + inner: RenderableCellContent::Chars((c, None)), line: Line(0), column: Column(i), fg: Default::default(), @@ -223,7 +221,7 @@ mod tests { let mut urls = Urls::new(); for cell in input { - urls.update(Column(num_cols), cell); + urls.update(Column(num_cols), &cell); } let url = urls.urls.first().unwrap(); @@ -239,7 +237,7 @@ mod tests { let mut urls = Urls::new(); for cell in input { - urls.update(Column(num_cols), cell); + urls.update(Column(num_cols), &cell); } assert_eq!(urls.urls.len(), 3); |