-
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
Fix SGR indexed colors to distinguish Indexed256 color (and more) #5834
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d5aabb4
Distinguish between indexed colors from the 16 color palette (which c…
j4james 414c727
Make the terminal dispatcher use the 256 color index format for SGR 3…
j4james 6ca9015
Update unit tests to account for the updated index color formats.
j4james 1814a58
Avoid directly copying the color table with memmove.
j4james c06c575
Remove some unnecessary functions that made the code harder to follow.
j4james a4c23a6
Combine the 16 and 256 color tables, and use string_views when passin…
j4james f321051
Make the conhost dispatcher use the 256 color index format for SGR 38…
j4james 020b0d1
Update unit tests to account for the corrected interpretation of inde…
j4james beeb0c9
Make the GraphicsSingleTests clearer by explicitly initialising the e…
j4james File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concerned about the difference between console color and ANSI color indices; also, should this be
false
since the console 16 are equivalent to the ANSI 16?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Right now, I believe (?) a round trip from legacy attribute to TextAttribute back to legacy attribute will fail because of the brighten check on line R67.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possibly debatable whether legacy colors should map to Index16 or Index256, but see the PR description for my reasoning behind the decision. Legacy roundtrips are never going to be perfect once you mix them with VT attributes, but if you're sticking to console APIs, they should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think I understand. We store INTENSITY in the meta field, and it’ll come back out during ReadConsoleOutput or GetConsoleTextAttribute, but GetLegacyAttributes will not explicitly set it or clear it. That might be worth a comment- what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(How does this comport with BACKGROUND_INTENSITY, and its potential impact on whether conpty should generate 10x or 40x? Am I mixing concerns here and worrying about the wrong thing?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the
INTENSITY
bit of legacy colors is not stored as a meta attribute, it's just one of the 4 bits making up the index value. There is a bold extended attribute, but that it not set by legacy colors, and has no effect on their rendering. TheFOREGROUND_INTENSITY
that you see being added in theGetLegacyAttributes
method is just to handle the conversion of VT ANSI colors (which can be brightened), to an equivalent legacy value.As for the conpty rendering, under these rules legacy colors would almost always be rendered with ISO/ITU sequences. Remember they're stored with the
IsIndex256
type. The only time we'd map them to SGR 3x/4x sequences is if we were using one of the 16-color renderers that didn't have any other option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, thanks for the reminder about the intensity bit being on the color. That all makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just rereading what I wrote here, I should clarify that I'm talking about the future version of the vtengine that I'm working on for issue #2661. The current vtengine doesn't yet take these index types into account.