-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colors palette changes using SetConsoleScreenBufferInfoEx should trigger equivalent OSC 4 sequences #7888
Comments
Note it seems doing this could also fix #399, as the legacy console properly refreshes its whole client area when the background color gets changed through OSC 4. |
Isn't this just a duplicate of #2985? |
Ah, sorry, didn't spot that one when looking for existing colors issues. Indeed, it is the same core issue, we need to propagate palette changes with OSC 4 to fix this and hopefully #399 as well. |
#399 is a conhost bug though. It's got nothing to do with conpty. I've actually hacked together fixes for both of these issues in the past, just as a proof of concept. Fixing them properly is more complicated though, which is why I never got around to submitting PRs. |
Could be, as the console definitely should refresh its whole client area when the colors are changed, however, it seems it does it properly when an OSC 4 command is processed, so it finally updates on that second pass. |
Thanks all! /dup #2985 |
Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! |
Win32 CUI apps typically use SetConsoleScreenBufferInfoEx to change the 16 colors palette used by the console.
Now that conhost can be used to connect these apps to a terminal, as much as possible of the original Console API needs to get translated to VT control sequences.
In the current implementation, conhost records the palette changes, as GetConsoleScreenBufferInfoEx will show the colors have been updated, but it will be kept purely as an internal state and the connected terminal app will not change its colors palette.
For Win32 CUI apps that change their colors to work properly with terminals, for any color that has been changed in the CONSOLE_SCREEN_BUFFER_INFOEX structure, we need conhost to generate and send the equivalent inband OSC 4 control sequences (ESC ] 4) to the terminal app.
(https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#screen-colors)
The following screenshot shows before and after changing the console colors, note how the right shows the new palette as it requests the actual conhost values through API and shows them using RGB/24-bit colors control sequences, while the colors wheel isn't updated because it uses 16-colors control sequences relying on the terminal's colors palette.
Same after a function has been used to get the console colors and generate and send equivalent OSC 4 control sequences.
My applyConsoleColorsToTerminal function is a workaround that simply gets the 16 colors using GetConsoleScreenBufferInfoEx and generates the 16 equivalent OSC 4 sequences to apply them to the attached terminal.
The text was updated successfully, but these errors were encountered: