Multi-line input: shift-enter, wrapping, /keys #120

Merged
hermes merged 1 commits from multiline-input into main 2026-10-03 11:36:19 +00:00
Collaborator

Shift-enter already inserted a newline in code, but terminals send it as plain Enter unless the app asks for the kitty keyboard protocol.

  • Probe supports_keyboard_enhancement() before the alt screen; if answered, push DISAMBIGUATE_ESCAPE_CODES, pop on exit and in the panic hook. Covers ghostty, kitty, WezTerm (needs enable_kitty_keyboard), iTerm2, foot, Alacritty, zellij.
  • tmux (no kitty protocol): send xterm modifyOtherKeys request (CSI > 4;2 m), reset on exit. crossterm 0.29 does not parse tmux's default ESC[27;2;13~, so tmux still needs extended-keys-format csi-u (documented in README).
  • Fallbacks: alt-enter, ctrl-j, trailing \\ + enter.
  • /keys: shows each key as hx receives it plus whether the protocol is on, to debug herdr or any other layer.
  • Input box wraps long lines; height and cursor from wrapped rows (cap 10, then scrolls).

Tests: editor wrap/cursor + backslash unit tests, key-event test (shift-enter/enter/backslash), wrapped render test, /keys probe test, tui_smoke sends ESC[13;2u and answers the probe like a non-kitty terminal. tests/all.sh green.

Not verified: real terminals (ghostty, herdr, tmux, zellij). Width wrapping counts chars, not cell width (CJK/emoji can overflow a cell).

Shift-enter already inserted a newline in code, but terminals send it as plain Enter unless the app asks for the kitty keyboard protocol. - Probe `supports_keyboard_enhancement()` before the alt screen; if answered, push `DISAMBIGUATE_ESCAPE_CODES`, pop on exit and in the panic hook. Covers ghostty, kitty, WezTerm (needs `enable_kitty_keyboard`), iTerm2, foot, Alacritty, zellij. - tmux (no kitty protocol): send xterm `modifyOtherKeys` request (`CSI > 4;2 m`), reset on exit. crossterm 0.29 does not parse tmux's default `ESC[27;2;13~`, so tmux still needs `extended-keys-format csi-u` (documented in README). - Fallbacks: alt-enter, ctrl-j, trailing `\\` + enter. - `/keys`: shows each key as hx receives it plus whether the protocol is on, to debug herdr or any other layer. - Input box wraps long lines; height and cursor from wrapped rows (cap 10, then scrolls). Tests: editor wrap/cursor + backslash unit tests, key-event test (shift-enter/enter/backslash), wrapped render test, `/keys` probe test, tui_smoke sends `ESC[13;2u` and answers the probe like a non-kitty terminal. `tests/all.sh` green. Not verified: real terminals (ghostty, herdr, tmux, zellij). Width wrapping counts chars, not cell width (CJK/emoji can overflow a cell).
hermes added 1 commit 2026-10-02 23:04:17 +00:00
hermes merged commit 02373fd597 into main 2026-10-03 11:36:19 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#120