[PR #11784] [MERGED] Consolidate the color palette APIs #28728

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11784
Author: @j4james
Created: 11/18/2021
Status: Merged
Merged: 11/23/2021
Merged by: @undefined

Base: mainHead: consolidate-palette-apis


📝 Commits (8)

  • 79859cf Merge default colors into color table.
  • 05e20f6 Eliminate default color APIs in ConGetSet and ITerminalApi.
  • a8bad33 Standardize color table APIs in ConGetSet and ITerminalApi.
  • 96dd85f Use index values when referring to default colors.
  • 6ebcb5e Cache the calculation of default color indices.
  • 7004ba7 Merge cursor color into color table.
  • a1e98f5 Simplify registry queries for special colors.
  • 69f2b4f Silence the spelling bot.

📊 Changes

43 files changed (+351 additions, -647 deletions)

View changed files

📝 .github/actions/spelling/allow/apis.txt (+1 -0)
📝 src/buffer/out/TextAttribute.cpp (+7 -7)
📝 src/buffer/out/TextAttribute.hpp (+3 -3)
📝 src/buffer/out/TextColor.cpp (+4 -2)
📝 src/buffer/out/TextColor.h (+6 -1)
📝 src/buffer/out/cursor.cpp (+2 -21)
📝 src/buffer/out/cursor.h (+1 -7)
📝 src/buffer/out/ut_textbuffer/TextAttributeTests.cpp (+51 -47)
📝 src/buffer/out/ut_textbuffer/TextColorTests.cpp (+39 -35)
📝 src/cascadia/PublicTerminalCore/HwndTerminal.cpp (+4 -4)
📝 src/cascadia/TerminalControl/ControlCore.cpp (+1 -1)
📝 src/cascadia/TerminalCore/ITerminalApi.hpp (+2 -5)
📝 src/cascadia/TerminalCore/Terminal.cpp (+12 -8)
📝 src/cascadia/TerminalCore/Terminal.hpp (+2 -7)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+21 -48)
📝 src/cascadia/TerminalCore/TerminalDispatch.cpp (+3 -3)
📝 src/cascadia/TerminalCore/terminalrenderdata.cpp (+7 -7)
📝 src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+3 -2)
📝 src/cascadia/UnitTests_TerminalCore/TerminalApiTest.cpp (+0 -1)
📝 src/host/consoleInformation.cpp (+2 -46)

...and 23 more files

📄 Description

This PR merges the default colors and cursor color into the main color
table, enabling us to simplify the ConGetSet and ITerminalApi
interfaces, with just two methods required for getting and setting any
form of color palette entry.

