diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-05 10:49:18 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-05 10:51:02 -0500 |
commit | b7359e5513e6102c293d51f0fbdabfccc3fe6450 (patch) | |
tree | af97d52da22a9061c7a7f26ebdbc4e01a3bc8fda | |
parent | 665238f5318bee40f254fe43aa158e61bdd25392 (diff) | |
download | vt100-rust-b7359e5513e6102c293d51f0fbdabfccc3fe6450.tar.gz vt100-rust-b7359e5513e6102c293d51f0fbdabfccc3fe6450.zip |
preserve the state of empty cells in contents_formatted
-rw-r--r-- | src/row.rs | 2 | ||||
-rw-r--r-- | tests/window_contents.rs | 12 |
2 files changed, 13 insertions, 1 deletions
@@ -112,7 +112,7 @@ impl Row { let cell_contents = cell.contents(); let cell_contents = if cell_contents == "" { - " " + "\x1b[C" } else { cell_contents }; diff --git a/tests/window_contents.rs b/tests/window_contents.rs index 5fe0cda..d79f75a 100644 --- a/tests/window_contents.rs +++ b/tests/window_contents.rs @@ -54,6 +54,18 @@ fn formatted() { assert_eq!(parser.screen().contents_formatted(0, 0 ,23, 79), &b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\n\x1b[45mq\x1b[38;2;123;213;231mu\x1b[38;5;254mu\x1b[39mx"[..]); } +#[test] +fn empty_cells() { + let mut parser = vt100::Parser::new(24, 80); + parser.process(b"\x1b[5C\x1b[32m bar\x1b[H\x1b[31mfoo"); + compare_formatted(&parser); + assert_eq!(parser.screen().contents(0, 0, 23, 79), "foo bar"); + assert_eq!( + parser.screen().contents_formatted(0, 0, 23, 79), + b"\x1b[31mfoo\x1b[m\x1b[C\x1b[C\x1b[32m bar" + ); +} + fn compare_formatted(parser: &vt100::Parser) { let (rows, cols) = parser.screen().size(); let contents = |