fn strip_ansi(chunk: &mut Vec<u8>)Expand description
Phase β (lite): strip ANSI control sequences from a PTY chunk so the overlay’s plain-text ChunkList doesn’t render them as garbled literal characters.
Three families to handle (everything bash emits during init and most programs emit during normal output):
-
CSI sequences —
ESC [ <params> <final>where params are0x30..=0x3F(digits,;,?, etc.) and final is0x40..=0x7E(letters + punctuation). Covers\x1b[m(reset),\x1b[?25h/l(cursor visibility), color codes, cursor moves. -
OSC sequences —
ESC ] <text> BEL(orESC ] <text> ESC \). Covers\x1b]0;<title>\x07(set window title — emitted by Git Bash on every command). -
Lone control chars —
\r(carriage return without newline),\x07(bell),\x08(backspace). CRLF → LF for the chunk list. Lone\rpasses through socollapse_crcan operate on thependingbuffer across PTY reads (see below).
Things we DON’T handle yet (Phase γ territory):
- Alt-screen apps (
\x1b[?1049h) — left in the stream. - Cursor positioning escapes within the same line.
- OSC 633 (shell integration markers).