From ba01db3e8cfa6684f30c3fd499b60154a124aa86 Mon Sep 17 00:00:00 2001 From: Tigger Kindel Date: Thu, 20 Jul 2023 08:09:50 -0600 Subject: [PATCH] Change Cleanup to not call SetConsoleOutputWindow --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 17 +++++++++-------- Terminal.Gui/Core/Application.cs | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 36f5dc82d..f121dcab8 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -164,7 +164,8 @@ namespace Terminal.Gui { SetCursorVisibility (initialCursorVisibility.Value); } - SetConsoleOutputWindow (out _); + // BUGBUG: Commenting this out fixes #2634 + //SetConsoleOutputWindow (out _); ConsoleMode = originalConsoleMode; //ContinueListeningForConsoleEvents = false; @@ -173,8 +174,9 @@ namespace Terminal.Gui { Console.WriteLine ("Error: {0}", err); } - if (ScreenBuffer != IntPtr.Zero) + if (ScreenBuffer != IntPtr.Zero) { CloseHandle (ScreenBuffer); + } ScreenBuffer = IntPtr.Zero; } @@ -1494,7 +1496,7 @@ namespace Terminal.Gui { // If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS). // If n is 3, clear entire screen and delete all lines saved in the scrollback buffer // DO NOT USE 3J - even with the alternate screen buffer, it clears the entire scrollback buffer - Console.Out.Write ("\x1b[3J"); + Console.Out.Write ("\x1b[0J"); } } @@ -1707,20 +1709,19 @@ namespace Terminal.Gui { public override void End () { + WinConsole.Cleanup (); WinConsole = null; + // Disable alternative screen buffer. + Console.Out.Write ("\x1b[?1047l"); + // Needed for Windows Terminal // Clear the alternative screen buffer from the cursor to the // end of the screen. // Note, [3J causes Windows Terminal to wipe out the entire NON ALTERNATIVE // backbuffer! So we need to use [0J instead. Console.Out.Write ("\x1b[0J"); - - // Disable alternative screen buffer. - Console.Out.Write ("\x1b[?1047l"); - - // Console.Out.Flush () is not needed. See https://stackoverflow.com/a/20450486/297526 } /// diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 8d929682b..e7e8a72d7 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -1103,6 +1103,7 @@ namespace Terminal.Gui { // Init created. Apps that do any threading will need to code defensively for this. // e.g. see Issue #537 foreach (var t in toplevels) { + t.Running = false; t.Dispose (); }