From e7fc85bfdb51f89488430adbfe5bbced3be79c2f Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Thu, 23 Jul 2026 03:47:34 +0300 Subject: fix: preserve kitty printable key releases refs #1746 --- src/terminal_modes.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/terminal_modes.rs') diff --git a/src/terminal_modes.rs b/src/terminal_modes.rs index e07de629..8f0276e0 100644 --- a/src/terminal_modes.rs +++ b/src/terminal_modes.rs @@ -15,10 +15,41 @@ pub(crate) fn clear_host_mouse_reporting(_writer: &mut W) -> io::Resul Ok(()) } +#[cfg(not(windows))] +pub(crate) fn set_host_kitty_keyboard_report_all( + writer: &mut W, + report_all_keys: bool, +) -> io::Result<()> { + let mut flags = crate::input::ime_compatible_keyboard_enhancement_flags(); + if report_all_keys { + flags |= crossterm::event::KeyboardEnhancementFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES; + } + write!(writer, "\x1b[={}u", flags.bits())?; + writer.flush() +} + +#[cfg(windows)] +pub(crate) fn set_host_kitty_keyboard_report_all( + _writer: &mut W, + _report_all_keys: bool, +) -> io::Result<()> { + Ok(()) +} + #[cfg(test)] mod tests { use super::*; + #[test] + fn host_keyboard_report_all_only_changes_the_current_herdr_stack_entry() { + let mut output = Vec::new(); + + set_host_kitty_keyboard_report_all(&mut output, true).unwrap(); + set_host_kitty_keyboard_report_all(&mut output, false).unwrap(); + + assert_eq!(output, b"\x1b[=15u\x1b[=7u"); + } + #[test] fn clears_all_known_host_mouse_modes() { let sequence = std::str::from_utf8(DISABLE_HOST_MOUSE_REPORTING_SEQUENCE).unwrap(); -- cgit v1.2.3