diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-01-09 23:06:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 23:06:41 +0000 |
commit | 3fb631b91caec163707858bd1d435015e6e6cb18 (patch) | |
tree | cfc575f224622b7c83a21281c2e23a7f8af83364 /alacritty_terminal/src/index.rs | |
parent | 5651c3f7114dff611e616865ad02e682779979d9 (diff) | |
download | alacritty-3fb631b91caec163707858bd1d435015e6e6cb18.tar.gz alacritty-3fb631b91caec163707858bd1d435015e6e6cb18.zip |
Fix cut off full width glyphs in last column
This resolves the issue with full width glyphs getting rendered in the
last column. Since they need at least two glyphs, it is not possible to
properly render them in the last column.
Instead of rendering half of the glyph in the last column, with the
other half cut off, an additional spacer is now inserted before the wide
glyph. This means that the specific glyph in question is then three
cells wide.
Fixes #2385.
Diffstat (limited to 'alacritty_terminal/src/index.rs')
-rw-r--r-- | alacritty_terminal/src/index.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/alacritty_terminal/src/index.rs b/alacritty_terminal/src/index.rs index d40245f3..fb21baa0 100644 --- a/alacritty_terminal/src/index.rs +++ b/alacritty_terminal/src/index.rs @@ -44,24 +44,32 @@ impl<L> Point<L> { #[inline] #[must_use = "this returns the result of the operation, without modifying the original"] - pub fn sub(mut self, num_cols: usize, length: usize) -> Point<L> + pub fn sub(mut self, num_cols: usize, length: usize, absolute_indexing: bool) -> Point<L> where - L: Copy + Sub<usize, Output = L>, + L: Copy + Add<usize, Output = L> + Sub<usize, Output = L>, { let line_changes = f32::ceil(length.saturating_sub(self.col.0) as f32 / num_cols as f32); - self.line = self.line - line_changes as usize; + if absolute_indexing { + self.line = self.line + line_changes as usize; + } else { + self.line = self.line - line_changes as usize; + } self.col = Column((num_cols + self.col.0 - length % num_cols) % num_cols); self } #[inline] #[must_use = "this returns the result of the operation, without modifying the original"] - pub fn add(mut self, num_cols: usize, length: usize) -> Point<L> + pub fn add(mut self, num_cols: usize, length: usize, absolute_indexing: bool) -> Point<L> where - L: Copy + Add<usize, Output = L>, + L: Copy + Add<usize, Output = L> + Sub<usize, Output = L>, { - let line_changes = length.saturating_sub(self.col.0) / num_cols; - self.line = self.line + line_changes; + let line_changes = (length + self.col.0) / num_cols; + if absolute_indexing { + self.line = self.line - line_changes; + } else { + self.line = self.line + line_changes; + } self.col = Column((self.col.0 + length) % num_cols); self } |