The is a follow-up to the color table standardization in #11602, and a
another small step towards de-duplicating AdaptDispatch and
TerminalDispatch for issue #3849. It should also make it easier to
support color queries (#3718) and a configurable bold color (#5682) in
the future.

On the conhost side, default colors could originally be either indexed
positions in the 16-color table, or separate standalone RGB values. With
the new system, the default colors will always be in the color table, so
we just need to track their index positions.

To make this work, those positions need to be calculated at startup
based on the loaded registry/shortcut settings, and updated when
settings are changed (this is handled in
CalculateDefaultColorIndices). But the plus side is that it's now much
easier to lookup the default color values for rendering.

For now the default colors in Windows Terminal use hardcoded positions,
because it doesn't need indexed default colors like conhost. But in the
future I'd like to extend the index handling to both terminals, so we
can eventually support the VT525 indexed color operations.

As for the cursor color, that was previously stored in the Cursor
class, which meant that it needed to be copied around in various places
where cursors were being instantiated. Now that it's managed separately
in the color table, a lot of that code is no longer required.

Validation

Some of the unit test initialization code needed to be updated to setup
the color table and default index values as required for the new system.
There were also some adjustments needed to account for API changes, in
particular for methods that now take index values for the default colors
in place of COLORREFs. But for the most part, the essential behavior of
the tests remains unchanged.

I've also run a variety of manual tests looking at the legacy console
APIs as well as the various VT color sequences, and checking that
everything works as expected when color schemes are changed, both in
Windows Terminal and conhost, and in the latter case with both indexed
colors and RGB values.

Closes #11768


🔄 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/11784 **Author:** [@j4james](https://github.com/j4james) **Created:** 11/18/2021 **Status:** ✅ Merged **Merged:** 11/23/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `consolidate-palette-apis` --- ### 📝 Commits (8) - [`79859cf`](https://github.com/microsoft/terminal/commit/79859cff84b84565ff3f3f6f7679eae70951f0da) Merge default colors into color table. - [`05e20f6`](https://github.com/microsoft/terminal/commit/05e20f6ebc9f9a81812d5fb2fdaa7810d6794371) Eliminate default color APIs in ConGetSet and ITerminalApi. - [`a8bad33`](https://github.com/microsoft/terminal/commit/a8bad338a157ecf6a2f5e39d5cc4ec84d4ae42de) Standardize color table APIs in ConGetSet and ITerminalApi. - [`96dd85f`](https://github.com/microsoft/terminal/commit/96dd85fd7274eaf53dc5c9011d28039881fd05e5) Use index values when referring to default colors. - [`6ebcb5e`](https://github.com/microsoft/terminal/commit/6ebcb5eaedb1bc86c51be74f67f32014f1998f57) Cache the calculation of default color indices. - [`7004ba7`](https://github.com/microsoft/terminal/commit/7004ba73db8360c213645a00aad5e5723c77a15f) Merge cursor color into color table. - [`a1e98f5`](https://github.com/microsoft/terminal/commit/a1e98f56bc0664239460ecefe04379d98019b1df) Simplify registry queries for special colors. - [`69f2b4f`](https://github.com/microsoft/terminal/commit/69f2b4f3a1fa281b7eddeb8ca23a874e98263784) Silence the spelling bot. ### 📊 Changes **43 files changed** (+351 additions, -647 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/apis.txt` (+1 -0) 📝 `src/buffer/out/TextAttribute.cpp` (+7 -7) 📝 `src/buffer/out/TextAttribute.hpp` (+3 -3) 📝 `src/buffer/out/TextColor.cpp` (+4 -2) 📝 `src/buffer/out/TextColor.h` (+6 -1) 📝 `src/buffer/out/cursor.cpp` (+2 -21) 📝 `src/buffer/out/cursor.h` (+1 -7) 📝 `src/buffer/out/ut_textbuffer/TextAttributeTests.cpp` (+51 -47) 📝 `src/buffer/out/ut_textbuffer/TextColorTests.cpp` (+39 -35) 📝 `src/cascadia/PublicTerminalCore/HwndTerminal.cpp` (+4 -4) 📝 `src/cascadia/TerminalControl/ControlCore.cpp` (+1 -1) 📝 `src/cascadia/TerminalCore/ITerminalApi.hpp` (+2 -5) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+12 -8) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+2 -7) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+21 -48) 📝 `src/cascadia/TerminalCore/TerminalDispatch.cpp` (+3 -3) 📝 `src/cascadia/TerminalCore/terminalrenderdata.cpp` (+7 -7) 📝 `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+3 -2) 📝 `src/cascadia/UnitTests_TerminalCore/TerminalApiTest.cpp` (+0 -1) 📝 `src/host/consoleInformation.cpp` (+2 -46) _...and 23 more files_ </details> ### 📄 Description This PR merges the default colors and cursor color into the main color table, enabling us to simplify the `ConGetSet` and `ITerminalApi` interfaces, with just two methods required for getting and setting any form of color palette entry. The is a follow-up to the color table standardization in #11602, and a another small step towards de-duplicating `AdaptDispatch` and `TerminalDispatch` for issue #3849. It should also make it easier to support color queries (#3718) and a configurable bold color (#5682) in the future. On the conhost side, default colors could originally be either indexed positions in the 16-color table, or separate standalone RGB values. With the new system, the default colors will always be in the color table, so we just need to track their index positions. To make this work, those positions need to be calculated at startup based on the loaded registry/shortcut settings, and updated when settings are changed (this is handled in `CalculateDefaultColorIndices`). But the plus side is that it's now much easier to lookup the default color values for rendering. For now the default colors in Windows Terminal use hardcoded positions, because it doesn't need indexed default colors like conhost. But in the future I'd like to extend the index handling to both terminals, so we can eventually support the VT525 indexed color operations. As for the cursor color, that was previously stored in the `Cursor` class, which meant that it needed to be copied around in various places where cursors were being instantiated. Now that it's managed separately in the color table, a lot of that code is no longer required. ## Validation Some of the unit test initialization code needed to be updated to setup the color table and default index values as required for the new system. There were also some adjustments needed to account for API changes, in particular for methods that now take index values for the default colors in place of COLORREFs. But for the most part, the essential behavior of the tests remains unchanged. I've also run a variety of manual tests looking at the legacy console APIs as well as the various VT color sequences, and checking that everything works as expected when color schemes are changed, both in Windows Terminal and conhost, and in the latter case with both indexed colors and RGB values. Closes #11768 --- <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:30:24 +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#28728