aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-06 04:32:24 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-06 04:32:24 -0500
commite523a38bd2665a1a487382c5042d94770e4087af (patch)
tree62c39d7cd350c57d9684c135b528df5a1b87772e
parentd94ec144dd1ca29886ebbc438882e73af6fe0ae9 (diff)
downloadvt100-rust-e523a38bd2665a1a487382c5042d94770e4087af.tar.gz
vt100-rust-e523a38bd2665a1a487382c5042d94770e4087af.zip
better (i think?) handling of weird character widths
control codes are ignored completely, and everything else defaults to 1 instead of 0
-rw-r--r--CHANGELOG.md16
-rw-r--r--src/cell.rs2
-rw-r--r--src/screen.rs7
-rw-r--r--tests/data/fixtures/ri/5.json4
-rw-r--r--tests/data/fixtures/ri/6.json4
5 files changed, 25 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69c9708..3538ba3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,27 @@
# Changelog
+## [Unreleased]
+
+### Changed
+
+* Unknown UTF-8 characters default to a width of 1, rather than 0 (except for
+ control characters, as mentioned below)
+
+### Fixed
+
+* Ignore C1 control characters rather than adding them to the cell data, since
+ they are non-printable
+
## [0.13.2] - 2021-12-05
-## Changed
+### Changed
* Delay allocation of the alternate screen until it is used (saves a bit of
memory in basic cases)
## [0.13.1] - 2021-12-04
-## Fixed
+### Fixed
* Fixed various line wrapping state issues
* Fixed cursor positioning after writing zero width characters at the end of
diff --git a/src/cell.rs b/src/cell.rs
index 7262c8d..857c9e2 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -36,7 +36,7 @@ impl Cell {
// strings in this context should always be an arbitrary character
// followed by zero or more zero-width characters, so we should only
// have to look at the first character
- self.set_wide(c.width().unwrap_or(0) > 1);
+ self.set_wide(c.width().unwrap_or(1) > 1);
self.attrs = a;
}
diff --git a/src/screen.rs b/src/screen.rs
index ae6bd2d..558c41f 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -820,7 +820,12 @@ impl Screen {
let size = self.grid().size();
let attrs = self.attrs;
- let width = c.width().unwrap_or(0).try_into().unwrap();
+ let width = c.width();
+ if width.is_none() && (c as u32) < 256 {
+ // don't even try to draw control characters
+ return;
+ }
+ let width = width.unwrap_or(1).try_into().unwrap();
// it doesn't make any sense to wrap if the last column in a row
// didn't already have contents. don't try to handle the case where a
diff --git a/tests/data/fixtures/ri/5.json b/tests/data/fixtures/ri/5.json
index e70e9fa..c4852e2 100644
--- a/tests/data/fixtures/ri/5.json
+++ b/tests/data/fixtures/ri/5.json
@@ -1,8 +1,8 @@
{
- "contents": " a\n\nb",
+ "contents": " a\n\nb",
"cells": {
"0,79": {
- "contents": "a"
+ "contents": "a"
},
"2,0": {
"contents": "b"
diff --git a/tests/data/fixtures/ri/6.json b/tests/data/fixtures/ri/6.json
index b58e830..7bf46db 100644
--- a/tests/data/fixtures/ri/6.json
+++ b/tests/data/fixtures/ri/6.json
@@ -1,8 +1,8 @@
{
- "contents": "\n a\n\nb",
+ "contents": "\n a\n\nb",
"cells": {
"1,79": {
- "contents": "a"
+ "contents": "a"
},
"3,0": {
"contents": "b"