What to build
The terminal buffer is append-only, so interactive CLIs (e.g. GitHub Copilot CLI) that redraw a line in place appear to "stack" a new line on every refresh instead of overwriting. Introduce a minimal cursor/line model so in-place redraws work end-to-end (parser → buffer → on-screen render):
- Interpret carriage return
\r as "move cursor to column 0 of the current line" (subsequent characters overwrite existing content on that line).
- Interpret erase-in-line
ESC [ K (and ESC [ 0/1/2 K) to clear from the cursor to end of line / start of line / whole line.
- Interpret erase-in-display
ESC [ 2 J and cursor-home ESC [ H to clear/reset the screen.
- Interpret basic cursor-column positioning (
ESC [ <n> G) and cursor left/right (ESC [ <n> C/D) enough to keep redraws aligned.
This introduces the cursor-position state that issue for the blinking cursor depends on. Keep the existing backspace/DEL and SGR behavior intact.
Acceptance criteria
Blocked by
None - can start immediately
What to build
The terminal buffer is append-only, so interactive CLIs (e.g. GitHub Copilot CLI) that redraw a line in place appear to "stack" a new line on every refresh instead of overwriting. Introduce a minimal cursor/line model so in-place redraws work end-to-end (parser → buffer → on-screen render):
\ras "move cursor to column 0 of the current line" (subsequent characters overwrite existing content on that line).ESC [ K(andESC [ 0/1/2 K) to clear from the cursor to end of line / start of line / whole line.ESC [ 2 Jand cursor-homeESC [ Hto clear/reset the screen.ESC [ <n> G) and cursor left/right (ESC [ <n> C/D) enough to keep redraws aligned.This introduces the cursor-position state that issue for the blinking cursor depends on. Keep the existing backspace/DEL and SGR behavior intact.
Acceptance criteria
abc\rXrenders asXbc(CR overwrites from column 0), notabcon one line andXon the nextfoobar\rfoo ESC[Kerases the tail, leavingfooESC[K) updates in place and does not add new linesESC[2J/ESC[Hclear/reset the visible bufferESC[Kvariants, and in-place redraw./run-tests.shpassesBlocked by
None - can start immediately