diff options
author | Michael Davis | 2022-11-26 19:04:27 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-02-28 03:35:52 +0000 |
commit | a066815833b322233dc11aeae38679bc8466ec56 (patch) | |
tree | f5ac3b88cd20a0448aca7e54f62537dede5758af /helix-term/src | |
parent | 79bf5e3094e16a34637703b14c7bf090d2dcf155 (diff) |
Enable the enhanced keyboard protocol if supported
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c8e8ecb1..d7896419 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -40,7 +40,8 @@ use anyhow::{Context, Error}; use crossterm::{ event::{ DisableBracketedPaste, DisableFocusChange, DisableMouseCapture, EnableBracketedPaste, - EnableFocusChange, EnableMouseCapture, Event as CrosstermEvent, + EnableFocusChange, EnableMouseCapture, Event as CrosstermEvent, KeyboardEnhancementFlags, + PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags, }, execute, terminal, tty::IsTty, @@ -111,6 +112,9 @@ fn restore_term() -> Result<(), Error> { let mut stdout = stdout(); // reset cursor shape write!(stdout, "\x1B[0 q")?; + if matches!(terminal::supports_keyboard_enhancement(), Ok(true)) { + execute!(stdout, PopKeyboardEnhancementFlags)?; + } // Ignore errors on disabling, this might trigger on windows if we call // disable without calling enable previously let _ = execute!(stdout, DisableMouseCapture); @@ -1062,6 +1066,19 @@ impl Application { if self.config.load().editor.mouse { execute!(stdout, EnableMouseCapture)?; } + if matches!(terminal::supports_keyboard_enhancement(), Ok(true)) { + log::debug!("The enhanced keyboard protocol is supported on this terminal"); + execute!( + stdout, + PushKeyboardEnhancementFlags( + KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES + | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS + ) + )?; + } else { + log::debug!("The enhanced keyboard protocol is not supported on this terminal"); + } + Ok(()) } |