Skip to content

Route send-next-key through the key encoder - #596

Merged
dakra merged 1 commit into
mainfrom
fix/send-next-key-encoder
Aug 3, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/send-next-key-encoder

Conversation

@dakra

@dakra dakra commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

ghostel-send-next-key (C-c C-q) wrote C0 and printable-ASCII events to the PTY as raw bytes, bypassing the key encoder. A child that enabled the kitty keyboard protocol then received bytes outside the negotiated encoding — e.g. a bare ESC where the disambiguate flag promises CSI 27u.

Changes

  • Extract the event → (key-name . mod-string) decoding from ghostel--send-event into a shared ghostel--event-key-spec helper (C0 disambiguation for Enter/Tab/ESC, shift-case restore, function-key symbols).
  • Route ghostel-send-next-key through it, so every key with an encoder representation goes through the terminal's negotiated encoding. Non-ASCII plain characters keep the UTF-8 fallback.
  • Legacy children see byte-identical output for unmodified and ctrl-chord C0/ASCII input; ctrl+shift chords now encode CSI-u, consistent with what ghostel--send-event already did for bound keys.
  • The rescue commands (ghostel-send-C-c and friends) intentionally keep sending raw bytes so the tty line discipline acts on them regardless of the child's protocol state.

Testing

  • New ERT tests: ghostel--event-key-spec decode contract, C0 bytes through the encoder, non-ASCII UTF-8 fallback; updated the three tests that pinned the old raw-byte behavior.
  • make -j8 all green (build, elisp + native tests, lint).

The send-next-key escape hatch wrote C0 and printable-ASCII events to
the PTY as raw bytes, bypassing the key encoder.  A child that enabled
the kitty keyboard protocol then received bytes outside the negotiated
encoding, e.g. a bare ESC where the disambiguate flag promises CSI 27u.

Extract the event decoding from ghostel--send-event into
ghostel--event-key-spec and use it for send-next-key too, so raw
Enter/Tab/ESC bytes map to the functional key rather than a ctrl
chord and every key with an encoder representation goes through the
terminal's negotiated encoding.  Legacy children see byte-identical
output for unmodified and ctrl-chord C0/ASCII input; ctrl+shift
chords now encode CSI-u like ghostel--send-event already did for
bound keys.  Non-ASCII characters keep the UTF-8 fallback, and the
rescue commands (ghostel-send-C-c and friends) intentionally keep
sending raw bytes so the line discipline acts on them regardless of
the child's protocol state.
@dakra
dakra merged commit 37a82ca into main Aug 3, 2026
29 checks passed
@dakra
dakra deleted the fix/send-next-key-encoder branch August 3, 2026 13:33

This branch was previously deployed

1 inactive deployment
github-pages — 37a82caa Deployed Aug 3, 2026 by dakra via deploy #143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant