aboutsummaryrefslogtreecommitdiff
path: root/src/terminal_modes.rs
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-08-31 21:22:56 +0200
committerGitHub <noreply@github.com>2026-08-31 21:22:56 +0200
commitef2674bab8a3b38984578473c1a80589ebcbb333 (patch)
tree2671b283d352158726ab06d52a6aec607ce98014 /src/terminal_modes.rs
parentd2cb0961663582a5069b1528edb93a9a8b23e1bc (diff)
fix(windows): enable mouse reporting over openssh (#3461)
refs #2810
Diffstat (limited to 'src/terminal_modes.rs')
-rw-r--r--src/terminal_modes.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/terminal_modes.rs b/src/terminal_modes.rs
index 5b6a5d3b..c9f08ceb 100644
--- a/src/terminal_modes.rs
+++ b/src/terminal_modes.rs
@@ -6,6 +6,13 @@ use crossterm::event::{PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags
const DISABLE_HOST_MOUSE_REPORTING_SEQUENCE: &[u8] =
b"\x1b[?1006l\x1b[?1016l\x1b[?1015l\x1b[?1005l\x1b[?1003l\x1b[?1002l\x1b[?1000l";
+#[cfg(any(windows, test))]
+const WINDOWS_SSH_MOUSE_REPORTING_ENABLE_SEQUENCE: &[u8] =
+ b"\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h";
+#[cfg(any(windows, test))]
+const WINDOWS_SSH_MOUSE_REPORTING_DISABLE_SEQUENCE: &[u8] =
+ b"\x1b[?1016l\x1b[?1006l\x1b[?1003l\x1b[?1002l\x1b[?1000l";
+
#[cfg(not(windows))]
pub(crate) fn clear_host_mouse_reporting<W: Write>(writer: &mut W) -> io::Result<()> {
writer.write_all(DISABLE_HOST_MOUSE_REPORTING_SEQUENCE)?;
@@ -17,6 +24,27 @@ pub(crate) fn clear_host_mouse_reporting<W: Write>(_writer: &mut W) -> io::Resul
Ok(())
}
+#[cfg(any(windows, test))]
+pub(crate) fn set_windows_ssh_mouse_reporting<W: Write>(
+ writer: &mut W,
+ enabled: bool,
+ sgr_pixels: bool,
+) -> io::Result<()> {
+ writer.write_all(if enabled {
+ WINDOWS_SSH_MOUSE_REPORTING_ENABLE_SEQUENCE
+ } else {
+ WINDOWS_SSH_MOUSE_REPORTING_DISABLE_SEQUENCE
+ })?;
+ if enabled {
+ writer.write_all(if sgr_pixels {
+ b"\x1b[?1016h"
+ } else {
+ b"\x1b[?1016l"
+ })?;
+ }
+ writer.flush()
+}
+
#[cfg(not(windows))]
pub(crate) fn set_host_kitty_keyboard_report_all<W: Write>(
writer: &mut W,
@@ -73,4 +101,18 @@ mod tests {
);
}
}
+
+ #[test]
+ fn windows_ssh_mouse_reporting_setup_and_teardown_request_required_modes() {
+ let mut output = Vec::new();
+
+ set_windows_ssh_mouse_reporting(&mut output, true, true).unwrap();
+ set_windows_ssh_mouse_reporting(&mut output, true, false).unwrap();
+ set_windows_ssh_mouse_reporting(&mut output, false, false).unwrap();
+
+ assert_eq!(
+ output,
+ b"\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h\x1b[?1016h\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h\x1b[?1016l\x1b[?1016l\x1b[?1006l\x1b[?1003l\x1b[?1002l\x1b[?1000l"
+ );
+ }
}