diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/anes/tests/parser/mouse | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/anes/tests/parser/mouse')
-rw-r--r-- | vendor/anes/tests/parser/mouse/mod.rs | 2 | ||||
-rw-r--r-- | vendor/anes/tests/parser/mouse/rxvt.rs | 152 | ||||
-rw-r--r-- | vendor/anes/tests/parser/mouse/xterm.rs | 154 |
3 files changed, 308 insertions, 0 deletions
diff --git a/vendor/anes/tests/parser/mouse/mod.rs b/vendor/anes/tests/parser/mouse/mod.rs new file mode 100644 index 000000000..dc53361e4 --- /dev/null +++ b/vendor/anes/tests/parser/mouse/mod.rs @@ -0,0 +1,2 @@ +mod rxvt; +mod xterm; diff --git a/vendor/anes/tests/parser/mouse/rxvt.rs b/vendor/anes/tests/parser/mouse/rxvt.rs new file mode 100644 index 000000000..47f43a51c --- /dev/null +++ b/vendor/anes/tests/parser/mouse/rxvt.rs @@ -0,0 +1,152 @@ +use anes::parser::{KeyModifiers, Mouse, MouseButton, Sequence}; + +use crate::test_sequences; + +#[test] +fn button_down() { + test_sequences!( + b"\x1B[0;30;40;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 30, 40), + KeyModifiers::empty() + ), + b"\x1B[1;30;40;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Middle, 30, 40), + KeyModifiers::empty() + ), + b"\x1B[2;30;40;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Right, 30, 40), + KeyModifiers::empty() + ), + ); +} + +#[test] +fn button_down_with_modifiers() { + test_sequences!( + b"\x1B[4;30;40;M", + Sequence::Mouse(Mouse::Down(MouseButton::Left, 30, 40), KeyModifiers::SHIFT), + b"\x1B[5;30;40;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Middle, 30, 40), + KeyModifiers::SHIFT + ), + b"\x1B[6;30;40;M", + Sequence::Mouse(Mouse::Down(MouseButton::Right, 30, 40), KeyModifiers::SHIFT), + ); +} + +#[test] +fn button_up() { + test_sequences!( + b"\x1B[3;30;40;M", + Sequence::Mouse(Mouse::Up(MouseButton::Any, 30, 40), KeyModifiers::empty()), + ); +} + +#[test] +fn button_up_with_modifiers() { + test_sequences!( + b"\x1B[7;30;40;M", + Sequence::Mouse(Mouse::Up(MouseButton::Any, 30, 40), KeyModifiers::SHIFT), + ); +} + +#[test] +fn scroll() { + test_sequences!( + b"\x1B[96;30;40;M", + Sequence::Mouse(Mouse::ScrollUp(30, 40), KeyModifiers::empty()), + b"\x1B[97;30;40;M", + Sequence::Mouse(Mouse::ScrollDown(30, 40), KeyModifiers::empty()), + ); +} + +#[test] +fn scroll_with_modifiers() { + test_sequences!( + b"\x1B[100;30;40;M", + Sequence::Mouse(Mouse::ScrollUp(30, 40), KeyModifiers::SHIFT), + b"\x1B[101;30;40;M", + Sequence::Mouse(Mouse::ScrollDown(30, 40), KeyModifiers::SHIFT), + ); +} + +#[test] +fn drag() { + test_sequences!( + b"\x1B[64;30;40;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Left, 30, 40), + KeyModifiers::empty() + ), + b"\x1B[65;30;40;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Middle, 30, 40), + KeyModifiers::empty() + ), + b"\x1B[66;30;40;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Right, 30, 40), + KeyModifiers::empty() + ), + ); +} + +#[test] +fn drag_with_modifiers() { + test_sequences!( + b"\x1B[64;30;40;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Left, 30, 40), + KeyModifiers::empty() + ), + b"\x1B[65;30;40;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Middle, 30, 40), + KeyModifiers::empty() + ), + b"\x1B[66;30;40;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Right, 30, 40), + KeyModifiers::empty() + ), + ); +} + +#[test] +fn key_modifier_combinations() { + test_sequences!( + b"\x1B[4;20;10M", + Sequence::Mouse(Mouse::Down(MouseButton::Left, 20, 10), KeyModifiers::SHIFT), + b"\x1B[8;20;10M", + Sequence::Mouse(Mouse::Down(MouseButton::Left, 20, 10), KeyModifiers::ALT), + b"\x1B[16;20;10M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 20, 10), + KeyModifiers::CONTROL + ), + b"\x1B[12;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 20, 10), + KeyModifiers::SHIFT | KeyModifiers::ALT + ), + b"\x1B[20;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 20, 10), + KeyModifiers::SHIFT | KeyModifiers::CONTROL + ), + b"\x1B[24;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 20, 10), + KeyModifiers::ALT | KeyModifiers::CONTROL + ), + b"\x1B[28;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 20, 10), + KeyModifiers::SHIFT | KeyModifiers::ALT | KeyModifiers::CONTROL + ), + ); +} diff --git a/vendor/anes/tests/parser/mouse/xterm.rs b/vendor/anes/tests/parser/mouse/xterm.rs new file mode 100644 index 000000000..47293d69e --- /dev/null +++ b/vendor/anes/tests/parser/mouse/xterm.rs @@ -0,0 +1,154 @@ +use anes::parser::{KeyModifiers, Mouse, MouseButton, Sequence}; + +use crate::test_sequences; + +#[test] +fn button_down() { + test_sequences!( + b"\x1B[<0;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Left, 20, 10), + KeyModifiers::empty() + ), + b"\x1B[<1;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Middle, 20, 10), + KeyModifiers::empty() + ), + b"\x1B[<2;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Right, 20, 10), + KeyModifiers::empty() + ), + ); +} + +#[test] +fn button_down_with_key_modifiers() { + test_sequences!( + b"\x1B[<4;20;10;M", + Sequence::Mouse(Mouse::Down(MouseButton::Left, 20, 10), KeyModifiers::SHIFT), + b"\x1B[<5;20;10;M", + Sequence::Mouse( + Mouse::Down(MouseButton::Middle, 20, 10), + KeyModifiers::SHIFT + ), + b"\x1B[<6;20;10;M", + Sequence::Mouse(Mouse::Down(MouseButton::Right, 20, 10), KeyModifiers::SHIFT), + ); +} + +#[test] +fn button_up() { + test_sequences!( + b"\x1B[<0;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::empty()), + b"\x1B[<1;20;10;m", + Sequence::Mouse( + Mouse::Up(MouseButton::Middle, 20, 10), + KeyModifiers::empty() + ), + b"\x1B[<2;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Right, 20, 10), KeyModifiers::empty()), + ); +} + +#[test] +fn button_up_with_key_modifiers() { + test_sequences!( + b"\x1B[<4;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::SHIFT), + b"\x1B[<5;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Middle, 20, 10), KeyModifiers::SHIFT), + b"\x1B[<6;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Right, 20, 10), KeyModifiers::SHIFT), + ); +} + +#[test] +fn scroll() { + test_sequences!( + b"\x1B[<64;20;10;m", + Sequence::Mouse(Mouse::ScrollUp(20, 10), KeyModifiers::empty()), + b"\x1B[<65;20;10;m", + Sequence::Mouse(Mouse::ScrollDown(20, 10), KeyModifiers::empty()), + ); +} + +#[test] +fn scroll_with_key_modifiers() { + test_sequences!( + b"\x1B[<68;20;10;m", + Sequence::Mouse(Mouse::ScrollUp(20, 10), KeyModifiers::SHIFT), + b"\x1B[<69;20;10;m", + Sequence::Mouse(Mouse::ScrollDown(20, 10), KeyModifiers::SHIFT), + ); +} + +#[test] +fn drag() { + test_sequences!( + b"\x1B[<32;20;10;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Left, 20, 10), + KeyModifiers::empty() + ), + b"\x1B[<33;20;10;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Middle, 20, 10), + KeyModifiers::empty() + ), + b"\x1B[<34;20;10;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Right, 20, 10), + KeyModifiers::empty() + ), + ); +} + +#[test] +fn drag_with_key_modifiers() { + test_sequences!( + b"\x1B[<36;20;10;M", + Sequence::Mouse(Mouse::Drag(MouseButton::Left, 20, 10), KeyModifiers::SHIFT), + b"\x1B[<37;20;10;M", + Sequence::Mouse( + Mouse::Drag(MouseButton::Middle, 20, 10), + KeyModifiers::SHIFT, + ), + b"\x1B[<38;20;10;M", + Sequence::Mouse(Mouse::Drag(MouseButton::Right, 20, 10), KeyModifiers::SHIFT), + ); +} + +#[test] +fn key_modifier_combinations() { + test_sequences!( + b"\x1B[<4;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::SHIFT), + b"\x1B[<8;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::ALT), + b"\x1B[<16;20;10;m", + Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::CONTROL), + b"\x1B[<12;20;10;m", + Sequence::Mouse( + Mouse::Up(MouseButton::Left, 20, 10), + KeyModifiers::SHIFT | KeyModifiers::ALT + ), + b"\x1B[<20;20;10;m", + Sequence::Mouse( + Mouse::Up(MouseButton::Left, 20, 10), + KeyModifiers::SHIFT | KeyModifiers::CONTROL + ), + b"\x1B[<24;20;10;m", + Sequence::Mouse( + Mouse::Up(MouseButton::Left, 20, 10), + KeyModifiers::ALT | KeyModifiers::CONTROL + ), + b"\x1B[<28;20;10;m", + Sequence::Mouse( + Mouse::Up(MouseButton::Left, 20, 10), + KeyModifiers::SHIFT | KeyModifiers::ALT | KeyModifiers::CONTROL + ), + ); +} |