-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Improve the DECSC/DECRC implementation #3160
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0355353
Add private APIs for getting and setting the full attributes of the a…
j4james d8cbb39
Extend the DECSC/DECRC commands so they also save and restore the cur…
j4james 3cc198f
Track the saved cursor state for the alt buffer separately from the m…
j4james 95596f9
Make sure the restored cursor position is within the bounds of the sc…
j4james ca99f94
Add screen buffer tests to verify the cursor save/restore behaviour.
j4james eae841d
Forgot to initialize the usingAltBuffer property.
j4james 522b60e
Rename the save/restore dispatch methods to better represent their ne…
j4james 5bc16a2
Improve comments.
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
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.
I suppose this change was inevitable. We've kinda just been patching around not just exposing the entire TextAttribute through this layer, but this might be easier. I know there was previously reluctance to doing this, something about it exposing too much of the implementation details of how conhost itself was implemented. @miniksa might remember more. I think we've come a long way since then, and this might be reasonable nowadays.
I guess from a design perspective, it would change things pretty dramatically - because the adapter could directly control the state of the text attributes, it could just avoid using any of the other functions, and put all the combined attribute manipulation logic directly in the adapter. There might be other things that conhost needs to do during some of these calls that might get circumnavigated by just using this method. These things might be a little trickier to move up into the adapter. I haven't dug in on this too much, so it might not be a problem.
If it was possible to move this logic into the adapter, then we could probably get rid of a bunch of these more specific boilerplate-y functions. That would probably make life easier for everyone.
The alternative here would be exposing a
PrivateSaveState
/PrivateRestoreState
pair that lets conhost implement it however it likes. Though, when I think about it, the implementation would be highly similar between conhost and Terminal...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.
Absolutely! I had exactly the same thought when I added this. There's a lot of weirdness in the current SGR implementation which I think could be greatly simplified if we had access to an API like this. Was going to raise a separate issue for that once I knew you were happy with the API and I had some time to play around with potential implementations.
If there was a need for conhost and Terminal to handle this functionality differently, that's already not a problem, since Terminal shares none of the
AdaptDispatch
implementation. That said, I'm not sure that's the right approach in the long term, because it seems we're slowly reimplementing all of theAdaptDispatch
code inTerminalDispatch
when those implementations should really be identical 99% of the time. But that's a topic for another issue.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'm OK with additional private methods being added here, I just don't want to expose any more publicly. @zadjii-msft, I'm not sure I had an extreme reticence to adding new private APIs given we've done a ton of them. I think it was more "I'm going to try to accomplish as much as possible without adding new APIs at all" and it led us to the non-ideal situations that we had and discovered over time.
Yes, if we're duplicating a big portion of the dispatch... then we probably need to somehow abstract the buffers or whatever the two adapters are calling and make that a shared component. Feel free to file another issue for that if you feel you can articulate it.