Add ANSI-aware terminal screen overlays#31
Merged
Conversation
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
Rendered terminal UIs in msgvault and kata need the same cell-aware splicing mechanics. Keeping private copies risks corrupting escape sequences and lets clipping behavior diverge, while taking a Bubble Tea or lipgloss dependency would make kit's reusable layer framework-specific. An app-neutral tui/screen package gives callers one defined coordinate and clipping model for already-rendered views. Using the established ANSI parser also keeps grapheme width and control-sequence handling aligned across consumers, with malformed-input and stateful-control limitations documented for future callers. Generated with Codex Co-authored-by: Codex <noreply@openai.com>
Screen coordinates are defined in terminal cells, but suffix cuts inside a two-cell grapheme consumed the full glyph without retaining the overshoot. That shifted remaining background or panel content left and broke clipping guarantees for CJK characters and emoji. Carry the actual skipped width through internal splice paths so omitted half-cells become blanks at either boundary. The package contract now also requires per-line ANSI state balance and makes side-effecting control replay an explicit caller responsibility. Generated with Codex Co-authored-by: Codex <noreply@openai.com>
Cell-preserving cuts replace an unrenderable half of a wide grapheme with a blank. Emitting that blank outside the carried SGR state left a visible hole whenever the glyph used a terminal background color. Separate carried and trailing controls from printable suffix and prefix content so compensating cells are written after state replay but before its closing controls. This keeps both coordinates and styling intact across left, right, replacement, and viewport cuts without changing the public API. Generated with Codex Co-authored-by: Codex <noreply@openai.com>
b479006 to
ea00980
Compare
roborev: Combined Review (
|
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.
Why
msgvault and kata both need to splice modal and positioned panels into already-rendered terminal views. Keeping separate private implementations makes ANSI corruption, wide-grapheme bugs, and inconsistent offscreen behavior likely as the callers evolve. Pulling in Bubble Tea or lipgloss at the shared layer would also make otherwise reusable mechanics depend on a specific UI framework.
Design context
The new tui/screen subpackage gives rendered-string callers one zero-based coordinate and clipping model while preserving tui as a namespace for related shared work. It deliberately uses the established charmbracelet ANSI parser instead of a CSI/OSC-only parser so grapheme width and complete control-sequence handling remain consistent with both consumers. The package documentation calls out malformed input and stateful cursor-control limitations.
Validation
generated by a clanker