Skip to content

feat(terminal): add SGR double underline (attribute 21)#69

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

feat(terminal): add SGR double underline (attribute 21)#69
roramirez wants to merge 1 commit into
mainfrom
feat/sgr-double-underline

Conversation

@roramirez

Copy link
Copy Markdown
Owner

Summary

Implements the SGR double underline attribute (ESC[21m): a double line drawn under the cell. ESC[24m (not underlined) clears both single and double underline, matching xterm/VTE. neovim and helix use double underline as one of their diagnostic underlines. Follows the existing SGR attribute pattern (tracked on the pen, stamped per cell, reset by SGR 0/24, preserved across DECSC/DECRC and the alternate screen).

Changes

  • src/terminal/grid.rs: add double_underline 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 arm 21 (on); extend arm 24 to clear both single and double underline. Also collapse the DECSET/DECRST (h/l) arms of handle_dec_private_modes into ('h' | 'l', …) patterns.
  • src/renderer/text.rs: draw the double underline as two draw_clipped_hline calls; factor the underline/double-underline/strikethrough hlines through a small local closure to remove the repeated argument lists.
  • Tests: parser tests for stamping, SGR 24 clearing both, and SGR 0 reset; a render smoke test in text_test.rs.
  • CHANGELOG.md: entry under [Unreleased] / Added.

How to test

  • cargo test (see sgr_double_underline_* / sgr_24_clears_single_and_double_underline in parser_test.rs).
  • In a running mmterm session: printf '\033[21mword\033[0m\n' shows word with a double underline.

Checks

  • cargo fmt
  • cargo clippy --locked -- -D warnings
  • cargo test (1212 passed)
  • [~] km score --trend origin/main --fail-if-worse — grade B+ (passes .kimun.toml fail_below = B); trend -0.02 at the Halstead rounding floor from the new attribute identifier repeated across the redundant SGR pen storage (Cell/Grid/SavedCursor/SavedScreen). Net LOC is negative after factoring the decoration hlines through a closure; keeping the attribute in the Saved* structs is deliberate (consistency with the other attributes).
  • CHANGELOG.md updated

Track a per-cell double-underline flag alongside the other SGR
attributes and draw it as two horizontal lines below the cell. SGR 24
now clears both single and double underline. Preserved across
DECSC/DECRC and the alternate screen like the other attributes.

Factor the decoration hlines through a small local closure and collapse
the DECSET/DECRST arms of handle_dec_private_modes into `h | l`
patterns while in the files.
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