diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-06-18 01:02:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 01:02:56 +0000 |
commit | 87e5b1aa25ea61937fa5f79668d2a46e88707c5e (patch) | |
tree | 59205d2e00072a5f8737dc104f57fc940db0c2ec /alacritty_terminal/src/term | |
parent | d526649ee67237a1bedad8228f1f017035ddad3f (diff) | |
download | alacritty-87e5b1aa25ea61937fa5f79668d2a46e88707c5e.tar.gz alacritty-87e5b1aa25ea61937fa5f79668d2a46e88707c5e.zip |
Add automatic scrolling during selection
This adds a new `Scheduler` which allows for staging events to be
processed at a later time.
If there is a selection active and the mouse is above or below the
window, the viewport will now scroll torwards the direction of the
mouse. The amount of lines scrolled depends on the distance of the mouse
to the boundaries used for selection scrolling.
To make it possible to scroll while in fullscreen, the selection
scrolling area includes the padding of the window and is at least 5
pixels high in case there is not enough padding present.
Diffstat (limited to 'alacritty_terminal/src/term')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 6aac05d9..33d2e14e 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -691,13 +691,24 @@ impl SizeInfo { Column(((self.width - 2. * self.padding_x) / self.cell_width) as usize) } + #[inline] + pub fn padding_right(&self) -> usize { + (self.padding_x + (self.width - 2. * self.padding_x) % self.cell_width) as usize + } + + #[inline] + pub fn padding_bottom(&self) -> usize { + (self.padding_y + (self.height - 2. * self.padding_y) % self.cell_height) as usize + } + /// Check if coordinates are inside the terminal grid. /// /// The padding is not counted as part of the grid. + #[inline] pub fn contains_point(&self, x: usize, y: usize) -> bool { - x < (self.width - self.padding_x) as usize + x < (self.width as usize - self.padding_right()) && x >= self.padding_x as usize - && y < (self.height - self.padding_y) as usize + && y < (self.height as usize - self.padding_bottom()) && y >= self.padding_y as usize } |