feat(terminal): add SGR conceal (attribute 8, reset 28)#68
Draft
roramirez wants to merge 1 commit into
Draft
Conversation
Track a per-cell conceal flag alongside the other SGR attributes and paint concealed glyphs in the background color so they are hidden (used by password prompts). Reset by SGR 28 and SGR 0, and preserved across DECSC/DECRC and the alternate screen like the other attributes. Collapse the DECSET/DECRST arms of handle_dec_private_modes into `h | l` patterns while in the file.
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
Implements the SGR conceal attribute (
ESC[8m, resetESC[28m): concealed text is rendered in the background color so it is invisible. Used by password prompts and some TUIs. Follows the exact pattern of the existing SGR attributes (bold/dim/underline/…): tracked on the pen, stamped per cell, reset by SGR 0/28, and preserved across DECSC/DECRC and the alternate screen.Changes
src/terminal/grid.rs: addconcealtoCell, theGridSGR pen,SavedCursor,SavedScreen, and every default/stamp/reset/save/restore site (mirrors theblinkattribute).src/terminal/parser.rs:handle_sgrarms8(conceal on) and28(conceal off). Also collapse the DECSET/DECRST (h/l) arms ofhandle_dec_private_modesinto('h' | 'l', …)patterns (same behavior, fewer lines).src/renderer/draw_fns.rs: inresolve_cell_colors, paint the glyph in the background color whencell.conceal— this also hides decorations, which derive from the resolved fg.resolve_cell_colorsunit test intext_test.rs.CHANGELOG.md: entry under[Unreleased] / Added.How to test
cargo test(seesgr_conceal_*inparser_test.rsandresolve_cell_colors_conceal_paints_fg_as_bgintext_test.rs).printf '\033[8mSECRET\033[0m\n'shows nothing (text painted in the background color); selecting it still copiesSECRET.Checks
.kimun.tomlfail_below = B); trend -0.02 on File Size. The codebase stores the SGR pen redundantly acrossCell/Grid/SavedCursor/SavedScreen, so adding one attribute consistently costs ~13 lines ingrid.rs; offset as far as reasonable by simplifying the DEC private-mode setter. Keeping conceal in the Saved* structs is deliberate — dropping them to gain the 0.02 would make conceal the only attribute not preserved across DECSC/DECRC.