mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-08 05:37:27 +00:00
fix: WpfTerminalControl allow Connection set to null (#15062)
Hides the cursor when null, shows it when not. Clear the screen any time the connection is changed. This prevents the WPF Control from crashing when set back to null, clears the console and hides the mouse as well. It sends 3 VT sequences as well now: 1) When the Connection is set to null the cursor is hidden (reflects what the default state is) 2) When the Connection is set to a value and it was null before we show the cursor (not a breaking change as requires it to have been null which previously would cause a crash, except for for set) 3) When the Connection is changed the terminal is reset. A breaking change officially although not sure if there are use cases where this behavior is not desired. For added safety we could make sure we are not being set to the same value we currently are. 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
This commit is contained in:
committed by
GitHub
parent
19069e03be
commit
eb725e9993
@@ -113,10 +113,23 @@ namespace Microsoft.Terminal.Wpf
|
||||
{
|
||||
this.connection.TerminalOutput -= this.Connection_TerminalOutput;
|
||||
}
|
||||
|
||||
this.Connection_TerminalOutput(this, new TerminalOutputEventArgs("\x001bc\x1b]104\x1b\\")); //reset console/clear screen - https://github.com/microsoft/terminal/pull/15062#issuecomment-1505654110
|
||||
var wasNull = this.connection == null;
|
||||
this.connection = value;
|
||||
this.connection.TerminalOutput += this.Connection_TerminalOutput;
|
||||
this.connection.Start();
|
||||
if (this.connection != null)
|
||||
{
|
||||
if (wasNull)
|
||||
{
|
||||
this.Connection_TerminalOutput(this, new TerminalOutputEventArgs("\x1b[?25h")); //show cursor
|
||||
}
|
||||
this.connection.TerminalOutput += this.Connection_TerminalOutput;
|
||||
this.connection.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Connection_TerminalOutput(this, new TerminalOutputEventArgs("\x1b[?25l")); //hide cursor
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user