aboutsummaryrefslogtreecommitdiffstats
path: root/tests/attr.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 /tests/attr.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 'tests/attr.rs')
-rw-r--r--tests/attr.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/attr.rs b/tests/attr.rs
index bd5aac9..a784388 100644
--- a/tests/attr.rs
+++ b/tests/attr.rs
@@ -171,6 +171,30 @@ fn colors() {
parser.screen().cell(0, 1).unwrap().bgcolor(),
vt100::Color::Idx(15)
);
+
+ // make sure bgcolor is properly preserved on cleared cells
+ parser.process(b"\x1bcfoo");
+
+ assert_eq!(
+ parser.screen().cell(0, 1).unwrap().bgcolor(),
+ vt100::Color::Default
+ );
+ parser.process(b"\x1b[1;2H\x1b[41mo\x1b[m");
+ assert_eq!(
+ parser.screen().cell(0, 1).unwrap().bgcolor(),
+ vt100::Color::Idx(1)
+ );
+
+ assert_eq!(
+ parser.screen().cell(0, 0).unwrap().bgcolor(),
+ vt100::Color::Default
+ );
+ parser.process(b"\x1b[1;1H\x1b[41m\x1b[X\x1b[m");
+ assert_eq!(
+ parser.screen().cell(0, 0).unwrap().bgcolor(),
+ vt100::Color::Idx(1)
+ );
+ assert!(!parser.screen().cell(0, 0).unwrap().has_contents());
}
#[test]
@@ -222,4 +246,24 @@ fn attrs() {
assert!(parser.screen().cell(0, 3).unwrap().italic());
assert!(parser.screen().cell(0, 3).unwrap().underline());
assert!(parser.screen().cell(0, 3).unwrap().inverse());
+
+ // alacritty renders underline and inverse status for empty cells, so make
+ // sure we reflect that here (so that we generate diffs correctly and
+ // such). unclear who is right here - other terminals don't do this, but
+ // terminals do generally render bgcolor for empty cells, which feels
+ // similar.
+ parser.process(b"\x1bcfoo");
+
+ assert!(!parser.screen().cell(0, 1).unwrap().underline());
+ assert!(!parser.screen().cell(0, 1).unwrap().inverse());
+ parser.process(b"\x1b[1;2H\x1b[4;7mo\x1b[m");
+ assert!(parser.screen().cell(0, 1).unwrap().underline());
+ assert!(parser.screen().cell(0, 1).unwrap().inverse());
+
+ assert!(!parser.screen().cell(0, 0).unwrap().underline());
+ assert!(!parser.screen().cell(0, 0).unwrap().inverse());
+ parser.process(b"\x1b[1;1H\x1b[4;7m\x1b[X\x1b[m");
+ assert!(parser.screen().cell(0, 0).unwrap().underline());
+ assert!(parser.screen().cell(0, 0).unwrap().inverse());
+ assert!(!parser.screen().cell(0, 0).unwrap().has_contents());
}