[PR #2917] Add support for passing through extended text attributes, like… #25147

Closed
opened 2026-01-31 09:07:34 +00:00 by claunia · 0 comments
Owner

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

State: closed
Merged: Yes


Summary of the Pull Request

Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does NOT add support for those styles to conhost or the terminal.

We will store these "Extended Text Attributes" in a TextAttribute. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a bool to a single bit in these flags.

Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.

References

See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.

PR Checklist

Validation Steps Performed

  • Replaced the conhost in my system32 and tried running the following script, via WSL interop:
import sys
import time # time.sleep is in seconds
def write(s):
    sys.stdout.write(s)

def csi(seq):
    sys.stdout.write('\x1b[{}'.format(seq))

def sgr(code=0):
    csi('{}m'.format(code))

def cupxy(x=0, y=0):
    cup(y+1, x+1)

def clear_all():
    cupxy(0,0)
    csi('2J')

# $ python ~/vttests/extended-attrs.py
if __name__ == '__main__':
    clear_all()
    print('This is the VT Test template.')

    sgr(0)
    write('[Normal Text]')
    sgr(3)
    write('[Italicized]')
    sgr(0)
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(4)
    write('[Underlined]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(4)
    write('[Underlined]')
    sgr(3)
    write('[U & I]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(4)
    write('[Underlined]')
    sgr(3)
    write('[U & I]')
    sgr(23)
    write('[Underlined]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(4)
    write('[Underlined]')
    sgr(3)
    write('[U & I]')
    sgr(24)
    write('[Italicized]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(5)
    write('[Blinking]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(8)
    write('[Invisible]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(9)
    write('[Crossed-out]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    ############################################################################


    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(3)
    write('[B & Italicized]')
    sgr(0)
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(4)
    write('[B & Underlined]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(4)
    write('[B & Underlined]')
    sgr(3)
    write('[B & U & I]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(4)
    write('[B & Underlined]')
    sgr(3)
    write('[U & I]')
    sgr(23)
    write('[B & Underlined]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(4)
    write('[B & Underlined]')
    sgr(3)
    write('[B & U & I]')
    sgr(24)
    write('[B & Italicized]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(5)
    write('[B & Blinking]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(8)
    write('[B & Invisible]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

    sgr(0)
    write('[Normal Text]')
    sgr(1)
    write('[Bold]')
    sgr(9)
    write('[B & Crossed-out]')
    sgr(0)
    write('[Normal Again]')
    write('\n')

  • ran tests
  • Using the (added) static assert, ensured that the size of the TextAttribute did not increase.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/2917 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal. We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags. Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however. ## References See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1. ## PR Checklist * [x] Closes #2554 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * Replaced the conhost in my system32 and tried running the following script, via WSL interop: <details> ```python import sys import time # time.sleep is in seconds def write(s): sys.stdout.write(s) def csi(seq): sys.stdout.write('\x1b[{}'.format(seq)) def sgr(code=0): csi('{}m'.format(code)) def cupxy(x=0, y=0): cup(y+1, x+1) def clear_all(): cupxy(0,0) csi('2J') # $ python ~/vttests/extended-attrs.py if __name__ == '__main__': clear_all() print('This is the VT Test template.') sgr(0) write('[Normal Text]') sgr(3) write('[Italicized]') sgr(0) write('\n') sgr(0) write('[Normal Text]') sgr(4) write('[Underlined]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(4) write('[Underlined]') sgr(3) write('[U & I]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(4) write('[Underlined]') sgr(3) write('[U & I]') sgr(23) write('[Underlined]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(4) write('[Underlined]') sgr(3) write('[U & I]') sgr(24) write('[Italicized]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(5) write('[Blinking]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(8) write('[Invisible]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(9) write('[Crossed-out]') sgr(0) write('[Normal Again]') write('\n') ############################################################################ sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(3) write('[B & Italicized]') sgr(0) write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(4) write('[B & Underlined]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(4) write('[B & Underlined]') sgr(3) write('[B & U & I]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(4) write('[B & Underlined]') sgr(3) write('[U & I]') sgr(23) write('[B & Underlined]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(4) write('[B & Underlined]') sgr(3) write('[B & U & I]') sgr(24) write('[B & Italicized]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(5) write('[B & Blinking]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(8) write('[B & Invisible]') sgr(0) write('[Normal Again]') write('\n') sgr(0) write('[Normal Text]') sgr(1) write('[Bold]') sgr(9) write('[B & Crossed-out]') sgr(0) write('[Normal Again]') write('\n') ``` </details> * ran tests * Using the (added) static assert, ensured that the size of the TextAttribute did not increase.
claunia added the pull-request label 2026-01-31 09:07:34 +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#25147