aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-12-06 23:27:51 -0500
committerJesse Luehrs <doy@tozt.net>2019-12-06 23:28:04 -0500
commite6b26a5f6ac8f79f0fd26da4fe285fa3c33da21c (patch)
tree8d6b1fbffec6b7b0397f908e7b02fa78dacf62fc
parente13049c91c036354b311bc529b0b258aa4b61952 (diff)
downloadvt100-rust-e6b26a5f6ac8f79f0fd26da4fe285fa3c33da21c.tar.gz
vt100-rust-e6b26a5f6ac8f79f0fd26da4fe285fa3c33da21c.zip
more line wrapping fixes
-rw-r--r--src/grid.rs1
-rw-r--r--src/row.rs32
-rw-r--r--tests/data/fixtures/wrap.in5
-rw-r--r--tests/data/fixtures/wrap/24.json21
-rw-r--r--tests/data/fixtures/wrap/24.typescript1
-rw-r--r--tests/data/fixtures/wrap/25.json18
-rw-r--r--tests/data/fixtures/wrap/25.typescript1
-rw-r--r--tests/data/fixtures/wrap/26.json21
-rw-r--r--tests/data/fixtures/wrap/26.typescript1
-rw-r--r--tests/data/fixtures/wrap/27.json18
-rw-r--r--tests/data/fixtures/wrap/27.typescript1
-rw-r--r--tests/data/fixtures/wrap/28.json12
-rw-r--r--tests/data/fixtures/wrap/28.typescript1
13 files changed, 132 insertions, 1 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 07bcd6f..b12216c 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -428,7 +428,6 @@ impl Grid {
let size = self.size;
let pos = self.pos;
let row = self.current_row_mut();
- row.wrap(false);
for col in pos.col..size.cols {
row.erase(col as usize, attrs);
}
diff --git a/src/row.rs b/src/row.rs
index b8da987..090619d 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -40,24 +40,31 @@ impl Row {
pub fn insert(&mut self, i: usize, cell: crate::cell::Cell) {
self.cells.insert(i, cell);
+ self.wrapped = false;
}
pub fn remove(&mut self, i: usize) {
self.clear_wide(i.try_into().unwrap());
self.cells.remove(i);
+ self.wrapped = false;
}
pub fn erase(&mut self, i: usize, attrs: crate::attrs::Attrs) {
self.clear_wide(i.try_into().unwrap());
self.cells.get_mut(i).unwrap().clear(attrs);
+ if i == self.cols() as usize - 1 {
+ self.wrapped = false;
+ }
}
pub fn truncate(&mut self, len: usize) {
self.cells.truncate(len);
+ self.wrapped = false;
}
pub fn resize(&mut self, len: usize, cell: crate::cell::Cell) {
self.cells.resize(len, cell);
+ self.wrapped = false;
}
pub fn wrap(&mut self, wrap: bool) {
@@ -381,6 +388,31 @@ impl Row {
crate::term::ClearRowForward::default().write_buf(contents);
}
+ if prev.wrapped && !self.wrapped {
+ let end_pos = if self
+ .get(self.cols() - 1)
+ .unwrap()
+ .is_wide_continuation()
+ {
+ crate::grid::Pos {
+ row,
+ col: self.cols() - 2,
+ }
+ } else {
+ crate::grid::Pos {
+ row,
+ col: self.cols() - 1,
+ }
+ };
+ crate::term::MoveFromTo::new(prev_pos, end_pos)
+ .write_buf(contents);
+ prev_pos = end_pos;
+ crate::term::EraseChar::new(1).write_buf(contents);
+ let end_cell = self.get(end_pos.col).unwrap();
+ contents.extend(end_cell.contents().as_bytes());
+ prev_pos.col += if end_cell.is_wide() { 2 } else { 1 };
+ }
+
(prev_pos, prev_attrs)
}
}
diff --git a/tests/data/fixtures/wrap.in b/tests/data/fixtures/wrap.in
index 4b1bea2..f079817 100644
--- a/tests/data/fixtures/wrap.in
+++ b/tests/data/fixtures/wrap.in
@@ -21,3 +21,8 @@ a
\x1b[H\x1b[J
ネa\x1b[L\x1b[1;79Hbcd
+\x1bc\x1b[1;79Habcd
+\x1b[1;80H\x1b[X
+\x1bc\x1b[1;79Habcd
+\x1b[H\x1b[@
+\x1bc\x1b[1;80Haa\x1b[T\x1b[@
diff --git a/tests/data/fixtures/wrap/24.json b/tests/data/fixtures/wrap/24.json
new file mode 100644
index 0000000..a4d8d68
--- /dev/null
+++ b/tests/data/fixtures/wrap/24.json
@@ -0,0 +1,21 @@
+{
+ "contents": " abcd",
+ "cells": {
+ "0,78": {
+ "contents": "a"
+ },
+ "0,79": {
+ "contents": "b"
+ },
+ "1,0": {
+ "contents": "c"
+ },
+ "1,1": {
+ "contents": "d"
+ }
+ },
+ "cursor_position": [
+ 1,
+ 2
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/24.typescript b/tests/data/fixtures/wrap/24.typescript
new file mode 100644
index 0000000..9e7bc48
--- /dev/null
+++ b/tests/data/fixtures/wrap/24.typescript
@@ -0,0 +1 @@
+cabcd \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/25.json b/tests/data/fixtures/wrap/25.json
new file mode 100644
index 0000000..3f7250b
--- /dev/null
+++ b/tests/data/fixtures/wrap/25.json
@@ -0,0 +1,18 @@
+{
+ "contents": " a\ncd",
+ "cells": {
+ "0,78": {
+ "contents": "a"
+ },
+ "1,0": {
+ "contents": "c"
+ },
+ "1,1": {
+ "contents": "d"
+ }
+ },
+ "cursor_position": [
+ 0,
+ 79
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/25.typescript b/tests/data/fixtures/wrap/25.typescript
new file mode 100644
index 0000000..582fae1
--- /dev/null
+++ b/tests/data/fixtures/wrap/25.typescript
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/26.json b/tests/data/fixtures/wrap/26.json
new file mode 100644
index 0000000..a4d8d68
--- /dev/null
+++ b/tests/data/fixtures/wrap/26.json
@@ -0,0 +1,21 @@
+{
+ "contents": " abcd",
+ "cells": {
+ "0,78": {
+ "contents": "a"
+ },
+ "0,79": {
+ "contents": "b"
+ },
+ "1,0": {
+ "contents": "c"
+ },
+ "1,1": {
+ "contents": "d"
+ }
+ },
+ "cursor_position": [
+ 1,
+ 2
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/26.typescript b/tests/data/fixtures/wrap/26.typescript
new file mode 100644
index 0000000..9e7bc48
--- /dev/null
+++ b/tests/data/fixtures/wrap/26.typescript
@@ -0,0 +1 @@
+cabcd \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/27.json b/tests/data/fixtures/wrap/27.json
new file mode 100644
index 0000000..ac07fa2
--- /dev/null
+++ b/tests/data/fixtures/wrap/27.json
@@ -0,0 +1,18 @@
+{
+ "contents": " a\ncd",
+ "cells": {
+ "0,79": {
+ "contents": "a"
+ },
+ "1,0": {
+ "contents": "c"
+ },
+ "1,1": {
+ "contents": "d"
+ }
+ },
+ "cursor_position": [
+ 0,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/27.typescript b/tests/data/fixtures/wrap/27.typescript
new file mode 100644
index 0000000..f6122a6
--- /dev/null
+++ b/tests/data/fixtures/wrap/27.typescript
@@ -0,0 +1 @@
+[@ \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/28.json b/tests/data/fixtures/wrap/28.json
new file mode 100644
index 0000000..a505566
--- /dev/null
+++ b/tests/data/fixtures/wrap/28.json
@@ -0,0 +1,12 @@
+{
+ "contents": "\n\na",
+ "cells": {
+ "2,0": {
+ "contents": "a"
+ }
+ },
+ "cursor_position": [
+ 1,
+ 1
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/28.typescript b/tests/data/fixtures/wrap/28.typescript
new file mode 100644
index 0000000..f760735
--- /dev/null
+++ b/tests/data/fixtures/wrap/28.typescript
@@ -0,0 +1 @@
+caa[@ \ No newline at end of file