|
| 1 | +# Display Erase Commands |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +Add root `Tty` command helpers for `CSI 2 J` and `CSI 3 J`, while keeping VT |
| 6 | +byte construction internal and avoiding any terminal screen or scrollback state |
| 7 | +model. |
| 8 | + |
| 9 | +## Status |
| 10 | + |
| 11 | +Done. |
| 12 | + |
| 13 | +## Context And Decisions |
| 14 | + |
| 15 | +- `CSI 2 J` is Erase in Display (ED) mode 2. It clears the visible display. |
| 16 | +- `CSI 3 J` is the common xterm extension for clearing saved lines or |
| 17 | + scrollback. |
| 18 | +- Avoid the name `erase_display_all` because it can imply that `CSI 2 J` also |
| 19 | + clears scrollback. |
| 20 | +- Use the shorter approved root method names: |
| 21 | + - `erase_display` |
| 22 | + - `erase_scrollback` |
| 23 | +- These are output-side commands only. Unsupported terminals may ignore |
| 24 | + `CSI 3 J`; no support query is added. |
| 25 | + |
| 26 | +## References Or Standards |
| 27 | + |
| 28 | +- ECMA-48 Erase in Display (ED), `CSI Ps J`. |
| 29 | +- xterm-compatible `CSI 3 J` saved-lines erase extension. |
| 30 | + |
| 31 | +## Target Files |
| 32 | + |
| 33 | +- `internal/vt/erase.mbt` |
| 34 | +- `internal/vt/erase_test.mbt` |
| 35 | +- `style.mbt` |
| 36 | +- `tty_wbtest.mbt` |
| 37 | +- `README.md` |
| 38 | +- `docs/plan.md` |
| 39 | +- generated `.mbti` files from `moon info` |
| 40 | + |
| 41 | +## Public API Changes |
| 42 | + |
| 43 | +Root package additions: |
| 44 | + |
| 45 | +- `Tty::erase_display(Self) -> Unit` |
| 46 | +- `Tty::erase_scrollback(Self) -> Unit` |
| 47 | + |
| 48 | +Internal VT package additions: |
| 49 | + |
| 50 | +- `erase_display : Bytes` |
| 51 | +- `erase_scrollback : Bytes` |
| 52 | + |
| 53 | +No new public type, parser state, input event, platform backend, dependency, or |
| 54 | +capability query is proposed. |
| 55 | + |
| 56 | +## Invariants |
| 57 | + |
| 58 | +- `Tty` remains the public output-command surface. |
| 59 | +- `internal/vt` remains byte-sequence-only and does not own output streams. |
| 60 | +- The package does not remember, infer, or expose terminal display state. |
| 61 | +- The package does not model or manage terminal scrollback. |
| 62 | + |
| 63 | +## Acceptance Criteria |
| 64 | + |
| 65 | +- Internal VT helpers emit `CSI 2 J` and `CSI 3 J`. |
| 66 | +- Root command helpers write the same bytes through `Tty`. |
| 67 | +- Generated `.mbti` diffs contain only the intended API additions. |
| 68 | +- README mentions display and scrollback erase as output commands. |
| 69 | + |
| 70 | +## Validation Commands |
| 71 | + |
| 72 | +- `moon fmt` |
| 73 | +- `moon test internal/vt` |
| 74 | +- `moon test .` |
| 75 | +- `moon check` |
| 76 | +- `moon info` |
| 77 | +- review generated `.mbti` diff |
| 78 | +- `git diff --check` |
| 79 | + |
| 80 | +## Public API Audit |
| 81 | + |
| 82 | +- Root `.mbti` adds only `Tty::erase_display` and |
| 83 | + `Tty::erase_scrollback`. |
| 84 | +- Internal VT `.mbti` adds only the `erase_display` and `erase_scrollback` |
| 85 | + byte constants used by root command methods. |
| 86 | +- No public type, mutable field, parser state, input event, platform handle, |
| 87 | + backend selection, dependency, or capability query was added. |
| 88 | +- Generated `.mbti` files were reviewed after `moon info`. |
| 89 | + |
| 90 | +## Result Notes |
| 91 | + |
| 92 | +- Added fixed ED byte constants for `CSI 2 J` and `CSI 3 J`. |
| 93 | +- Added root write-through helpers on `Tty`. |
| 94 | +- Added internal VT byte tests and extended the root pipe-backed terminal |
| 95 | + command test to cover both new methods. |
| 96 | +- Updated README output-command wording and the execution board. |
| 97 | +- Real terminal clear behavior needs a terminal emulator with observable screen |
| 98 | + state; pipe and PTY tests only verify byte traffic. No terminal-emulator |
| 99 | + integration test was added for this task. |
| 100 | + |
| 101 | +## Validation Results |
| 102 | + |
| 103 | +- `moon fmt` passed. |
| 104 | +- `moon test internal/vt` passed: 18 tests. |
| 105 | +- `moon test .` passed: 24 tests. |
| 106 | +- `moon test` passed: 146 tests. |
| 107 | +- `moon check` passed. |
| 108 | +- `moon info` passed and regenerated intended `.mbti` entries. |
| 109 | +- generated `.mbti` diff reviewed. |
| 110 | +- `git diff --check` passed. |
| 111 | + |
| 112 | +## Open Questions |
| 113 | + |
| 114 | +- None. |
0 commit comments