aboutsummaryrefslogtreecommitdiffstats
path: root/src/row.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-11 11:48:38 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-11 11:48:38 -0500
commit346c7404ecc51556f86efd3222c86148101c89a0 (patch)
treed8c015228f7e08eef31a6edfb60857eb54d76d56 /src/row.rs
parentede7fdaf5ce7868b42d19d5f5916935a46d13dd6 (diff)
downloadvt100-rust-346c7404ecc51556f86efd3222c86148101c89a0.tar.gz
vt100-rust-346c7404ecc51556f86efd3222c86148101c89a0.zip
preserve all text attributes on cleared cells
some terminals require it (alacritty wants to render underline and inverse state of cleared cells, for instance, so we have to be sure that the diff algorithm will properly reset the cursor attributes before clearing cells)
Diffstat (limited to 'src/row.rs')
-rw-r--r--src/row.rs32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/row.rs b/src/row.rs
index 26e117b..f521467 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -19,9 +19,9 @@ impl Row {
self.cells.len().try_into().unwrap()
}
- pub fn clear(&mut self, bgcolor: crate::attrs::Color) {
+ pub fn clear(&mut self, attrs: crate::attrs::Attrs) {
for cell in &mut self.cells {
- cell.clear(bgcolor);
+ cell.clear(attrs);
}
self.wrapped = false;
}
@@ -147,21 +147,15 @@ impl Row {
}
let attrs = cell.attrs();
+ if &prev_attrs != attrs {
+ attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *attrs;
+ }
if cell.has_contents() {
- if &prev_attrs != attrs {
- attrs.write_escape_code_diff(contents, &prev_attrs);
- prev_attrs = *attrs;
- }
-
contents.extend(cell.contents().as_bytes());
prev_pos.col += if cell.is_wide() { 2 } else { 1 };
} else {
- if prev_attrs.bgcolor != attrs.bgcolor {
- attrs.write_escape_code_diff(contents, &prev_attrs);
- prev_attrs = *attrs;
- }
-
crate::term::EraseChar::default().write_buf(contents);
}
}
@@ -223,21 +217,15 @@ impl Row {
}
let attrs = cell.attrs();
+ if &prev_attrs != attrs {
+ attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *attrs;
+ }
if cell.has_contents() {
- if &prev_attrs != attrs {
- attrs.write_escape_code_diff(contents, &prev_attrs);
- prev_attrs = *attrs;
- }
-
contents.extend(cell.contents().as_bytes());
prev_pos.col += if cell.is_wide() { 2 } else { 1 };
} else {
- if prev_attrs.bgcolor != attrs.bgcolor {
- attrs.write_escape_code_diff(contents, &prev_attrs);
- prev_attrs = *attrs;
- }
-
crate::term::EraseChar::default().write_buf(contents);
}
}