Enable the enhanced keyboard protocol if supported
This commit is contained in:
parent
79bf5e3094
commit
a066815833
@ -40,7 +40,8 @@
|
|||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{
|
event::{
|
||||||
DisableBracketedPaste, DisableFocusChange, DisableMouseCapture, EnableBracketedPaste,
|
DisableBracketedPaste, DisableFocusChange, DisableMouseCapture, EnableBracketedPaste,
|
||||||
EnableFocusChange, EnableMouseCapture, Event as CrosstermEvent,
|
EnableFocusChange, EnableMouseCapture, Event as CrosstermEvent, KeyboardEnhancementFlags,
|
||||||
|
PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
||||||
},
|
},
|
||||||
execute, terminal,
|
execute, terminal,
|
||||||
tty::IsTty,
|
tty::IsTty,
|
||||||
@ -111,6 +112,9 @@ fn restore_term() -> Result<(), Error> {
|
|||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
// reset cursor shape
|
// reset cursor shape
|
||||||
write!(stdout, "\x1B[0 q")?;
|
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
|
// Ignore errors on disabling, this might trigger on windows if we call
|
||||||
// disable without calling enable previously
|
// disable without calling enable previously
|
||||||
let _ = execute!(stdout, DisableMouseCapture);
|
let _ = execute!(stdout, DisableMouseCapture);
|
||||||
@ -1062,6 +1066,19 @@ async fn claim_term(&mut self) -> Result<(), Error> {
|
|||||||
if self.config.load().editor.mouse {
|
if self.config.load().editor.mouse {
|
||||||
execute!(stdout, EnableMouseCapture)?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user