[PR #14036] [MERGED] Merge the legacy and extended attributes #29887

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14036
Author: @j4james
Created: 9/19/2022
Status: Merged
Merged: 9/20/2022
Merged by: @undefined

Base: mainHead: refactor-text-attributes


📝 Commits (1)

  • 3798c56 Merge the legacy and extended attributes.

📊 Changes

7 files changed (+85 additions, -99 deletions)

View changed files

📝 src/buffer/out/TextAttribute.cpp (+36 -46)
📝 src/buffer/out/TextAttribute.hpp (+14 -27)
📝 src/buffer/out/ut_textbuffer/TextAttributeTests.cpp (+1 -1)
📝 src/host/ut_host/ScreenBufferTests.cpp (+18 -18)
📝 src/inc/conattrs.hpp (+11 -2)
📝 src/renderer/vt/paint.cpp (+4 -4)
📝 src/terminal/adapter/adaptDispatchGraphics.cpp (+1 -1)

📄 Description

This PR attempts to simplify the TextAttribute class by merging the
two fields that were previously storing the "legacy" attributes and the
"extended" attributes separately.

When the TextAttribute class is initialized with a legacy value, we
were masking off the META_ATTRS bits to store in the _wAttrLegacy
field, and then additionally clearing the COMMON_LVB_SBCSDBCS bits,
so there were only 5 bits that were actually used in the end. We also
had an additional _extendedAttrs field holding other VT attributes,
which only used 8 of its available 16 bits.

In this PR I've now merged the the two sets of attributes into one enum,
so they all fit in a single 16-bit value. The legacy attributes retain
the same bit positions they originally had, so we can mask them off from
an incoming legacy value as we did before. I've just simplified the
process somewhat by creating a USED_META_ATTRS mask that covers the
exact subset of meta attributes that we care about.

The new enum that holds the combined attributes has now been named
CharacterAttributes rather than ExtendedAttributes, since that seems
to be the term typically used in VT documentation. This covers both
rendition/visual attributes and logical attributes (not yet used, but we
will need them at some point to support selective erase operations).

While making these changes I also noticed the IsLeadingByte and
IsTrailingByte methods weren't actually used anywhere, and weren't
correctly implemented anyway, so I've removed those now.

Validation Steps Performed

I've manually run a number of attribute test scripts which cover both
legacy and VT operations, and everything still appears to be working
correctly.

Closes #14031


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/14036 **Author:** [@j4james](https://github.com/j4james) **Created:** 9/19/2022 **Status:** ✅ Merged **Merged:** 9/20/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `refactor-text-attributes` --- ### 📝 Commits (1) - [`3798c56`](https://github.com/microsoft/terminal/commit/3798c56168a7b6c97c06b07798556ca4e8a1b416) Merge the legacy and extended attributes. ### 📊 Changes **7 files changed** (+85 additions, -99 deletions) <details> <summary>View changed files</summary> 📝 `src/buffer/out/TextAttribute.cpp` (+36 -46) 📝 `src/buffer/out/TextAttribute.hpp` (+14 -27) 📝 `src/buffer/out/ut_textbuffer/TextAttributeTests.cpp` (+1 -1) 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+18 -18) 📝 `src/inc/conattrs.hpp` (+11 -2) 📝 `src/renderer/vt/paint.cpp` (+4 -4) 📝 `src/terminal/adapter/adaptDispatchGraphics.cpp` (+1 -1) </details> ### 📄 Description This PR attempts to simplify the `TextAttribute` class by merging the two fields that were previously storing the "legacy" attributes and the "extended" attributes separately. When the `TextAttribute` class is initialized with a legacy value, we were masking off the `META_ATTRS` bits to store in the `_wAttrLegacy` field, and then additionally clearing the `COMMON_LVB_SBCSDBCS` bits, so there were only 5 bits that were actually used in the end. We also had an additional `_extendedAttrs` field holding other VT attributes, which only used 8 of its available 16 bits. In this PR I've now merged the the two sets of attributes into one enum, so they all fit in a single 16-bit value. The legacy attributes retain the same bit positions they originally had, so we can mask them off from an incoming legacy value as we did before. I've just simplified the process somewhat by creating a `USED_META_ATTRS` mask that covers the exact subset of meta attributes that we care about. The new enum that holds the combined attributes has now been named `CharacterAttributes` rather than `ExtendedAttributes`, since that seems to be the term typically used in VT documentation. This covers both rendition/visual attributes and logical attributes (not yet used, but we will need them at some point to support selective erase operations). While making these changes I also noticed the `IsLeadingByte` and `IsTrailingByte` methods weren't actually used anywhere, and weren't correctly implemented anyway, so I've removed those now. ## Validation Steps Performed I've manually run a number of attribute test scripts which cover both legacy and VT operations, and everything still appears to be working correctly. Closes #14031 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:37:27 +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#29887