Fix control character width measurement
This commit is contained in:
parent
94052c5a65
commit
8556fd8176
2 changed files with 12 additions and 0 deletions
|
|
@ -13,6 +13,9 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Width measurements of ASCII control characters
|
||||||
|
|
||||||
## v0.2.2 - 2024-01-14
|
## v0.2.2 - 2024-01-14
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,15 @@ impl WidthDb {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
for grapheme in self.requested.drain() {
|
for grapheme in self.requested.drain() {
|
||||||
|
if grapheme.chars().any(|c|c.is_ascii_control()){
|
||||||
|
// ASCII control characters like the escape character or the
|
||||||
|
// bell character tend to be interpreted specially by terminals.
|
||||||
|
// This may break width measurements. To avoid this, we just
|
||||||
|
// assign each control character a with of 0.
|
||||||
|
self.known.insert(grapheme, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
out.queue(Clear(ClearType::All))?
|
out.queue(Clear(ClearType::All))?
|
||||||
.queue(MoveTo(0, 0))?
|
.queue(MoveTo(0, 0))?
|
||||||
.queue(Print(&grapheme))?;
|
.queue(Print(&grapheme))?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue