diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-06 02:06:49 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-06 02:06:49 -0500 |
commit | 7e7f4a10930498c2d576c7103054408a0915370e (patch) | |
tree | bfbc996afb8ffdb2e8a050a7d9a8897c96d52c39 /tests | |
parent | cd03c4f836baeae66e4a55407266f35f6ebf43a1 (diff) | |
download | vt100-rust-7e7f4a10930498c2d576c7103054408a0915370e.tar.gz vt100-rust-7e7f4a10930498c2d576c7103054408a0915370e.zip |
contents_formatted and contents_diff should also restore the cursor
since the cursor is a visible part of the terminal
Diffstat (limited to 'tests')
-rw-r--r-- | tests/escape.rs | 6 | ||||
-rw-r--r-- | tests/window_contents.rs | 16 |
2 files changed, 14 insertions, 8 deletions
diff --git a/tests/escape.rs b/tests/escape.rs index 01ac574..fcd4e6b 100644 --- a/tests/escape.rs +++ b/tests/escape.rs @@ -64,7 +64,7 @@ fn ris() { assert_eq!(parser.screen().contents(), "foo"); assert_eq!( parser.screen().contents_formatted(), - b"f\x1b[31;47;1;3;4moo" + b"\x1b[?25lf\x1b[31;47;1;3;4moo\x1b[21;21H" ); assert_eq!(parser.screen().title(), "window title"); @@ -172,13 +172,13 @@ fn decsc() { assert_eq!(parser.screen().cursor_position(), (0, 3)); assert_eq!( parser.screen().contents_formatted(), - b"\x1b[32mbar\r\n\r\n\r\n\r\n\x1b[31mfoo" + b"\x1b[32mbar\r\n\r\n\r\n\r\n\x1b[31mfoo\x1b[1;4H" ); parser.process(b"\x1b8\x1b[Hz"); assert_eq!(parser.screen().cursor_position(), (4, 1)); assert_eq!( parser.screen().contents_formatted(), - b"\x1b[32mbar\r\n\r\n\r\n\r\n\x1b[31mzoo" + b"\x1b[32mbar\r\n\r\n\r\n\r\n\x1b[31mzoo\x1b[5;2H" ); } diff --git a/tests/window_contents.rs b/tests/window_contents.rs index 235c05e..ed15517 100644 --- a/tests/window_contents.rs +++ b/tests/window_contents.rs @@ -22,7 +22,7 @@ fn formatted() { assert!(!parser.screen().cell(0, 5).unwrap().bold()); assert_eq!( parser.screen().contents_formatted(), - b"foo\x1b[33;1;7mb\x1b[mar" + b"foo\x1b[33;1;7mb\x1b[mar\x1b[1;5H" ); parser.process(b"\x1b[1;5H\x1b[22;42ma"); @@ -33,7 +33,7 @@ fn formatted() { assert!(!parser.screen().cell(0, 5).unwrap().bold()); assert_eq!( parser.screen().contents_formatted(), - b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[mr" + b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[mr\x1b[1;6H" ); parser.process(b"\x1b[1;6H\x1b[35mr\r\nquux"); @@ -64,7 +64,7 @@ fn empty_cells() { assert_eq!(parser.screen().contents(), "foo bar"); assert_eq!( parser.screen().contents_formatted(), - b"\x1b[31mfoo\x1b[m\x1b[C\x1b[C\x1b[32m bar" + b"\x1b[31mfoo\x1b[m\x1b[C\x1b[C\x1b[32m bar\x1b[1;4H" ); } @@ -349,7 +349,7 @@ fn diff() { let screen5 = parser.screen().clone(); assert_eq!( screen5.contents_diff(&screen4), - b"\x1b[m\x1b[1;8H\x1b[X\x1b[C" + b"\x1b[m\x1b[1;8H\x1b[X\x1b[C\x1b[1;8H" ); compare_diff( &screen4, @@ -385,7 +385,6 @@ fn diff_crawl(i: usize) { let mut all_frames: Vec<u8> = vec![]; for two_screens in screens.windows(2) { - eprintln!("loop"); match two_screens { [(prev_frame, prev_screen), (_, screen)] => { all_frames.extend(prev_frame); @@ -419,6 +418,11 @@ fn compare_diff( let mut parser = vt100::Parser::new(rows, cols); parser.process(&contents); compare_cells(parser.screen(), &prev_screen); + assert_eq!(parser.screen().hide_cursor(), prev_screen.hide_cursor()); + assert_eq!( + parser.screen().cursor_position(), + prev_screen.cursor_position() + ); assert_eq!( parser.screen().contents_formatted(), prev_screen.contents_formatted() @@ -440,6 +444,8 @@ fn compare_diff( .unwrap(); } compare_cells(parser.screen(), &screen); + assert_eq!(parser.screen().hide_cursor(), screen.hide_cursor()); + assert_eq!(parser.screen().cursor_position(), screen.cursor_position()); assert_eq!( parser.screen().contents_formatted(), screen.contents_formatted() |