diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-05 12:53:25 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-05 13:26:49 -0500 |
commit | 2e7f1686d719497d9b2d2d2c8ffba20e6c8214bd (patch) | |
tree | 8f31cb37faaec73bdf4a5253f0c34bceb3cc6d6f /tests/processing.rs | |
parent | e12f9d9ee4e6b902436d0282e4a1e47ed7d54d6c (diff) | |
download | vt100-rust-2e7f1686d719497d9b2d2d2c8ffba20e6c8214bd.tar.gz vt100-rust-2e7f1686d719497d9b2d2d2c8ffba20e6c8214bd.zip |
adjust the way window contents are reported
contents and contents_formatted now only allow getting the entire
terminal contents, and for any other uses we now provide rows and
rows_formatted.
the reasoning here is that it wasn't particularly useful to return
newline (or crlf) separated lines when not drawing the full terminal,
since it's not like you can send those to the terminal in any meaningful
way anyway (like, if you wanted to draw a subset of the terminal state,
you'll almost certainly need to be doing explicit positioning on your
own, since crlf is only actually correct if you're drawing the screen
subset in the upper left hand corner of the screen). with this, you can
draw each (subset of a) line individually, and reposition the cursor in
whatever way makes sense in between drawing the lines.
Diffstat (limited to 'tests/processing.rs')
-rw-r--r-- | tests/processing.rs | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/tests/processing.rs b/tests/processing.rs index 282ab65..4fdb8cb 100644 --- a/tests/processing.rs +++ b/tests/processing.rs @@ -3,41 +3,41 @@ #[test] fn split_escape_sequences() { let mut parser = vt100::Parser::new(24, 80); - let contents = parser.screen().contents(0, 0, 23, 79); + let contents = parser.screen().contents(); parser.process(b"abc"); - assert_ne!(parser.screen().contents(0, 0, 23, 79), contents); - let contents = parser.screen().contents(0, 0, 23, 79); + assert_ne!(parser.screen().contents(), contents); + let contents = parser.screen().contents(); parser.process(b"abc\x1b[12;24Hdef"); - assert_ne!(parser.screen().contents(0, 0, 23, 79), contents); - let contents = parser.screen().contents(0, 0, 23, 79); + assert_ne!(parser.screen().contents(), contents); + let contents = parser.screen().contents(); assert!(contents.contains("abc")); assert!(contents.contains("def")); assert_eq!(parser.screen().cursor_position(), (11, 26)); parser.process(b"\x1b"); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"["); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"1"); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"2"); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b";"); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"2"); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"4"); assert_eq!(parser.screen().cursor_position(), (11, 26)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"H"); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); assert_eq!( parser.screen().mouse_protocol_mode(), @@ -49,56 +49,56 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"["); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"?"); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"1"); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"0"); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"0"); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"0"); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::None ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"h"); assert_eq!( parser.screen().mouse_protocol_mode(), vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); assert_eq!(parser.screen().title(), ""); parser.process(b"\x1b"); @@ -108,7 +108,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"]"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -116,7 +116,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"0"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -124,7 +124,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b";"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -132,7 +132,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"a"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -140,7 +140,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b" "); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -148,7 +148,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"'"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -156,7 +156,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"["); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -164,7 +164,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"]"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -172,7 +172,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"_"); assert_eq!(parser.screen().title(), ""); assert_eq!( @@ -180,7 +180,7 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\x07"); assert_eq!(parser.screen().title(), "a '[]_"); assert_eq!( @@ -188,37 +188,37 @@ fn split_escape_sequences() { vt100::MouseProtocolMode::PressRelease ); assert_eq!(parser.screen().cursor_position(), (11, 23)); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); } #[test] fn split_utf8() { let mut parser = vt100::Parser::new(24, 80); - let contents = parser.screen().contents(0, 0, 23, 79); + let contents = parser.screen().contents(); parser.process(b"a"); - assert_ne!(parser.screen().contents(0, 0, 23, 79), contents); - let contents = parser.screen().contents(0, 0, 23, 79); + assert_ne!(parser.screen().contents(), contents); + let contents = parser.screen().contents(); parser.process(b"\xc3"); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\xa1"); - assert_ne!(parser.screen().contents(0, 0, 23, 79), contents); - let contents = parser.screen().contents(0, 0, 23, 79); + assert_ne!(parser.screen().contents(), contents); + let contents = parser.screen().contents(); parser.process(b"\xe3"); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\x82"); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\xad"); - assert_ne!(parser.screen().contents(0, 0, 23, 79), contents); - let contents = parser.screen().contents(0, 0, 23, 79); + assert_ne!(parser.screen().contents(), contents); + let contents = parser.screen().contents(); parser.process(b"\xf0"); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\x9f"); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\x92"); - assert_eq!(parser.screen().contents(0, 0, 23, 79), contents); + assert_eq!(parser.screen().contents(), contents); parser.process(b"\xa9"); - assert_ne!(parser.screen().contents(0, 0, 23, 79), contents); + assert_ne!(parser.screen().contents(), contents); } |