aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-20 13:16:05 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-20 13:16:05 -0500
commitf5d5f602dba0229335ec44b817c7822c73171e29 (patch)
tree0f8205ba85d5fee7a5654346106b33a5778fd7b6
parentdc5efa534b80264f2e5a83ab60056c0834925aea (diff)
downloadvt100-rust-f5d5f602dba0229335ec44b817c7822c73171e29.tar.gz
vt100-rust-f5d5f602dba0229335ec44b817c7822c73171e29.zip
combining characters should also trigger a cursor wrap
this seems pretty weird, but it is what all other terminals i can find do, so
-rw-r--r--src/screen.rs11
-rw-r--r--tests/text.rs2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/screen.rs b/src/screen.rs
index f28fb90..ec4d204 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -591,7 +591,16 @@ impl Screen {
let width = c.width().unwrap_or(0).try_into().unwrap();
let attrs = self.attrs;
- self.grid_mut().col_wrap(width);
+ // zero width characters still cause the cursor to wrap - this doesn't
+ // affect which cell they go into (the "previous cell" for both (row,
+ // max_col + 1) and (row + 1, 0) is (row, max_col)), but does affect
+ // further movement afterwards - writing an `a` at (row, max_col)
+ // followed by a crlf puts the cursor at (row + 1, 0), but writing a
+ // `à` (specifically `a` followed by a combining grave accent - the
+ // normalized U+00E0 "latin small letter a with grave" behaves the
+ // same as `a`) at (row, max_col) followed by a crlf puts the cursor
+ // at (row + 2, 0)
+ self.grid_mut().col_wrap(if width == 0 { 1 } else { width });
if width == 0 {
if pos.col > 0 {
diff --git a/tests/text.rs b/tests/text.rs
index a962741..81201a1 100644
--- a/tests/text.rs
+++ b/tests/text.rs
@@ -160,7 +160,7 @@ fn combining() {
assert_eq!(parser.screen().contents(), "a".repeat(80));
parser.process("\u{0301}".as_bytes());
- assert_eq!(parser.screen().cursor_position(), (0, 80));
+ assert_eq!(parser.screen().cursor_position(), (1, 0));
assert_eq!(parser.screen().contents(), format!("{}á", "a".repeat(79)));
}