Simplify the color palette APIs #15893

Closed
opened 2026-01-31 04:51:29 +00:00 by claunia · 1 comment
Owner

Originally created by @j4james on GitHub (Nov 16, 2021).

Description of the new feature/enhancement

At the moment, the ConGetSet and ITerminalApi interfaces have a bunch of different methods for setting color palette entries. There's a SetColorTableEntry, a SetCursorColor, a SetDefaultForeground, and a SetDefaultBackground. If we want to support the OSC color queries (#3718), we're going to need to add equivalent getter methods for each of these colors. And at some point we'll probably want add support for things like the selection colors, and bold color (#5682), each of which will also require setter and getter methods.

My proposal is we simplify this to just two methods: SetColorTableEntry and GetColorTableEntry, which can then be used to access any of the configurable color values, and not just the 256-color table.

Proposed technical implementation details (optional)

The way this would work, is we'd extend the 256-color table with additional entries on the end for the special colors, and define a few constants to reference those entries.

So instead of calling a unique method like SetDefaultForeground(color), you'd just be doing something like SetColorTableEntry(TextColor::DEFAULT_FOREGROUJD, color).

One of the advantages of this approach, is that it simplifies the interpretation of the default colors in conhost. Right now a default color can either be an index in the color table, or a completely separate value. With this new approach it'll always be somewhere in the color table - you just need to store the actual index.

And note that support for index-based default colors is something that we'll need for VT525 emulation at some point, so in the long term it won't just be a conhost thing.

I also have a sneaking suspicion that this might help us get rid of the PowerShell color quirk (#6807), or at least simplify it, but I can't promise that.

Originally created by @j4james on GitHub (Nov 16, 2021). # Description of the new feature/enhancement At the moment, the `ConGetSet` and `ITerminalApi` interfaces have a bunch of different methods for setting color palette entries. There's a `SetColorTableEntry`, a `SetCursorColor`, a `SetDefaultForeground`, and a `SetDefaultBackground`. If we want to support the OSC color queries (#3718), we're going to need to add equivalent getter methods for each of these colors. And at some point we'll probably want add support for things like the selection colors, and bold color (#5682), each of which will also require setter and getter methods. My proposal is we simplify this to just two methods: `SetColorTableEntry` and `GetColorTableEntry`, which can then be used to access any of the configurable color values, and not just the 256-color table. # Proposed technical implementation details (optional) The way this would work, is we'd extend the 256-color table with additional entries on the end for the special colors, and define a few constants to reference those entries. So instead of calling a unique method like `SetDefaultForeground(color)`, you'd just be doing something like `SetColorTableEntry(TextColor::DEFAULT_FOREGROUJD, color)`. One of the advantages of this approach, is that it simplifies the interpretation of the default colors in conhost. Right now a default color can either be an index in the color table, or a completely separate value. With this new approach it'll always be somewhere in the color table - you just need to store the actual index. And note that support for index-based default colors is something that we'll need for VT525 emulation at some point, so in the long term it won't just be a conhost thing. I also have a sneaking suspicion that this might help us get rid of the PowerShell color quirk (#6807), or at least simplify it, but I can't promise that.
Author
Owner

@ghost commented on GitHub (Feb 3, 2022):

:tada:This issue was addressed in #11784, which has now been successfully released as Windows Terminal Preview v1.13.10336.0.🎉

Handy links:

@ghost commented on GitHub (Feb 3, 2022): :tada:This issue was addressed in #11784, which has now been successfully released as `Windows Terminal Preview v1.13.10336.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.13.10336.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15893