Files
orca/src/shared/terminal-modified-enter-encoding.ts
T
Kelvin Amoaba a9f90e7a71 fix(mobile): use desktop's terminal paste, key and query-reply rules (#33957)
* fix(mobile): send terminal paste, keys and query replies like desktop

* fix(mobile): encode Shift+Enter for the pane's negotiated keyboard modes

The phone's xterm now tracks Kitty flags and modifyOtherKeys with desktop's tracker, seeded from the host snapshot.

* fix(mobile): keep keyboard modes across terminal snapshots

* fix(mobile): adopt snapshot keyboard modes with desktop's rule

* refactor(terminal): share snapshot keyboard-mode adoption and mode mirroring

* fix(mobile): compare terminal modes field by field instead of a dynamic read

* refactor(mobile): share terminal display-mode adoption between snapshot and resize

* fix(mobile): accept only known terminal display modes from the host
2026-10-27 04:26:16 +00:00

26 lines
816 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const TERMINAL_KITTY_SHIFT_ENTER_INPUT = '\x1b[13;2u'
/** Ctrl+Backspace deletes the previous word, like readline's Ctrl+W. */
export const TERMINAL_CTRL_BACKSPACE_INPUT = '\x17'
/** ESC CR depends on Pi’s private Kitty-query result, which panes cannot observe. Armed modifyOtherKeys uses CSI 27;mod;13~ consistently in either state (STA-7701). */
export function encodeModifyOtherKeysEnter(
modifyOtherKeys: number,
modifier: 2 | 3
): string | null {
return modifyOtherKeys > 0 ? `\x1b[27;${modifier};13~` : null
}
export function encodeTerminalShiftEnter({
canSendCsiU,
modifyOtherKeys
}: {
canSendCsiU: boolean
modifyOtherKeys: number
}): string {
if (canSendCsiU) {
return TERMINAL_KITTY_SHIFT_ENTER_INPUT
}
return encodeModifyOtherKeysEnter(modifyOtherKeys, 2) ?? '\x1b\r'
}