Skip to content

Commit

Permalink
explicitly emit 1 without modifiers in kitty encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Dec 25, 2024
1 parent 67e64ae commit 4d1fbde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ language: 'en'
- Kitty keyboard protocol is now enabled by default.
- Allow `Renderer` to be configured cross-platform by `Platform` property.
- Add `ToggleFullscreen` to configurable actions.
- Always emit `1` for the first parameter when having modifiers in kitty keyboard protocol.

## 0.2.2

Expand Down
13 changes: 10 additions & 3 deletions frontends/rioterm/src/bindings/kitty_keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn build_key_sequence(key: &KeyEvent, mods: ModifiersState, mode: Mode) -> V
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));

Expand Down Expand Up @@ -263,14 +263,21 @@ 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 {
let one_based = if self.modifiers.is_empty()
&& !self.kitty_event_type
&& !has_associated_text
{
""
} else {
"1"
Expand Down

0 comments on commit 4d1fbde

Please sign in to comment.