mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Fix issue rendering double, zero width chars
This has an issue where many diacritics will not show up at all unless they are baked into a glyph and input as a single codepoint.
This commit is contained in:
parent
ad56e3b761
commit
fc5f46ce93
1 changed files with 16 additions and 9 deletions
|
@ -1036,6 +1036,14 @@ impl ansi::Handler for Term {
|
||||||
/// A character to be displayed
|
/// A character to be displayed
|
||||||
#[inline]
|
#[inline]
|
||||||
fn input(&mut self, c: char) {
|
fn input(&mut self, c: char) {
|
||||||
|
// Number of cells the char will occupy
|
||||||
|
//
|
||||||
|
// TODO handle zero width characters (eg unicode variation selectors)
|
||||||
|
let width = match c.width() {
|
||||||
|
Some(0) | None => return,
|
||||||
|
Some(width) => width,
|
||||||
|
};
|
||||||
|
|
||||||
if self.input_needs_wrap {
|
if self.input_needs_wrap {
|
||||||
if !self.mode.contains(mode::LINE_WRAP) {
|
if !self.mode.contains(mode::LINE_WRAP) {
|
||||||
return;
|
return;
|
||||||
|
@ -1064,9 +1072,6 @@ impl ansi::Handler for Term {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Number of cells the char will occupy
|
|
||||||
let width = c.width();
|
|
||||||
|
|
||||||
// Sigh, borrowck making us check the width twice. Hopefully the
|
// Sigh, borrowck making us check the width twice. Hopefully the
|
||||||
// optimizer can fix it.
|
// optimizer can fix it.
|
||||||
{
|
{
|
||||||
|
@ -1075,24 +1080,26 @@ impl ansi::Handler for Term {
|
||||||
cell.c = self.cursor.charsets[self.active_charset].map(c);
|
cell.c = self.cursor.charsets[self.active_charset].map(c);
|
||||||
|
|
||||||
// Handle wide chars
|
// Handle wide chars
|
||||||
if let Some(2) = width {
|
if width == 2 {
|
||||||
cell.flags.insert(cell::WIDE_CHAR);
|
cell.flags.insert(cell::WIDE_CHAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set spacer cell for wide chars.
|
// Set spacer cell for wide chars.
|
||||||
if let Some(2) = width {
|
if width == 2 {
|
||||||
|
// Only set the wide char spacer when not at EOL
|
||||||
if self.cursor.point.col + 1 < self.grid.num_cols() {
|
if self.cursor.point.col + 1 < self.grid.num_cols() {
|
||||||
self.cursor.point.col += 1;
|
let mut point = self.cursor.point;
|
||||||
let spacer = &mut self.grid[&self.cursor.point];
|
point.col += 1;
|
||||||
|
let spacer = &mut self.grid[&point];
|
||||||
*spacer = self.cursor.template;
|
*spacer = self.cursor.template;
|
||||||
spacer.flags.insert(cell::WIDE_CHAR_SPACER);
|
spacer.flags.insert(cell::WIDE_CHAR_SPACER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.cursor.point.col + 1) < self.grid.num_cols() {
|
if (self.cursor.point.col + width) < self.grid.num_cols() {
|
||||||
self.cursor.point.col += 1;
|
self.cursor.point.col += width;
|
||||||
} else {
|
} else {
|
||||||
self.input_needs_wrap = true;
|
self.input_needs_wrap = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue