aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-20 02:24:46 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-20 02:24:46 -0500
commitdd42df358df7889a42fc23b07140fa99c6249ae7 (patch)
tree41bcf041c3d053131b9ad6f32f134ede1a4fb2bc
parent49f6a8ba69764e99d6674147cd716e32254dfc30 (diff)
downloadvt100-rust-dd42df358df7889a42fc23b07140fa99c6249ae7.tar.gz
vt100-rust-dd42df358df7889a42fc23b07140fa99c6249ae7.zip
more cursor_state_formatted fixes
-rw-r--r--src/grid.rs23
-rw-r--r--tests/data/fixtures/attrs.in1
-rw-r--r--tests/data/fixtures/attrs/11.json13
-rw-r--r--tests/data/fixtures/attrs/11.typescript1
4 files changed, 38 insertions, 0 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 970909c..263e846 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -322,17 +322,40 @@ impl Grid {
}
let cell = self.visible_cell(pos).unwrap();
if cell.has_contents() {
+ // not sure why this is triggering here, seems like a
+ // clippy bug
+ #[allow(clippy::option_if_let_else)]
if let Some(prev_pos) = prev_pos {
if prev_pos.row != i
|| prev_pos.col < self.size.cols
{
crate::term::MoveFromTo::new(prev_pos, pos)
.write_buf(contents);
+ cell.attrs().write_escape_code_diff(
+ contents,
+ &prev_attrs.unwrap_or_default(),
+ );
contents.extend(cell.contents().as_bytes());
+ if let Some(prev_attrs) = prev_attrs {
+ prev_attrs.write_escape_code_diff(
+ contents,
+ cell.attrs(),
+ );
+ }
}
} else {
crate::term::MoveTo::new(pos).write_buf(contents);
+ cell.attrs().write_escape_code_diff(
+ contents,
+ &prev_attrs.unwrap_or_default(),
+ );
contents.extend(cell.contents().as_bytes());
+ if let Some(prev_attrs) = prev_attrs {
+ prev_attrs.write_escape_code_diff(
+ contents,
+ cell.attrs(),
+ );
+ }
}
contents.extend(
"\n".repeat((orig_row - i) as usize).as_bytes(),
diff --git a/tests/data/fixtures/attrs.in b/tests/data/fixtures/attrs.in
index 4fe65cb..9058d9a 100644
--- a/tests/data/fixtures/attrs.in
+++ b/tests/data/fixtures/attrs.in
@@ -8,3 +8,4 @@ f\x1b[1mo\x1b[3mo\x1b[4mo\x1b[7mo
\x1b[1;2H\x1b[4;7mo\x1b[m
\x1b[1;1H\x1b[4;7m\x1b[X\x1b[m
\x1bc\x1b[1;79H\x1b[31mab
+\x1bc\x1b[1;80H\x1b[41ma\n
diff --git a/tests/data/fixtures/attrs/11.json b/tests/data/fixtures/attrs/11.json
new file mode 100644
index 0000000..915ae63
--- /dev/null
+++ b/tests/data/fixtures/attrs/11.json
@@ -0,0 +1,13 @@
+{
+ "contents": " a",
+ "cells": {
+ "0,79": {
+ "contents": "a",
+ "bgcolor": "1"
+ }
+ },
+ "cursor_position": [
+ 1,
+ 80
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/attrs/11.typescript b/tests/data/fixtures/attrs/11.typescript
new file mode 100644
index 0000000..20008d6
--- /dev/null
+++ b/tests/data/fixtures/attrs/11.typescript
@@ -0,0 +1 @@
+ca