aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-29 04:00:21 -0500
committerJesse Luehrs <doy@tozt.net>2019-12-05 12:54:34 -0500
commitdc62fd174f6c5887e958b9b9bc8305ddd7c428a8 (patch)
tree8380adc7c1ebc00461d37c21087281139ce1e542
parenta9b6d72b24fffa55093201c520075d500712a3ff (diff)
downloadvt100-rust-dc62fd174f6c5887e958b9b9bc8305ddd7c428a8.tar.gz
vt100-rust-dc62fd174f6c5887e958b9b9bc8305ddd7c428a8.zip
fix applying combining characters to wide characters
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/screen.rs23
-rw-r--r--tests/text.rs4
3 files changed, 25 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea84420..969385a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
### Fixed
* Fix a couple more end-of-line/wrapping bugs.
+* Fix applying combining characters to wide characters.
## [0.7.0] - 2019-11-23
diff --git a/src/screen.rs b/src/screen.rs
index d350f6f..f8844aa 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -584,6 +584,7 @@ impl Screen {
}
impl Screen {
+ #[allow(clippy::too_many_lines)]
fn text(&mut self, c: char) {
let pos = self.grid().pos();
let size = self.grid().size();
@@ -667,12 +668,20 @@ impl Screen {
if width == 0 {
if pos.col > 0 {
- let prev_cell = self
+ let mut prev_cell = self
.drawing_cell_mut(crate::grid::Pos {
row: pos.row,
col: pos.col - 1,
})
.unwrap();
+ if prev_cell.is_wide_continuation() {
+ prev_cell = self
+ .drawing_cell_mut(crate::grid::Pos {
+ row: pos.row,
+ col: pos.col - 2,
+ })
+ .unwrap();
+ }
prev_cell.append(c);
} else if pos.row > 0 {
let prev_row = self
@@ -682,12 +691,20 @@ impl Screen {
})
.unwrap();
if prev_row.wrapped() {
- let prev_cell = self
+ let mut prev_cell = self
.drawing_cell_mut(crate::grid::Pos {
row: pos.row - 1,
- col: self.grid().size().cols - 1,
+ col: size.cols - 1,
})
.unwrap();
+ if prev_cell.is_wide_continuation() {
+ prev_cell = self
+ .drawing_cell_mut(crate::grid::Pos {
+ row: pos.row - 1,
+ col: size.cols - 2,
+ })
+ .unwrap();
+ }
prev_cell.append(c);
}
}
diff --git a/tests/text.rs b/tests/text.rs
index 5f5dbef..51ee297 100644
--- a/tests/text.rs
+++ b/tests/text.rs
@@ -163,6 +163,10 @@ fn combining() {
parser.process("\u{0301}".as_bytes());
assert_eq!(parser.screen().cursor_position(), (1, 0));
assert_eq!(parser.screen().contents(), format!("{}á", "a".repeat(79)));
+
+ parser.process("\x1b[H\x1b[Ja\u{0301}".as_bytes());
+ assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), "a\u{0301}");
+ assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), "");
}
#[test]