diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-08-03 13:19:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-03 13:19:33 +0000 |
commit | 5a40149069c91f63f9dcbf5fb46b36144b30eb95 (patch) | |
tree | 8503ba4ad05ac7e77268a29809c2800cd24da1b0 /alacritty_terminal/src/grid | |
parent | 9dddf649a15d103295f4ce97b8ae4c178c9623e0 (diff) | |
download | r-alacritty-5a40149069c91f63f9dcbf5fb46b36144b30eb95.tar.gz r-alacritty-5a40149069c91f63f9dcbf5fb46b36144b30eb95.tar.bz2 r-alacritty-5a40149069c91f63f9dcbf5fb46b36144b30eb95.zip |
Move modifier check before URL search
This makes sure that the URL search is only initiated when all required
modifiers are held down. This should improve performance with long URLs.
Diffstat (limited to 'alacritty_terminal/src/grid')
-rw-r--r-- | alacritty_terminal/src/grid/mod.rs | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs index e2cda175..2d191d20 100644 --- a/alacritty_terminal/src/grid/mod.rs +++ b/alacritty_terminal/src/grid/mod.rs @@ -119,13 +119,6 @@ pub enum Scroll { Bottom, } -#[derive(Copy, Clone)] -enum ViewportPosition { - Visible(Line), - Above, - Below, -} - impl<T: GridCell + Copy + Clone> Grid<T> { pub fn new(lines: index::Line, cols: index::Column, scrollback: usize, template: T) -> Grid<T> { let raw = Storage::with_capacity(lines, Row::new(cols, &template)); @@ -144,30 +137,19 @@ impl<T: GridCell + Copy + Clone> Grid<T> { pub fn buffer_to_visible(&self, point: impl Into<Point<usize>>) -> Point<usize> { let mut point = point.into(); - match self.buffer_line_to_visible(point.line) { - ViewportPosition::Visible(line) => point.line = line.0, - ViewportPosition::Above => { - point.col = Column(0); - point.line = 0; - }, - ViewportPosition::Below => { - point.col = self.num_cols(); - point.line = self.num_lines().0 - 1; - }, - } + let offset = point.line.saturating_sub(self.display_offset); - point - } - - fn buffer_line_to_visible(&self, line: usize) -> ViewportPosition { - let offset = line.saturating_sub(self.display_offset); - if line < self.display_offset { - ViewportPosition::Below + if point.line < self.display_offset { + point.col = self.num_cols(); + point.line = self.num_lines().0 - 1; } else if offset >= *self.num_lines() { - ViewportPosition::Above + point.col = Column(0); + point.line = 0; } else { - ViewportPosition::Visible(self.lines - offset - 1) + point.line = self.lines.0 - offset - 1; } + + point } pub fn visible_to_buffer(&self, point: Point) -> Point<usize> { |