From 7b75f535febee25dc45a39dad8b3e542ee51aa7f Mon Sep 17 00:00:00 2001 From: BDisp Date: Tue, 16 Feb 2021 14:29:37 +0000 Subject: [PATCH] Removed the vertical shrinking feature from the WindowsDriver as request. --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 35 +++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 42ac617c0..c669c459b 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -59,7 +59,7 @@ namespace Terminal.Gui { public bool WriteToConsole (CharInfo [] charInfoBuffer, Coord coords, SmallRect window) { if (ScreenBuffer == IntPtr.Zero) { - window = ReadFromConsoleOutput (new Size (Console.WindowWidth, Console.WindowHeight), coords, window); + ReadFromConsoleOutput (new Size (Console.WindowWidth, Console.WindowHeight), coords, ref window); } return WriteConsoleOutput (ScreenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); @@ -67,11 +67,28 @@ namespace Terminal.Gui { public void ReadFromConsoleOutput (Size size, Coord coords, ref SmallRect window) { + ScreenBuffer = CreateConsoleScreenBuffer ( + DesiredAccess.GenericRead | DesiredAccess.GenericWrite, + ShareMode.FileShareRead | ShareMode.FileShareWrite, + IntPtr.Zero, + 1, + IntPtr.Zero + ); + if (ScreenBuffer == INVALID_HANDLE_VALUE) { + var err = Marshal.GetLastWin32Error (); + + if (err != 0) + throw new System.ComponentModel.Win32Exception (err); + } + + if (!SetConsoleActiveScreenBuffer (ScreenBuffer)) { + var err = Marshal.GetLastWin32Error (); + throw new System.ComponentModel.Win32Exception (err); + } + OriginalStdOutChars = new CharInfo [size.Height * size.Width]; ReadConsoleOutput (OutputHandle, OriginalStdOutChars, coords, new Coord () { X = 0, Y = 0 }, ref window); - - return window; } public bool SetCursorPosition (Coord position) @@ -513,6 +530,7 @@ namespace Terminal.Gui { public override int Cols => cols; public override int Rows => rows; public override int Top => top; + public override bool HeightAsBuffer { get; set; } public WindowsConsole WinConsole { get => winConsole; @@ -564,12 +582,9 @@ namespace Terminal.Gui { if (!winChanging) { TerminalResized.Invoke (); } - wasChangeWin = true; } } - bool isFromRestore; - void ProcessInput (WindowsConsole.InputRecord inputEvent) { switch (inputEvent.EventType) { @@ -1336,7 +1351,8 @@ namespace Terminal.Gui { { this.mainLoop = mainLoop; Task.Run (WindowsInputHandler); - Task.Run (CheckWinChange); + // Nor working yet. + //Task.Run (CheckWinChange); } void WindowsInputHandler () @@ -1387,9 +1403,10 @@ namespace Terminal.Gui { return true; } - //result = null; + result = null; waitForProbe.Set (); - winChange.Set (); + // Nor working yet. + //winChange.Set (); try { if (!tokenSource.IsCancellationRequested) {