-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Restore the DECCTR color table report over conpty #13227
Conversation
I hope we can replace the character-wise parsing with |
@lhecker I'm not sure I understand exactly what you're proposing, but I definitely agree that the current architecture isn't optimal, so I'd be happy to see improvements there. I suspect it might require a major rewrite of the |
It's just that I saw this line: return [&, buffer = std::wstring{}](const auto ch) mutable { and it reminded me how we're currently limited to character-wise parsing. |
Unfortunately it's a little more complicated than that. There are a bunch of characters we need to check for, including |
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.
I trust the combined brains of you and Leonard on the state transitions being correct here for SosPmApc, DcsPassThrough and DcsIgnore; thanks for doing this!
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
Summary of the Pull Request
Up to now we haven't supported passing
DCS
sequences over conpty, soany
DCS
operations would just be ignored in Windows Terminal. This PRintroduces a mechanism whereby we can selectively pass through
operations that could reasonably be handled by the connected terminal
without interfering with the regular conpty renderer. For now this is
just used to support restoring the
DECCTR
color table report.References
Support for
DECCTR
was originally added to conhost in PR #13139.PR Checklist
checked, I'm ready to accept this work might be rejected in favor of a
different grand plan. Issue number where discussion took place: #xxx
Detailed Description of the Pull Request / Additional comments
The way this works is we have a helper method in
AdaptDispatch
thatDCS
operations can use to create a passthroughStringHandler
for theincoming data instead of their usual handler. To make this passthrough
process more efficient, the handler buffers the data before forwarding
it to conpty.
However, it's important that we aren't holding back data if output is
paused before the string terminator, so we need to flush the buffer
whenever we reach the end of the current write operation. This is
achieved by querying a new method in the
StateMachine
that lets usknow if we're currently dealing with the last character.
Another issue that came up was with the way the
StateMachine
cachessequences that it might later need to forward to conpty. In the case of
string sequences like
DCS
, we don't want the actual string data cachedhere, because that will just waste memory, and can also result in the
data being mistakenly output. So I've now disabled that caching when
we're in any of the string processing states.
Validation Steps Performed
I've manually confirmed that the
DECCTR
sequence can now update thecolor table in Windows Terminal. I've also added a new unit test in
ConptyRoundtripTests
to verify the sequence is being passed throughsuccessfully.