mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-22 08:13:57 +01:00
feat: enable enhanced keyboard mode (#1505)
This enabled the Kitty Keyboard Protocol Read more here: https://sw.kovidgoyal.net/kitty/keyboard-protocol/ No change on unsupported terminals, but means in the future we can be more creative with keybinding depending on terminal. Tested on Alacritty and events come through with all modifiers supported. Will be useful for #193
This commit is contained in:
parent
951aafa414
commit
e129f7a93e
@ -7,7 +7,8 @@ use atuin_common::utils;
|
||||
use crossterm::{
|
||||
event::{
|
||||
self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers,
|
||||
MouseEvent,
|
||||
KeyboardEnhancementFlags, MouseEvent, PopKeyboardEnhancementFlags,
|
||||
PushKeyboardEnhancementFlags,
|
||||
},
|
||||
execute, terminal,
|
||||
};
|
||||
@ -562,14 +563,21 @@ impl Stdout {
|
||||
pub fn new(inline_mode: bool) -> std::io::Result<Self> {
|
||||
terminal::enable_raw_mode()?;
|
||||
let mut stdout = stdout();
|
||||
|
||||
if !inline_mode {
|
||||
execute!(stdout, terminal::EnterAlternateScreen)?;
|
||||
}
|
||||
|
||||
execute!(
|
||||
stdout,
|
||||
event::EnableMouseCapture,
|
||||
event::EnableBracketedPaste,
|
||||
PushKeyboardEnhancementFlags(
|
||||
KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES
|
||||
| KeyboardEnhancementFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES
|
||||
),
|
||||
)?;
|
||||
|
||||
Ok(Self {
|
||||
stdout,
|
||||
inline_mode,
|
||||
@ -586,6 +594,7 @@ impl Drop for Stdout {
|
||||
self.stdout,
|
||||
event::DisableMouseCapture,
|
||||
event::DisableBracketedPaste,
|
||||
PopKeyboardEnhancementFlags
|
||||
)
|
||||
.unwrap();
|
||||
terminal::disable_raw_mode().unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user