fix(terminal): restore keyboard reporting on detach (#2395)
refs #2393 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
This commit is contained in:
parent
fc824b99ab
commit
e9222d1882
|
|
@ -1,5 +1,7 @@
|
|||
use std::io::{self, Write};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
use crossterm::event::{PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags};
|
||||
#[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";
|
||||
|
|
@ -24,8 +26,13 @@ pub(crate) fn set_host_kitty_keyboard_report_all<W: Write>(
|
|||
if report_all_keys {
|
||||
flags |= crossterm::event::KeyboardEnhancementFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES;
|
||||
}
|
||||
write!(writer, "\x1b[={}u", flags.bits())?;
|
||||
writer.flush()
|
||||
// Older iTerm2 releases clear the keyboard stack on SET, so a later pop
|
||||
// cannot restore the host state. Replace only Herdr's top entry instead.
|
||||
crossterm::execute!(
|
||||
writer,
|
||||
PopKeyboardEnhancementFlags,
|
||||
PushKeyboardEnhancementFlags(flags)
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
|
@ -41,13 +48,13 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn host_keyboard_report_all_only_changes_the_current_herdr_stack_entry() {
|
||||
fn host_keyboard_report_all_replaces_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");
|
||||
assert_eq!(output, b"\x1b[<1u\x1b[>15u\x1b[<1u\x1b[>7u");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue