[PR #7148] Render the SGR "underlined" attribute in the style of the font #26850

Open
opened 2026-01-31 09:18:30 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/7148

State: closed
Merged: Yes


This PR updates the rendering of the underlined graphic rendition
attribute, using the style specified in the active font, instead of just
reusing the grid line at the bottom of the character cell.

  • Support for drawing the correct underline effect in the grid line
    renderer was added in #7107.

There was already an ExtendedAttributes flag defined for the
underlined state, but I needed to update the SetUnderlined and
IsUnderlined methods in the TextAttribute class to use that flag
now in place of the legacy LVB_UNDERSCORE attribute. This enables
underlines set via a VT sequence to be tracked separately from
LVB_UNDERSCORE grid lines set via the console API.

I then needed to update the Renderer::s_GetGridlines method to
activate the GridLines::Underline style when the Underlined
attribute was set. The GridLines::Bottom style is still triggered by
the LVB_UNDERSCORE attribute to produce the bottom grid line effect.

Validation

Because this is a change from the existing behaviour, certain unit tests
that were expecting the LVB_UNDERSCORE to be toggled by SGR 4 and
SGR 24 have now had to be updated to check the Underlined flag
instead.

There were also some UI Automation tests that were checking for SGR 4
mapping to LVB_UNDERSCORE attribute, which I've now substituted with a
test of the SGR 53 overline attribute mapping to
LVB_GRID_HORIZONTAL. These tests only work with legacy attributes, so
they can't access the extended underline state, and I thought a
replacement test that covered similar ground would be better than
dropping the tests altogether.

As far as the visual rendering is concerned, I've manually confirmed
that the VT underline sequences now draw the underline in the correct
position and style, while grid lines output via the console API are
still displayed in their original form.

Closes #2915

**Original Pull Request:** https://github.com/microsoft/terminal/pull/7148 **State:** closed **Merged:** Yes --- This PR updates the rendering of the _underlined_ graphic rendition attribute, using the style specified in the active font, instead of just reusing the grid line at the bottom of the character cell. * Support for drawing the correct underline effect in the grid line renderer was added in #7107. There was already an `ExtendedAttributes` flag defined for the underlined state, but I needed to update the `SetUnderlined` and `IsUnderlined` methods in the `TextAttribute` class to use that flag now in place of the legacy `LVB_UNDERSCORE` attribute. This enables underlines set via a VT sequence to be tracked separately from `LVB_UNDERSCORE` grid lines set via the console API. I then needed to update the `Renderer::s_GetGridlines` method to activate the `GridLines::Underline` style when the `Underlined` attribute was set. The `GridLines::Bottom` style is still triggered by the `LVB_UNDERSCORE` attribute to produce the bottom grid line effect. Validation ---------- Because this is a change from the existing behaviour, certain unit tests that were expecting the `LVB_UNDERSCORE` to be toggled by `SGR 4` and `SGR 24` have now had to be updated to check the `Underlined` flag instead. There were also some UI Automation tests that were checking for `SGR 4` mapping to `LVB_UNDERSCORE` attribute, which I've now substituted with a test of the `SGR 53` overline attribute mapping to `LVB_GRID_HORIZONTAL`. These tests only work with legacy attributes, so they can't access the extended underline state, and I thought a replacement test that covered similar ground would be better than dropping the tests altogether. As far as the visual rendering is concerned, I've manually confirmed that the VT underline sequences now draw the underline in the correct position and style, while grid lines output via the console API are still displayed in their original form. Closes #2915
claunia added the pull-request label 2026-01-31 09:18:30 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26850