Skip to content

Commit

Permalink
feat: enable enhanced keyboard mode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ellie committed Jan 5, 2024
1 parent 951aafa commit a0e9cba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion atuin/src/command/client/search/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand All @@ -586,6 +594,7 @@ impl Drop for Stdout {
self.stdout,
event::DisableMouseCapture,
event::DisableBracketedPaste,
PopKeyboardEnhancementFlags
)
.unwrap();
terminal::disable_raw_mode().unwrap();
Expand Down

0 comments on commit a0e9cba

Please sign in to comment.