Files
bare-operating-system/packages/bare-os-coreutils/test/clear-sequence.test.mjs
T
Raven Scott 4846c534fd feat(terminal): align clear and fish TTY with xterm.js scrollback behavior
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.
2026-04-25 02:00:44 -04:00

23 lines
881 B
JavaScript

/**
* Ensures /bin/clear stays aligned with bare-os-booter terminal-escapes.js
* (kernel scripts cannot import the booter module).
*/
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
/** Source must use hex escapes (not raw ESC bytes) so the file stays printable UTF-8 */
const expectedSourceLiteral =
"const seq = '\\x1b[H\\x1b[3J\\x1b[2J\\x1b[0m'"
test('clear.js uses xterm scrollback + viewport clear sequence', async () => {
const src = await readFile(join(__dirname, '../src/clear.js'), 'utf8')
assert.ok(
src.includes(expectedSourceLiteral),
'clear.js must use the canonical xterm clear sequence (sync with bare-os-booter terminal-escapes.js)'
)
})