aboutsummaryrefslogtreecommitdiffstats
path: root/tests/window_contents.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-08 04:13:08 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-08 06:46:33 -0500
commit76aeb85e99e088151c867d86858705bf38c345de (patch)
treeab4a9375980026885c707f4af71b3b49a5f1bf17 /tests/window_contents.rs
parentf5e9c72622f2fceeb083f5df872c77dd1d39cffb (diff)
downloadvt100-rust-76aeb85e99e088151c867d86858705bf38c345de.tar.gz
vt100-rust-76aeb85e99e088151c867d86858705bf38c345de.zip
fix wide character handling in contents_formatted and contents_diff
Diffstat (limited to 'tests/window_contents.rs')
-rw-r--r--tests/window_contents.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/window_contents.rs b/tests/window_contents.rs
index 9b49421..29b76f8 100644
--- a/tests/window_contents.rs
+++ b/tests/window_contents.rs
@@ -76,6 +76,44 @@ fn empty_cells() {
}
#[test]
+fn cursor_positioning() {
+ let mut parser = vt100::Parser::new(24, 80);
+ let screen1 = parser.screen().clone();
+
+ parser.process(b":\x1b[K");
+ let screen2 = parser.screen().clone();
+ assert_eq!(parser.screen().cursor_position(), (0, 1));
+ assert_eq!(
+ parser.screen().contents_formatted(),
+ b"\x1b[?25h\x1b[H\x1b[J:"
+ );
+ assert_eq!(parser.screen().contents_diff(&screen1), b"\x1b[m\x1b[1;1H:");
+
+ parser.process(b"a");
+ let screen3 = parser.screen().clone();
+ assert_eq!(parser.screen().cursor_position(), (0, 2));
+ assert_eq!(
+ parser.screen().contents_formatted(),
+ b"\x1b[?25h\x1b[H\x1b[J:a"
+ );
+ assert_eq!(
+ parser.screen().contents_diff(&screen2),
+ b"\x1b[m\x1b[1;1H\x1b[1Ca"
+ );
+
+ parser.process(b"\x1b[1;2H\x1b[K");
+ assert_eq!(parser.screen().cursor_position(), (0, 1));
+ assert_eq!(
+ parser.screen().contents_formatted(),
+ b"\x1b[?25h\x1b[H\x1b[J:"
+ );
+ assert_eq!(
+ parser.screen().contents_diff(&screen3),
+ b"\x1b[m\x1b[1;1H\x1b[1C\x1b[X\x1b[C\x1b[1;2H"
+ );
+}
+
+#[test]
fn rows() {
let mut parser = vt100::Parser::new(24, 80);
let screen1 = parser.screen().clone();