Skip to content

feat(terminal): add SGR conceal (attribute 8, reset 28)#68

Draft
roramirez wants to merge 1 commit into
mainfrom
feat/sgr-conceal
Draft

feat(terminal): add SGR conceal (attribute 8, reset 28)#68
roramirez wants to merge 1 commit into
mainfrom
feat/sgr-conceal

Conversation

@roramirez

Copy link
Copy Markdown
Owner

Summary

Implements the SGR conceal attribute (ESC[8m, reset ESC[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: add conceal to Cell, the Grid SGR pen, SavedCursor, SavedScreen, and every default/stamp/reset/save/restore site (mirrors the blink attribute).
  • src/terminal/parser.rs: handle_sgr arms 8 (conceal on) and 28 (conceal off). Also collapse the DECSET/DECRST (h/l) arms of handle_dec_private_modes into ('h' | 'l', …) patterns (same behavior, fewer lines).
  • src/renderer/draw_fns.rs: in resolve_cell_colors, paint the glyph in the background color when cell.conceal — this also hides decorations, which derive from the resolved fg.
  • Tests: parser tests for stamping/reset; a resolve_cell_colors unit test in text_test.rs.
  • CHANGELOG.md: entry under [Unreleased] / Added.

How to test

  • cargo test (see sgr_conceal_* in parser_test.rs and resolve_cell_colors_conceal_paints_fg_as_bg in text_test.rs).
  • In a running mmterm session: printf '\033[8mSECRET\033[0m\n' shows nothing (text painted in the background color); selecting it still copies SECRET.

Checks

  • cargo fmt
  • cargo clippy --locked -- -D warnings
  • cargo test (1211 passed)
  • [~] km score --trend origin/main --fail-if-worse — grade B+ (passes .kimun.toml fail_below = B); trend -0.02 on File Size. The codebase stores the SGR pen redundantly across Cell/Grid/SavedCursor/SavedScreen, so adding one attribute consistently costs ~13 lines in grid.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.
  • CHANGELOG.md updated

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant