mirror of
https://github.com/herdrdev/herdr.git
synced 2026-09-14 18:03:41 +08:00
ef67a97047
refs #936
34 lines
944 B
Rust
34 lines
944 B
Rust
use std::io::{self, Write};
|
|
|
|
#[cfg(any(not(windows), test))]
|
|
const DISABLE_HOST_MOUSE_REPORTING_SEQUENCE: &[u8] =
|
|
b"\x1b[?1006l\x1b[?1016l\x1b[?1015l\x1b[?1005l\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)?;
|
|
writer.flush()
|
|
}
|
|
|
|
#[cfg(windows)]
|
|
pub(crate) fn clear_host_mouse_reporting<W: Write>(_writer: &mut W) -> io::Result<()> {
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn clears_all_known_host_mouse_modes() {
|
|
let sequence = std::str::from_utf8(DISABLE_HOST_MOUSE_REPORTING_SEQUENCE).unwrap();
|
|
|
|
for mode in ["1000", "1002", "1003", "1005", "1006", "1015", "1016"] {
|
|
assert!(
|
|
sequence.contains(&format!("\x1b[?{mode}l")),
|
|
"missing mouse mode {mode}"
|
|
);
|
|
}
|
|
}
|
|
}
|