aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/term/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty_terminal/src/term/mod.rs')
-rw-r--r--alacritty_terminal/src/term/mod.rs15
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
}