Repository navigation
feat: draw on the terminal's own background - #13
Merged
Merged
Conversation
Merged
github-merge-queue Bot
pushed a commit
to plannotator/plannotator-tui
that referenced
this pull request
Nov 23, 2026
…the terminal background (#186) * feat(review): tick viewed files in the file list The diff viewer's file list now shows a tick after a viewed file's counts and dims its row; a folder gets the tick once every file in it is viewed, also when collapsed. It uses diffs-rs `Engine::set_file_marks`, synced on open, on every toggle, when files arrive and on reload. Not mergeable yet: `set_file_marks` is not in a diffs-rs release. The root Cargo.toml patches diffs-rs to a commit of plannotator/diffs-rs feat/file-badges. Once diffs-rs 0.2.1 is published: delete the [patch.crates-io] section, require diffs-rs = "0.2.1" in crates/plannotator-tui/Cargo.toml, and run `cargo update -p diffs-rs`. * feat(review): draw the code review on the terminal's own background The diff viewer now leaves empty rows, plain context lines and its file list to the terminal's background and plain text to its foreground, as the document screen does. Changed lines and hunk headings keep tints from the light or dark palette that the theme setting picks. Uses diffs-rs `Engine::set_terminal_background`. Not mergeable yet: needs plannotator/diffs-rs#13 and a diffs-rs release. The root Cargo.toml patches diffs-rs to that PR's commit; once 0.2.1 is published, delete the [patch.crates-io] section, require diffs-rs = "0.2.1", and run `cargo update -p diffs-rs`. If the whole-file view (#172) lands first, its second engine needs the same call. * build: diffs-rs 0.2.1 from crates.io; the whole-file view on the terminal background too The [patch.crates-io] pointer to a diffs-rs commit is gone: 0.2.1 has Engine::set_file_marks and Engine::set_terminal_background. The whole-file view (o, O) opens a second engine; it now draws on the terminal's background as the diff does. Tests cover that, the light palette, and the file list's ticks through x in the whole-file view, ctrl+n, the rail hidden and shown, a change on disk, a reload that drops a changed file's mark, and a PR review's own marks.
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.
This adds a host option to draw the diff on the terminal's own background and text color, so plannotator-tui's code review matches its Markdown screen. Today diffs-rs paints its whole rectangle with the theme's #0a0a0a (or #ffffff in the light theme).
API
It is off by default, so hosts that do not call it and the
diffsviewer do not change. It can be set before files arrive, stays set acrossreplace(), and follows thettheme toggle. I made it a method rather than anOptionsfield: a new field breaks hosts that buildOptionswithout..Options::default(), as the 0.2.0 changelog notes. As a method it is additive and fits 0.2.1. The CHANGELOG entry is under "0.2.1 - Unreleased", and docs/embedding.md has a new "Terminal background" section.What changes when it is on
Color::Resetas background: empty rows, plain context lines, gaps, metadata and "no newline" rows, file headers, the Files sidebar, and with chrome the label row, footer and help.Options::appearance: added and deleted lines, changed words, hunk headers, the empty half of a split row, and the Files keyboard cursor row. The host picks the appearance that matches its terminal.The terminal's real background is unknown, so the explicit colors are derived differently in this mode:
On a dark terminal the tints now start from a slightly lighter base (#0a0a0a mixed 6% toward the text color). They read on black, #1e1e1e and a blue-grey #1e2230 alike, instead of looking like dark holes on lighter backgrounds. The light hunk header was almost invisible on an off-white terminal, so it is mixed more strongly.
The Files cursor row normally uses the context color. In this mode that color is the terminal's own background, so the cursor row uses the hunk header color instead.
theme::Colorsgains no field.Tests
replace().Checks run locally
cargo fmt --checkcargo clippy --locked --all-targets -- -D warnings, and the same with--all-featurescargo test --release --locked --no-fail-fast -- --test-threads=1cargo +1.88.0 check --locked --all-targetsRUSTDOCFLAGS="-D warnings" cargo doc --no-depsI also ran plannotator-tui with the option on, on a dark (#1e2230) and a light (#fafafa) page, and compared it with the screen before the change. That host branch is local only.