Add terminal-escapes.js with a canonical clear sequence (home, CSI 3J/2J, SGR reset) and use it for fish ^L and fish-tty-repro. Match /bin/clear in coreutils with the same sequence and a sync comment. Harden fish-readline for bracketed paste, SS3/legacy CSI arrows, focus CSI, and common ~ keys; widen stripAnsi CSI matching. Add brittle and coreutils tests for the sequence and paste/focus/^L behavior.
25 lines
888 B
JavaScript
25 lines
888 B
JavaScript
/**
|
|
* Canonical terminal sequences for xterm.js / VT100-style hosts (Pear stdio, SSH PTY).
|
|
* Keep {@link XTERM_CLEAR_SCROLLBACK_AND_VIEWPORT} in sync with
|
|
* `packages/bare-os-coreutils/src/clear.js` (kernel /bin scripts cannot import this module).
|
|
*/
|
|
|
|
/** SGR reset */
|
|
export const SGR_RESET = '\x1b[0m'
|
|
|
|
/** Cursor to home (1,1) */
|
|
export const CURSOR_HOME = '\x1b[H'
|
|
|
|
/** Erase saved lines (scrollback) then full display — xterm.js honors CSI 3 J */
|
|
export const CSI_ERASE_SCROLLBACK = '\x1b[3J'
|
|
|
|
/** Erase entire display (viewport) */
|
|
export const CSI_ERASE_DISPLAY = '\x1b[2J'
|
|
|
|
/**
|
|
* Clear scrollback and visible screen, home cursor, reset attributes.
|
|
* Order: home first so erase targets a stable origin; 3J then 2J matches common xterm expectations.
|
|
*/
|
|
export const XTERM_CLEAR_SCROLLBACK_AND_VIEWPORT =
|
|
CURSOR_HOME + CSI_ERASE_SCROLLBACK + CSI_ERASE_DISPLAY + SGR_RESET
|