From af3a1ff661fd09aa549aa43d6b271334be78472e Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Mon, 25 Jan 2021 08:38:07 -0800 Subject: [PATCH 1/2] disable mouse tracking when ocgv closes --- src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs index a78f573..16d9a66 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs @@ -327,6 +327,10 @@ public void Dispose() // Esc[?1h - Set cursor key to application mode // See http://ascii-table.com/ansi-escape-sequences-vt-100.php Console.Write("\u001b[?1h"); + + // Similar to the fix above this, this turns of Mouse Tracking as described here: + // https://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking + Console.Write("\u001b[?1003l"); } } } From 2ed0f08187a4960efaf3398e1b9a45983e5cfb3f Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Mon, 25 Jan 2021 10:35:14 -0800 Subject: [PATCH 2/2] feedback from Dustin --- .../ConsoleGui.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs index 16d9a66..2ad6f0d 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs @@ -322,15 +322,15 @@ public void Dispose() { if (!Console.IsInputRedirected) { - // By emitting this, we fix an issue where arrow keys don't work in the console - // because .NET requires application mode to support Arrow key escape sequences - // Esc[?1h - Set cursor key to application mode - // See http://ascii-table.com/ansi-escape-sequences-vt-100.php - Console.Write("\u001b[?1h"); - - // Similar to the fix above this, this turns of Mouse Tracking as described here: - // https://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking - Console.Write("\u001b[?1003l"); + // By emitting this, we fix two issues: + // 1. An issue where arrow keys don't work in the console because .NET + // requires application mode to support Arrow key escape sequences. + // Esc[?1h sets the cursor key to application mode + // See http://ascii-table.com/ansi-escape-sequences-vt-100.php + // 2. An issue where moving the mouse causes characters to show up because + // mouse tracking is still on. Esc[?1003l turns it off. + // See https://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking + Console.Write("\u001b[?1h\u001b[?1003l"); } } }