diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2024-12-20 03:51:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-20 00:51:36 +0000 |
commit | 8591a9421d0a100af16cd50b4610bc55506fb14f (patch) | |
tree | 8c034971ecb0174592b8dd2f47b23932906cc9ac | |
parent | 39daaffff9c694d3aa54d1a749cd2523341509d9 (diff) | |
download | alacritty-8591a9421d0a100af16cd50b4610bc55506fb14f.tar.gz alacritty-8591a9421d0a100af16cd50b4610bc55506fb14f.zip |
Always explicitly emit `1` without modifiers in kitty encoding
While this doesn't change much with how parsers are implemented, it
improves consistency with how key release is handled.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/input/keyboard.rs | 15 |
2 files changed, 13 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ed471ce7..86637383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its - Moved config option `shell` to `terminal.shell` - `ctrl+shift+u` binding to open links to `ctrl+shift+o` to avoid collisions with IMEs - Use `Beam` cursor for single char cursor inside the IME preview +- Always emit `1` for the first parameter when having modifiers in kitty keyboard protocol ### Fixed diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs index 14755594..85734109 100644 --- a/alacritty/src/input/keyboard.rs +++ b/alacritty/src/input/keyboard.rs @@ -280,7 +280,7 @@ fn build_sequence(key: KeyEvent, mods: ModifiersState, mode: TermMode) -> Vec<u8 let sequence_base = context .try_build_numpad(&key) .or_else(|| context.try_build_named_kitty(&key)) - .or_else(|| context.try_build_named_normal(&key)) + .or_else(|| context.try_build_named_normal(&key, associated_text.is_some())) .or_else(|| context.try_build_control_char_or_mod(&key, &mut modifiers)) .or_else(|| context.try_build_textual(&key, associated_text)); @@ -483,14 +483,23 @@ impl SequenceBuilder { } /// Try building from [`NamedKey`]. - fn try_build_named_normal(&self, key: &KeyEvent) -> Option<SequenceBase> { + fn try_build_named_normal( + &self, + key: &KeyEvent, + has_associated_text: bool, + ) -> Option<SequenceBase> { let named = match key.logical_key { Key::Named(named) => named, _ => return None, }; // The default parameter is 1, so we can omit it. - let one_based = if self.modifiers.is_empty() && !self.kitty_event_type { "" } else { "1" }; + let one_based = + if self.modifiers.is_empty() && !self.kitty_event_type && !has_associated_text { + "" + } else { + "1" + }; let (base, terminator) = match named { NamedKey::PageUp => ("5", SequenceTerminator::Normal('~')), NamedKey::PageDown => ("6", SequenceTerminator::Normal('~')), |