From ba29c72896e277522a830fd9fcb4e93eb938772f Mon Sep 17 00:00:00 2001 From: BDisp Date: Thu, 16 Oct 2025 15:31:11 +0100 Subject: [PATCH] Ensure restore the original colors --- Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs b/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs index 5e75cc355..6c5f806c7 100644 --- a/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs +++ b/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs @@ -100,6 +100,8 @@ internal partial class WindowsOutput : OutputBase, IConsoleOutput private readonly nint _outputHandle; private nint _screenBuffer; private readonly bool _isVirtualTerminal; + private readonly ConsoleColor _foreground; + private readonly ConsoleColor _background; public WindowsOutput () { @@ -122,6 +124,11 @@ internal partial class WindowsOutput : OutputBase, IConsoleOutput //Enable alternative screen buffer. Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll); } + else + { + _foreground = Console.ForegroundColor; + _background = Console.BackgroundColor; + } } else { @@ -513,7 +520,8 @@ internal partial class WindowsOutput : OutputBase, IConsoleOutput else { // Simulate restoring the color and clearing the screen. - Console.ResetColor (); + Console.ForegroundColor = _foreground; + Console.BackgroundColor = _background; Console.Clear (); } }