-
Notifications
You must be signed in to change notification settings - Fork 8.5k
fix: WpfTerminalControl allow Connection set to null #15062
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: WpfTerminalControl allow Connection set to null #15062
Conversation
@microsoft-github-policy-service agree |
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.
Sure
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.
Alright! I like the thrust behind this, but I'd like to put you on brief pause while we figure out what the public API for the Terminal Control is.
In general, I feel weird about using strings to have one part of an application tell another part what to do; this includes VT (the control telling itself!)
It strikes me as something that should be intrinsic to the internal native API bridging PublicTerminalCore <-> WpfTerminalControl.
In addition, we may want to surface the hard reset operation rather than a simple clear screen one. A connection terminating can leave the terminal in a weird state, where it's sending encoded mouse events or scroll events or is using DECCKM for arrow keys or somesuch. Hard reset will bring it completely back into sanity. :)
Yeah certainly a bit odd but such is much of the ANSI api. If exposing the hard reset api is something to occur sooner rather than later happy to wait and update once it is. If it might be a good bit further down the line, I can revise this to just allow setting it back to null for a temporary bandaid (if preferable). There is nothing currently that stops you from assigning another it is just setting to null that breaks things (so the bugs mentioned do occur there). |
Discussion: maybe it should be the |
@@ -113,10 +113,23 @@ private get | |||
{ | |||
this.connection.TerminalOutput -= this.Connection_TerminalOutput; | |||
} | |||
|
|||
this.Connection_TerminalOutput(this, new TerminalOutputEventArgs("\u001b[2J")); //clear screen |
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.
C# supports \x1b
for strings btw, so there's no need for the rather verbose \u001b
.
I personally believe that the ANSI escape sequences are fine. Using an approach like "\x1bc\x1b]104\a\x1b[!p\x1b[?3;4l\x1b[4l\x1b>\x1b[?69l" Translated this means:
Some of these don't seem to be useful for us, but I think that this string is generally fine. It's definitely more thorough than the current approach. |
Alright @mitchcapper, my team convinced me to see the light here. I'm not gonna let perfect be the enemy of good enough, and I think that using VT is good enough. We don't have immediate plans to give you a better API, anyway. I was pretty curious about Leonard's recommended reset sequence, though.
I don't know if we need to go full overboard with this, and I'm actually quite confused as to why My understanding is that terminal/src/terminal/adapter/adaptDispatch.cpp Lines 2594 to 2610 in f671f06
terminal/src/terminal/adapter/adaptDispatch.cpp Lines 2535 to 2556 in f671f06
. . . I believe that all we need is |
The issue here is that terminfo has a bunch of different reset strings ( I suspect one of the reasons for the split might be because some of the original hardware terminals would trigger a disconnect on a hard reset, so it would typically be preferable to use a soft reset if that option was available. When you do a But the bottom line is, if you're going to send |
Hides the cursor when null, shows it when not. Clear the screen any time the connection is changed. Closes: microsoft#15061
1d600c4
to
bfa3990
Compare
OK so I have updated the PR to match described. @lhecker I mostly was using the intercept sequences between ConPty and Terminal. The |
Thanks James for the write-up :) and thanks Mitch for implementing |
#### Fix warnings due to formatting during a clean build Seems like the compiler cares about them more than our formatter. Possibly introduced in #15062 ## Validation Steps Performed - Tests passed
Hides the cursor when null, shows it when not.
Clear the screen any time the connection is changed.
Summary of the Pull Request
Prevents the WPF Control from crashing when set back to null, clears the console and hides the mouse as well.
References and Relevant Issues
#15061
Detailed Description of the Pull Request / Additional comments
It say 3 ansi commands as well now:
None of the ansi commands are needed, users could do it all themselves as well, the behavior largely seemed natural though. I didn't see any ansi constants anywhere so they are just hard coded with comments, but not sure if there is an established better practice.
Closes #15061