aboutsummaryrefslogtreecommitdiff
path: root/src/input/tests.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-03-31 23:03:11 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-03-31 23:03:11 +0300
commite857710d73ad660d17ce39fa3201a39aa49f6932 (patch)
tree7fa2db20fc6c4e78b9d182af449784ed48515c9e /src/input/tests.rs
parent5f97b0c26d848ef36aed70df906893907e2d0686 (diff)
fix: align pane scrolling with tmux and ghostty
Diffstat (limited to 'src/input/tests.rs')
-rw-r--r--src/input/tests.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/input/tests.rs b/src/input/tests.rs
index 0d9d2c74..e6900df7 100644
--- a/src/input/tests.rs
+++ b/src/input/tests.rs
@@ -1,7 +1,8 @@
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, ModifierKeyCode};
use super::{
- encode_key, encode_terminal_key, parse_terminal_key_sequence, KeyboardProtocol, TerminalKey,
+ encode_cursor_key, encode_key, encode_mouse_scroll, encode_terminal_key,
+ parse_terminal_key_sequence, KeyboardProtocol, TerminalKey,
};
fn assert_terminal_key_eq(
@@ -143,6 +144,32 @@ fn legacy_alt_char_still_esc_prefix() {
}
#[test]
+fn application_cursor_keys_use_ss3_sequences() {
+ assert_eq!(encode_cursor_key(KeyCode::Up, true), b"\x1bOA");
+ assert_eq!(encode_cursor_key(KeyCode::Down, true), b"\x1bOB");
+}
+
+#[test]
+fn normal_cursor_keys_use_csi_sequences() {
+ assert_eq!(encode_cursor_key(KeyCode::Up, false), b"\x1b[A");
+ assert_eq!(encode_cursor_key(KeyCode::Down, false), b"\x1b[B");
+}
+
+#[test]
+fn sgr_mouse_scroll_encodes_wheel_button_and_coordinates() {
+ let encoded = encode_mouse_scroll(
+ crossterm::event::MouseEventKind::ScrollDown,
+ 4,
+ 6,
+ KeyModifiers::SHIFT,
+ vt100::MouseProtocolEncoding::Sgr,
+ )
+ .expect("mouse scroll should encode");
+
+ assert_eq!(encoded, b"\x1b[<69;5;7M");
+}
+
+#[test]
fn kitty_shift_enter() {
let key = KeyEvent::new(KeyCode::Enter, KeyModifiers::SHIFT);
assert_eq!(