Support clearing scrollback#31
Open
donbeave wants to merge 1 commit into
Open
Conversation
Add Screen::clear_scrollback and handle CSI 3 J as xterm's erase saved lines sequence. This lets embedders clear scrollback through terminal semantics without resetting parser state. Co-authored-by: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds a narrow scrollback-clearing path to vt100:
Screen::clear_scrollback()clears the active screen's saved scrollback and returns the scrollback view to the live viewport.CSI 3 Jis handled as xterm's "erase saved lines" operation.I also included two small CI hygiene updates so this PR can run cleanly against the current workflow: the existing example loop is adjusted for current clippy, and the lockfile updates the dev-only
randentry from0.9.1to0.9.4to clear the current RustSec advisory reported bycargo deny.Motivation
vt100 already models the terminal screen, scrollback, and parser state for consumers building terminal wrappers/multiplexers. Those consumers need to distinguish "clear saved lines" from heavier reset-style behavior:
CSI 3 Jshould clear scrollback.That makes this fit vt100's existing responsibility better than forcing each downstream consumer to reach into local state or fake a terminal reset.
This is intentionally narrower than #22. That PR proposed broader scrollback inspection APIs. This PR only adds the missing clear operation and terminal escape handling, without exposing scrollback rows or internal row types.
Tests
Added coverage in
tests/scroll.rsfor:Screen::clear_scrollback()behavior;CSI 3 Jclearing saved lines;CSI 3 J;CSI 3 J.Local verification
cargo fmt --checkcargo testcargo clippy --all-targets -- -D warningscargo build --all-targetscargo doc --no-depsrustup run 1.70.0 cargo check --lib --all-featurescargo deny check