From 76eca1ccec127e3053927545b783cc41e9a49d7c Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 13:24:36 +0100 Subject: [PATCH 1/7] Revert "Fixes #3752. Tracking Windows Terminal Preview Issue - App size is corrupted" This reverts commit 486f129c8a9e70237615ad985dd971d5d709d841. --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 259 +++++++++---------- 1 file changed, 126 insertions(+), 133 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 0abcc60248..01d13b80d2 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -18,6 +18,7 @@ internal class WindowsConsole { public const int STD_ERROR_HANDLE = -12; internal IntPtr InputHandle, OutputHandle; + IntPtr ScreenBuffer; readonly uint originalConsoleMode; CursorVisibility? initialCursorVisibility = null; CursorVisibility? currentCursorVisibility = null; @@ -39,47 +40,47 @@ public WindowsConsole () public bool WriteToConsole (Size size, CharInfo [] charInfoBuffer, Coord coords, SmallRect window) { - //if (OutputHandle == IntPtr.Zero) { - // ReadFromConsoleOutput (size, coords, ref window); - //} + if (ScreenBuffer == IntPtr.Zero) { + ReadFromConsoleOutput (size, coords, ref window); + } - return WriteConsoleOutput (OutputHandle, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); + return WriteConsoleOutput (ScreenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); } - //public void ReadFromConsoleOutput (Size size, Coord coords, ref SmallRect window) - //{ - // OutputHandle = CreateConsoleScreenBuffer ( - // DesiredAccess.GenericRead | DesiredAccess.GenericWrite, - // ShareMode.FileShareRead | ShareMode.FileShareWrite, - // IntPtr.Zero, - // 1, - // IntPtr.Zero - // ); - // if (ScreenBuffer == INVALID_HANDLE_VALUE) { - // var err = Marshal.GetLastWin32Error (); + 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 (err != 0) + throw new System.ComponentModel.Win32Exception (err); + } - // if (!initialCursorVisibility.HasValue && GetCursorVisibility (out CursorVisibility visibility)) { - // initialCursorVisibility = visibility; - // } + if (!initialCursorVisibility.HasValue && GetCursorVisibility (out CursorVisibility visibility)) { + initialCursorVisibility = visibility; + } - // if (!SetConsoleActiveScreenBuffer (ScreenBuffer)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } + if (!SetConsoleActiveScreenBuffer (ScreenBuffer)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } - // OriginalStdOutChars = new CharInfo [size.Height * size.Width]; + OriginalStdOutChars = new CharInfo [size.Height * size.Width]; - // if (!ReadConsoleOutput (ScreenBuffer, OriginalStdOutChars, coords, new Coord () { X = 0, Y = 0 }, ref window)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - //} + if (!ReadConsoleOutput (ScreenBuffer, OriginalStdOutChars, coords, new Coord () { X = 0, Y = 0 }, ref window)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + } public bool SetCursorPosition (Coord position) { - return SetConsoleCursorPosition (OutputHandle, position); + return SetConsoleCursorPosition (ScreenBuffer, position); } public void SetInitialCursorVisibility () @@ -91,11 +92,11 @@ public void SetInitialCursorVisibility () public bool GetCursorVisibility (out CursorVisibility visibility) { - if (OutputHandle == IntPtr.Zero) { + if (ScreenBuffer == IntPtr.Zero) { visibility = CursorVisibility.Invisible; return false; } - if (!GetConsoleCursorInfo (OutputHandle, out ConsoleCursorInfo info)) { + if (!GetConsoleCursorInfo (ScreenBuffer, out ConsoleCursorInfo info)) { var err = Marshal.GetLastWin32Error (); if (err != 0) { throw new System.ComponentModel.Win32Exception (err); @@ -148,7 +149,7 @@ public bool SetCursorVisibility (CursorVisibility visibility) bVisible = ((uint)visibility & 0xFF00) != 0 }; - if (!SetConsoleCursorInfo (OutputHandle, ref info)) + if (!SetConsoleCursorInfo (ScreenBuffer, ref info)) return false; currentCursorVisibility = visibility; @@ -164,28 +165,28 @@ public void Cleanup () } ConsoleMode = originalConsoleMode; - //if (!SetConsoleActiveScreenBuffer (OutputHandle)) { - // var err = Marshal.GetLastWin32Error (); - // Console.WriteLine ("Error: {0}", err); - //} + if (!SetConsoleActiveScreenBuffer (OutputHandle)) { + var err = Marshal.GetLastWin32Error (); + Console.WriteLine ("Error: {0}", err); + } - //if (ScreenBuffer != IntPtr.Zero) { - // CloseHandle (ScreenBuffer); - //} + if (ScreenBuffer != IntPtr.Zero) { + CloseHandle (ScreenBuffer); + } - //ScreenBuffer = IntPtr.Zero; + ScreenBuffer = IntPtr.Zero; } internal Size GetConsoleBufferWindow (out Point position) { - if (OutputHandle == IntPtr.Zero) { + if (ScreenBuffer == IntPtr.Zero) { position = Point.Empty; return Size.Empty; } var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx (OutputHandle, ref csbi)) { + if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { //throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); position = Point.Empty; return Size.Empty; @@ -211,65 +212,65 @@ internal Size GetConsoleOutputWindow (out Point position) return sz; } - //internal Size SetConsoleWindow (short cols, short rows) - //{ - // var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); - // csbi.cbSize = (uint)Marshal.SizeOf (csbi); - - // if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - // var maxWinSize = GetLargestConsoleWindowSize (ScreenBuffer); - // var newCols = Math.Min (cols, maxWinSize.X); - // var newRows = Math.Min (rows, maxWinSize.Y); - // csbi.dwSize = new Coord (newCols, Math.Max (newRows, (short)1)); - // csbi.srWindow = new SmallRect (0, 0, newCols, newRows); - // csbi.dwMaximumWindowSize = new Coord (newCols, newRows); - // if (!SetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - // var winRect = new SmallRect (0, 0, (short)(newCols - 1), (short)Math.Max (newRows - 1, 0)); - // if (!SetConsoleWindowInfo (OutputHandle, true, ref winRect)) { - // //throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // return new Size (cols, rows); - // } - // SetConsoleOutputWindow (csbi); - // return new Size (winRect.Right + 1, newRows - 1 < 0 ? 0 : winRect.Bottom + 1); - //} - - //void SetConsoleOutputWindow (CONSOLE_SCREEN_BUFFER_INFOEX csbi) - //{ - // if (ScreenBuffer != IntPtr.Zero && !SetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - //} - - //internal Size SetConsoleOutputWindow (out Point position) - //{ - // if (ScreenBuffer == IntPtr.Zero) { - // position = Point.Empty; - // return Size.Empty; - // } - - // var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); - // csbi.cbSize = (uint)Marshal.SizeOf (csbi); - // if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - // var sz = new Size (csbi.srWindow.Right - csbi.srWindow.Left + 1, - // Math.Max (csbi.srWindow.Bottom - csbi.srWindow.Top + 1, 0)); - // position = new Point (csbi.srWindow.Left, csbi.srWindow.Top); - // SetConsoleOutputWindow (csbi); - // var winRect = new SmallRect (0, 0, (short)(sz.Width - 1), (short)Math.Max (sz.Height - 1, 0)); - // if (!SetConsoleScreenBufferInfoEx (OutputHandle, ref csbi)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - // if (!SetConsoleWindowInfo (OutputHandle, true, ref winRect)) { - // throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); - // } - - // return sz; - //} + internal Size SetConsoleWindow (short cols, short rows) + { + var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); + csbi.cbSize = (uint)Marshal.SizeOf (csbi); + + if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + var maxWinSize = GetLargestConsoleWindowSize (ScreenBuffer); + var newCols = Math.Min (cols, maxWinSize.X); + var newRows = Math.Min (rows, maxWinSize.Y); + csbi.dwSize = new Coord (newCols, Math.Max (newRows, (short)1)); + csbi.srWindow = new SmallRect (0, 0, newCols, newRows); + csbi.dwMaximumWindowSize = new Coord (newCols, newRows); + if (!SetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + var winRect = new SmallRect (0, 0, (short)(newCols - 1), (short)Math.Max (newRows - 1, 0)); + if (!SetConsoleWindowInfo (OutputHandle, true, ref winRect)) { + //throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + return new Size (cols, rows); + } + SetConsoleOutputWindow (csbi); + return new Size (winRect.Right + 1, newRows - 1 < 0 ? 0 : winRect.Bottom + 1); + } + + void SetConsoleOutputWindow (CONSOLE_SCREEN_BUFFER_INFOEX csbi) + { + if (ScreenBuffer != IntPtr.Zero && !SetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + } + + internal Size SetConsoleOutputWindow (out Point position) + { + if (ScreenBuffer == IntPtr.Zero) { + position = Point.Empty; + return Size.Empty; + } + + var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); + csbi.cbSize = (uint)Marshal.SizeOf (csbi); + if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + var sz = new Size (csbi.srWindow.Right - csbi.srWindow.Left + 1, + Math.Max (csbi.srWindow.Bottom - csbi.srWindow.Top + 1, 0)); + position = new Point (csbi.srWindow.Left, csbi.srWindow.Top); + SetConsoleOutputWindow (csbi); + var winRect = new SmallRect (0, 0, (short)(sz.Width - 1), (short)Math.Max (sz.Height - 1, 0)); + if (!SetConsoleScreenBufferInfoEx (OutputHandle, ref csbi)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + if (!SetConsoleWindowInfo (OutputHandle, true, ref winRect)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } + + return sz; + } //bool ContinueListeningForConsoleEvents = true; @@ -733,7 +734,7 @@ public WindowsDriver () WinConsole = new WindowsConsole (); clipboard = new WindowsClipboard (); - isWindowsTerminal = Environment.GetEnvironmentVariable ("WT_SESSION") != null || Environment.GetEnvironmentVariable ("VSAPPIDNAME") != null; + isWindowsTerminal = Environment.GetEnvironmentVariable ("WT_SESSION") != null; } public override void PrepareToRun (MainLoop mainLoop, Action keyHandler, Action keyDownHandler, Action keyUpHandler, Action mouseHandler) @@ -747,28 +748,28 @@ public override void PrepareToRun (MainLoop mainLoop, Action keyHandle mLoop.ProcessInput = (e) => ProcessInput (e); - //mLoop.WinChanged = (e) => { - // ChangeWin (e); - //}; - } - - //private void ChangeWin (Size e) - //{ - // var w = e.Width; - // if (w == cols - 3 && e.Height < rows) { - // w += 3; - // } - // var newSize = WinConsole.SetConsoleWindow ( - // (short)Math.Max (w, 16), (short)Math.Max (e.Height, 0)); - - // left = 0; - // top = 0; - // cols = newSize.Width; - // rows = newSize.Height; - // ResizeScreen (); - // UpdateOffScreen (); - // TerminalResized.Invoke (); - //} + mLoop.WinChanged = (e) => { + ChangeWin (e); + }; + } + + private void ChangeWin (Size e) + { + var w = e.Width; + if (w == cols - 3 && e.Height < rows) { + w += 3; + } + var newSize = WinConsole.SetConsoleWindow ( + (short)Math.Max (w, 16), (short)Math.Max (e.Height, 0)); + + left = 0; + top = 0; + cols = newSize.Width; + rows = newSize.Height; + ResizeScreen (); + UpdateOffScreen (); + TerminalResized.Invoke (); + } void ProcessInput (WindowsConsole.InputRecord inputEvent) { @@ -892,14 +893,6 @@ void ProcessInput (WindowsConsole.InputRecord inputEvent) case WindowsConsole.EventType.Focus: keyModifiers = null; break; - - case WindowsConsole.EventType.WindowBufferSize: - cols = inputEvent.WindowBufferSizeEvent.size.X; - rows = inputEvent.WindowBufferSizeEvent.size.Y; - - ResizeScreen (); - TerminalResized.Invoke (); - break; } } From 4f13b1c9d8fa83f4ffa14b49720773b7bb1b06d4 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 15:45:02 +0100 Subject: [PATCH 2/7] Fix console restore on non-Windows Terminal --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 40 ++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 01d13b80d2..5a5140d8d0 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -40,11 +40,15 @@ public WindowsConsole () public bool WriteToConsole (Size size, CharInfo [] charInfoBuffer, Coord coords, SmallRect window) { - if (ScreenBuffer == IntPtr.Zero) { + if (!IsWindowsTerminal && ScreenBuffer == IntPtr.Zero) { ReadFromConsoleOutput (size, coords, ref window); } - return WriteConsoleOutput (ScreenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); + if (!initialCursorVisibility.HasValue && GetCursorVisibility (out CursorVisibility visibility)) { + initialCursorVisibility = visibility; + } + + return WriteConsoleOutput (IsWindowsTerminal ? OutputHandle : ScreenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); } public void ReadFromConsoleOutput (Size size, Coord coords, ref SmallRect window) @@ -63,10 +67,6 @@ public void ReadFromConsoleOutput (Size size, Coord coords, ref SmallRect window throw new System.ComponentModel.Win32Exception (err); } - if (!initialCursorVisibility.HasValue && GetCursorVisibility (out CursorVisibility visibility)) { - initialCursorVisibility = visibility; - } - if (!SetConsoleActiveScreenBuffer (ScreenBuffer)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } @@ -80,7 +80,7 @@ public void ReadFromConsoleOutput (Size size, Coord coords, ref SmallRect window public bool SetCursorPosition (Coord position) { - return SetConsoleCursorPosition (ScreenBuffer, position); + return SetConsoleCursorPosition (IsWindowsTerminal ? OutputHandle : ScreenBuffer, position); } public void SetInitialCursorVisibility () @@ -92,11 +92,11 @@ public void SetInitialCursorVisibility () public bool GetCursorVisibility (out CursorVisibility visibility) { - if (ScreenBuffer == IntPtr.Zero) { + if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) == IntPtr.Zero) { visibility = CursorVisibility.Invisible; return false; } - if (!GetConsoleCursorInfo (ScreenBuffer, out ConsoleCursorInfo info)) { + if (!GetConsoleCursorInfo (IsWindowsTerminal ? OutputHandle : ScreenBuffer, out ConsoleCursorInfo info)) { var err = Marshal.GetLastWin32Error (); if (err != 0) { throw new System.ComponentModel.Win32Exception (err); @@ -149,7 +149,7 @@ public bool SetCursorVisibility (CursorVisibility visibility) bVisible = ((uint)visibility & 0xFF00) != 0 }; - if (!SetConsoleCursorInfo (ScreenBuffer, ref info)) + if (!SetConsoleCursorInfo (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref info)) return false; currentCursorVisibility = visibility; @@ -179,14 +179,14 @@ public void Cleanup () internal Size GetConsoleBufferWindow (out Point position) { - if (ScreenBuffer == IntPtr.Zero) { + if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) == IntPtr.Zero) { position = Point.Empty; return Size.Empty; } var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + if (!GetConsoleScreenBufferInfoEx ((IsWindowsTerminal ? OutputHandle : ScreenBuffer), ref csbi)) { //throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); position = Point.Empty; return Size.Empty; @@ -217,16 +217,16 @@ internal Size SetConsoleWindow (short cols, short rows) var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + if (!GetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } - var maxWinSize = GetLargestConsoleWindowSize (ScreenBuffer); + var maxWinSize = GetLargestConsoleWindowSize (IsWindowsTerminal ? OutputHandle : ScreenBuffer); var newCols = Math.Min (cols, maxWinSize.X); var newRows = Math.Min (rows, maxWinSize.Y); csbi.dwSize = new Coord (newCols, Math.Max (newRows, (short)1)); csbi.srWindow = new SmallRect (0, 0, newCols, newRows); csbi.dwMaximumWindowSize = new Coord (newCols, newRows); - if (!SetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + if (!SetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } var winRect = new SmallRect (0, 0, (short)(newCols - 1), (short)Math.Max (newRows - 1, 0)); @@ -240,21 +240,21 @@ internal Size SetConsoleWindow (short cols, short rows) void SetConsoleOutputWindow (CONSOLE_SCREEN_BUFFER_INFOEX csbi) { - if (ScreenBuffer != IntPtr.Zero && !SetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) != IntPtr.Zero && !SetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } } internal Size SetConsoleOutputWindow (out Point position) { - if (ScreenBuffer == IntPtr.Zero) { + if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) == IntPtr.Zero) { position = Point.Empty; return Size.Empty; } var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx (ScreenBuffer, ref csbi)) { + if (!GetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } var sz = new Size (csbi.srWindow.Right - csbi.srWindow.Left + 1, @@ -274,6 +274,8 @@ internal Size SetConsoleOutputWindow (out Point position) //bool ContinueListeningForConsoleEvents = true; + internal bool IsWindowsTerminal { get; set; } + public uint ConsoleMode { get { GetConsoleMode (InputHandle, out uint v); @@ -734,7 +736,7 @@ public WindowsDriver () WinConsole = new WindowsConsole (); clipboard = new WindowsClipboard (); - isWindowsTerminal = Environment.GetEnvironmentVariable ("WT_SESSION") != null; + WinConsole.IsWindowsTerminal = isWindowsTerminal = Environment.GetEnvironmentVariable ("WT_SESSION") != null || Environment.GetEnvironmentVariable ("VSAPPIDNAME") != null; } public override void PrepareToRun (MainLoop mainLoop, Action keyHandler, Action keyDownHandler, Action keyUpHandler, Action mouseHandler) From 79129bf0cf49a7702ead136bd0f4e28a82219a9a Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 15:49:34 +0100 Subject: [PATCH 3/7] Remove unsupported net7.0 --- Terminal.Gui/Terminal.Gui.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Terminal.Gui/Terminal.Gui.csproj b/Terminal.Gui/Terminal.Gui.csproj index bd919e2aae..3dc102d81a 100644 --- a/Terminal.Gui/Terminal.Gui.csproj +++ b/Terminal.Gui/Terminal.Gui.csproj @@ -20,7 +20,7 @@ portable - net472;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0 + net472;netstandard2.0;netstandard2.1;net6.0;net8.0 Terminal.Gui Terminal.Gui true From 8f10e9326823a163880c39fcf4199d68643c9196 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 16:00:24 +0100 Subject: [PATCH 4/7] Fix Package 'SixLabors.ImageSharp' 3.1.5 has a known high severity vulnerability, https://github.com/advisories/GHSA-2cmq-823j-5qj8 --- UICatalog/UICatalog.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UICatalog/UICatalog.csproj b/UICatalog/UICatalog.csproj index a05ebdf02a..4cedf89be0 100644 --- a/UICatalog/UICatalog.csproj +++ b/UICatalog/UICatalog.csproj @@ -21,7 +21,7 @@ - + From 160cc9af29ae9f69e4adf13c374778b31ae0988c Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 16:11:34 +0100 Subject: [PATCH 5/7] Fix punctuation at the end of the messages doesn't match up. The expected trailing punctuation sequence is: ... --- Terminal.Gui/Resources/Strings.ja-JP.resx | 2 +- Terminal.Gui/Resources/Strings.pt-PT.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Resources/Strings.ja-JP.resx b/Terminal.Gui/Resources/Strings.ja-JP.resx index 68b15dda80..06e33fab44 100644 --- a/Terminal.Gui/Resources/Strings.ja-JP.resx +++ b/Terminal.Gui/Resources/Strings.ja-JP.resx @@ -166,6 +166,6 @@ 終える - 次に + 次に... \ No newline at end of file diff --git a/Terminal.Gui/Resources/Strings.pt-PT.resx b/Terminal.Gui/Resources/Strings.pt-PT.resx index a8385c556e..3a8519a6c3 100644 --- a/Terminal.Gui/Resources/Strings.pt-PT.resx +++ b/Terminal.Gui/Resources/Strings.pt-PT.resx @@ -166,6 +166,6 @@ Acabam_ento - S_eguir + S_eguir... \ No newline at end of file From ace48faf94048657bcf175c96e73c0048df8da5b Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 16:45:38 +0100 Subject: [PATCH 6/7] Fix referenced assembly 'UICatalog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. --- UICatalog/UICatalog.csproj | 4 +++- UICatalog/UICatalog.snk | Bin 0 -> 596 bytes 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 UICatalog/UICatalog.snk diff --git a/UICatalog/UICatalog.csproj b/UICatalog/UICatalog.csproj index 4cedf89be0..f6eec91b9a 100644 --- a/UICatalog/UICatalog.csproj +++ b/UICatalog/UICatalog.csproj @@ -1,4 +1,4 @@ - + Exe net8.0 @@ -9,6 +9,8 @@ 1.0.0.0 1.0.0 + True + UICatalog.snk TRACE diff --git a/UICatalog/UICatalog.snk b/UICatalog/UICatalog.snk new file mode 100644 index 0000000000000000000000000000000000000000..a6fc18ff3e6b6afb8202881f3d2d1565ca265baf GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096Aq4tYN_1e?nhUIY{pWuo$75QNEQW z)SqTGhs}r_O%G957G)#JW(08c^S*f^s~_&YP>P|85-p|SHUVAMVbwlP zdoDhW5rdIww-@jOY}3|Zo0(BH03}&qs$o4%4RK9doz*90J<=cj=ta)@XtJ-P{l|4X&xtPyu@UcS0R=<}m9YzJ9CvP>6VH(o1v#(=F7v?jTo*zB literal 0 HcmV?d00001 From ed0a51a2d436f5785df5189032df5f51926d6883 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Apr 2025 20:46:04 +0100 Subject: [PATCH 7/7] Fix naming rule violation --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 44 ++++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 5a5140d8d0..9a9deccee0 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -18,7 +18,7 @@ internal class WindowsConsole { public const int STD_ERROR_HANDLE = -12; internal IntPtr InputHandle, OutputHandle; - IntPtr ScreenBuffer; + IntPtr screenBuffer; readonly uint originalConsoleMode; CursorVisibility? initialCursorVisibility = null; CursorVisibility? currentCursorVisibility = null; @@ -40,7 +40,7 @@ public WindowsConsole () public bool WriteToConsole (Size size, CharInfo [] charInfoBuffer, Coord coords, SmallRect window) { - if (!IsWindowsTerminal && ScreenBuffer == IntPtr.Zero) { + if (!IsWindowsTerminal && screenBuffer == IntPtr.Zero) { ReadFromConsoleOutput (size, coords, ref window); } @@ -48,39 +48,39 @@ public bool WriteToConsole (Size size, CharInfo [] charInfoBuffer, Coord coords, initialCursorVisibility = visibility; } - return WriteConsoleOutput (IsWindowsTerminal ? OutputHandle : ScreenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); + return WriteConsoleOutput (IsWindowsTerminal ? OutputHandle : screenBuffer, charInfoBuffer, coords, new Coord () { X = window.Left, Y = window.Top }, ref window); } public void ReadFromConsoleOutput (Size size, Coord coords, ref SmallRect window) { - ScreenBuffer = CreateConsoleScreenBuffer ( + screenBuffer = CreateConsoleScreenBuffer ( DesiredAccess.GenericRead | DesiredAccess.GenericWrite, ShareMode.FileShareRead | ShareMode.FileShareWrite, IntPtr.Zero, 1, IntPtr.Zero ); - if (ScreenBuffer == INVALID_HANDLE_VALUE) { + if (screenBuffer == INVALID_HANDLE_VALUE) { var err = Marshal.GetLastWin32Error (); if (err != 0) throw new System.ComponentModel.Win32Exception (err); } - if (!SetConsoleActiveScreenBuffer (ScreenBuffer)) { + if (!SetConsoleActiveScreenBuffer (screenBuffer)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } OriginalStdOutChars = new CharInfo [size.Height * size.Width]; - if (!ReadConsoleOutput (ScreenBuffer, OriginalStdOutChars, coords, new Coord () { X = 0, Y = 0 }, ref window)) { + if (!ReadConsoleOutput (screenBuffer, OriginalStdOutChars, coords, new Coord () { X = 0, Y = 0 }, ref window)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } } public bool SetCursorPosition (Coord position) { - return SetConsoleCursorPosition (IsWindowsTerminal ? OutputHandle : ScreenBuffer, position); + return SetConsoleCursorPosition (IsWindowsTerminal ? OutputHandle : screenBuffer, position); } public void SetInitialCursorVisibility () @@ -92,11 +92,11 @@ public void SetInitialCursorVisibility () public bool GetCursorVisibility (out CursorVisibility visibility) { - if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) == IntPtr.Zero) { + if ((IsWindowsTerminal ? OutputHandle : screenBuffer) == IntPtr.Zero) { visibility = CursorVisibility.Invisible; return false; } - if (!GetConsoleCursorInfo (IsWindowsTerminal ? OutputHandle : ScreenBuffer, out ConsoleCursorInfo info)) { + if (!GetConsoleCursorInfo (IsWindowsTerminal ? OutputHandle : screenBuffer, out ConsoleCursorInfo info)) { var err = Marshal.GetLastWin32Error (); if (err != 0) { throw new System.ComponentModel.Win32Exception (err); @@ -149,7 +149,7 @@ public bool SetCursorVisibility (CursorVisibility visibility) bVisible = ((uint)visibility & 0xFF00) != 0 }; - if (!SetConsoleCursorInfo (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref info)) + if (!SetConsoleCursorInfo (IsWindowsTerminal ? OutputHandle : screenBuffer, ref info)) return false; currentCursorVisibility = visibility; @@ -170,23 +170,23 @@ public void Cleanup () Console.WriteLine ("Error: {0}", err); } - if (ScreenBuffer != IntPtr.Zero) { - CloseHandle (ScreenBuffer); + if (screenBuffer != IntPtr.Zero) { + CloseHandle (screenBuffer); } - ScreenBuffer = IntPtr.Zero; + screenBuffer = IntPtr.Zero; } internal Size GetConsoleBufferWindow (out Point position) { - if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) == IntPtr.Zero) { + if ((IsWindowsTerminal ? OutputHandle : screenBuffer) == IntPtr.Zero) { position = Point.Empty; return Size.Empty; } var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx ((IsWindowsTerminal ? OutputHandle : ScreenBuffer), ref csbi)) { + if (!GetConsoleScreenBufferInfoEx ((IsWindowsTerminal ? OutputHandle : screenBuffer), ref csbi)) { //throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); position = Point.Empty; return Size.Empty; @@ -217,16 +217,16 @@ internal Size SetConsoleWindow (short cols, short rows) var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { + if (!GetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : screenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } - var maxWinSize = GetLargestConsoleWindowSize (IsWindowsTerminal ? OutputHandle : ScreenBuffer); + var maxWinSize = GetLargestConsoleWindowSize (IsWindowsTerminal ? OutputHandle : screenBuffer); var newCols = Math.Min (cols, maxWinSize.X); var newRows = Math.Min (rows, maxWinSize.Y); csbi.dwSize = new Coord (newCols, Math.Max (newRows, (short)1)); csbi.srWindow = new SmallRect (0, 0, newCols, newRows); csbi.dwMaximumWindowSize = new Coord (newCols, newRows); - if (!SetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { + if (!SetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : screenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } var winRect = new SmallRect (0, 0, (short)(newCols - 1), (short)Math.Max (newRows - 1, 0)); @@ -240,21 +240,21 @@ internal Size SetConsoleWindow (short cols, short rows) void SetConsoleOutputWindow (CONSOLE_SCREEN_BUFFER_INFOEX csbi) { - if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) != IntPtr.Zero && !SetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { + if ((IsWindowsTerminal ? OutputHandle : screenBuffer) != IntPtr.Zero && !SetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : screenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } } internal Size SetConsoleOutputWindow (out Point position) { - if ((IsWindowsTerminal ? OutputHandle : ScreenBuffer) == IntPtr.Zero) { + if ((IsWindowsTerminal ? OutputHandle : screenBuffer) == IntPtr.Zero) { position = Point.Empty; return Size.Empty; } var csbi = new CONSOLE_SCREEN_BUFFER_INFOEX (); csbi.cbSize = (uint)Marshal.SizeOf (csbi); - if (!GetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : ScreenBuffer, ref csbi)) { + if (!GetConsoleScreenBufferInfoEx (IsWindowsTerminal ? OutputHandle : screenBuffer, ref csbi)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } var sz = new Size (csbi.srWindow.Right - csbi.srWindow.Left + 1,