-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Description of the new feature/enhancement
In our current implementation, we use two different orderings for the color tables. The WT color table use ANSI order (i.e. black, red, green, yellow, blue...), while the conhost color table using a Windows order (i.e. black, blue, green, cyan, red...).
This means that the WT and conhost dispatchers have to use a different set of constants when processing ANSI SGR sequences, and conhost needs to transpose and indexed-colors with Xterm256ToWindowsIndex. Then when it comes to the conpty implementation, the VtRenderer has to go through the same process in reverse, translating the indexed colors from Windows order back to ANSI order.
Ideally the two color tables should be using the same order, so the two dispatchers can use the exact same code, and we will eventually be able to merge the two code bases (i.e. #3849). And I'm hoping this change might also enable us to merge and simplify parts of the renderer that are now handled separately in WT and conhost.
Proposed technical implementation details (optional)
The idea is that the translation will now need to happen when processing legacy color attributes that have come from the console APIs, or when returning legacy color attributes in console API queries. There will also be parts of conhost that need translation when initializing the color tables with legacy config, like the registry.
But the active color tables themselves will always be in ANSI order, and the TextColor values in the buffer will always use ANSI order. All VT sequences, and queries will get to pass through indexed values exactly as they are, without the need for translation.
The only downside I can see is that there could be a performance hit in legacy APIs that read or write a large series of attribute values, but I'm hoping that will be negligible. I've got a WIP of this change, but I haven't had a chance to do any performance testing yet.