aboutsummaryrefslogtreecommitdiff
path: root/src/terminal_modes.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-23 03:47:34 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-23 03:47:44 +0300
commite7fc85bfdb51f89488430adbfe5bbced3be79c2f (patch)
treec1c0324f28040c50d0075d6407bdf6ab14d1b8c0 /src/terminal_modes.rs
parent2a20e90a026936d0d5b96823d74e2e4fe13a166f (diff)
fix: preserve kitty printable key releases
refs #1746
Diffstat (limited to 'src/terminal_modes.rs')
-rw-r--r--src/terminal_modes.rs31
1 files changed, 31 insertions, 0 deletions
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,11 +15,42 @@ pub(crate) fn clear_host_mouse_reporting<W: Write>(_writer: &mut W) -> io::Resul
Ok(())
}
+#[cfg(not(windows))]
+pub(crate) fn set_host_kitty_keyboard_report_all<W: Write>(
+ 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<W: Write>(
+ _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();