mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
fix(tui): route Ctrl+K and Ctrl+W through macOS readline fallback
Makes Ctrl+K and Ctrl+W work in hermes --tui mode in macOS
This commit is contained in:
parent
b49a1b71a7
commit
ea9ddecc72
3 changed files with 31 additions and 7 deletions
|
|
@ -16,15 +16,18 @@ export const isActionMod = (key: { ctrl: boolean; meta: boolean; super?: boolean
|
|||
isMac ? key.meta || key.super === true : key.ctrl
|
||||
|
||||
/**
|
||||
* Some macOS terminals rewrite Cmd navigation/deletion into readline control keys.
|
||||
* Treat those as action shortcuts too, but only for the specific fallbacks we
|
||||
* have observed from terminals: Cmd+Left → Ctrl+A, Cmd+Right → Ctrl+E,
|
||||
* Cmd+Backspace → Ctrl+U.
|
||||
* Accept raw Ctrl+<letter> as an action shortcut on macOS, where `isActionMod`
|
||||
* otherwise means Cmd. Two motivations:
|
||||
* - Some macOS terminals rewrite Cmd navigation/deletion into readline control
|
||||
* keys (Cmd+Left → Ctrl+A, Cmd+Right → Ctrl+E, Cmd+Backspace → Ctrl+U).
|
||||
* - Ctrl+K (kill-to-end) and Ctrl+W (delete-word-back) are standard readline
|
||||
* bindings that users expect to work regardless of platform, even though
|
||||
* no terminal rewrites Cmd into them.
|
||||
*/
|
||||
export const isMacActionFallback = (
|
||||
key: { ctrl: boolean; meta: boolean; super?: boolean },
|
||||
ch: string,
|
||||
target: 'a' | 'e' | 'u'
|
||||
target: 'a' | 'e' | 'u' | 'k' | 'w'
|
||||
): boolean => isMac && key.ctrl && !key.meta && key.super !== true && ch.toLowerCase() === target
|
||||
|
||||
/** Match action-modifier + a single character (case-insensitive). */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue