From 7ef51bad852354199dee6d0dcf62ac45f02d173f Mon Sep 17 00:00:00 2001 From: Tigger Kindel Date: Wed, 26 Jul 2023 08:10:36 -0600 Subject: [PATCH] Remove EnableConsoleScrolling --- .../CursesDriver/CursesDriver.cs | 8 +- .../ConsoleDrivers/FakeDriver/FakeDriver.cs | 56 +++----- Terminal.Gui/ConsoleDrivers/NetDriver.cs | 127 ++++------------- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 8 +- Terminal.Gui/Core/Application.cs | 31 +--- Terminal.Gui/Core/ConsoleDriver.cs | 10 +- UICatalog/UICatalog.cs | 22 --- UnitTests/Application/ApplicationTests.cs | 2 - UnitTests/Drivers/ConsoleDriverTests.cs | 134 +----------------- UnitTests/xunit.runner.json | 2 +- 10 files changed, 67 insertions(+), 333 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs index 7e5f4dcfd4..036666970d 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs @@ -20,12 +20,10 @@ internal class CursesDriver : ConsoleDriver { public override int Rows => Curses.Lines; public override int Left => 0; public override int Top => 0; + [Obsolete ("This API is deprecated", false)] public override bool EnableConsoleScrolling { get; set; } - [Obsolete ("This API is deprecated; use EnableConsoleScrolling instead.", false)] - public override bool HeightAsBuffer { - get => EnableConsoleScrolling; - set => EnableConsoleScrolling = value; - } + [Obsolete ("This API is deprecated", false)] + public override bool HeightAsBuffer { get; set; } public override IClipboard Clipboard { get => clipboard; } CursorVisibility? initialCursorVisibility = null; diff --git a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs index 824a638292..fcb45bd9c6 100644 --- a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs @@ -45,12 +45,10 @@ public Behaviors (bool useFakeClipboard = false, bool fakeClipboardAlwaysThrowsN // Only handling left here because not all terminals has a horizontal scroll bar. public override int Left => 0; public override int Top => 0; + [Obsolete ("This API is deprecated", false)] public override bool EnableConsoleScrolling { get; set; } - [Obsolete ("This API is deprecated; use EnableConsoleScrolling instead.", false)] - public override bool HeightAsBuffer { - get => EnableConsoleScrolling; - set => EnableConsoleScrolling = value; - } + [Obsolete ("This API is deprecated", false)] + public override bool HeightAsBuffer { get; set; } private IClipboard clipboard = null; public override IClipboard Clipboard => clipboard; @@ -537,31 +535,24 @@ public void SetBufferSize (int width, int height) FakeConsole.SetBufferSize (width, height); cols = width; rows = height; - if (!EnableConsoleScrolling) { - SetWindowSize (width, height); - } + SetWindowSize (width, height); ProcessResize (); } public void SetWindowSize (int width, int height) { FakeConsole.SetWindowSize (width, height); - if (!EnableConsoleScrolling) { - if (width != cols || height != rows) { - SetBufferSize (width, height); - cols = width; - rows = height; - } + if (width != cols || height != rows) { + SetBufferSize (width, height); + cols = width; + rows = height; } ProcessResize (); } public void SetWindowPosition (int left, int top) { - if (EnableConsoleScrolling) { - this.left = Math.Max (Math.Min (left, Cols - FakeConsole.WindowWidth), 0); - this.top = Math.Max (Math.Min (top, Rows - FakeConsole.WindowHeight), 0); - } else if (this.left > 0 || this.top > 0) { + if (this.left > 0 || this.top > 0) { this.left = 0; this.top = 0; } @@ -577,29 +568,18 @@ void ProcessResize () public override void ResizeScreen () { - if (!EnableConsoleScrolling) { - if (FakeConsole.WindowHeight > 0) { - // Can raise an exception while is still resizing. - try { -#pragma warning disable CA1416 - FakeConsole.CursorTop = 0; - FakeConsole.CursorLeft = 0; - FakeConsole.WindowTop = 0; - FakeConsole.WindowLeft = 0; -#pragma warning restore CA1416 - } catch (System.IO.IOException) { - return; - } catch (ArgumentOutOfRangeException) { - return; - } - } - } else { + if (FakeConsole.WindowHeight > 0) { + // Can raise an exception while is still resizing. try { #pragma warning disable CA1416 - FakeConsole.WindowLeft = Math.Max (Math.Min (left, Cols - FakeConsole.WindowWidth), 0); - FakeConsole.WindowTop = Math.Max (Math.Min (top, Rows - FakeConsole.WindowHeight), 0); + FakeConsole.CursorTop = 0; + FakeConsole.CursorLeft = 0; + FakeConsole.WindowTop = 0; + FakeConsole.WindowLeft = 0; #pragma warning restore CA1416 - } catch (Exception) { + } catch (System.IO.IOException) { + return; + } catch (ArgumentOutOfRangeException) { return; } } diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index 45fcae946b..811426f441 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -113,7 +113,6 @@ internal class NetEvents { ConsoleDriver consoleDriver; volatile ConsoleKeyInfo [] cki = null; static volatile bool isEscSeq; - int lastWindowHeight; bool stopTasks; #if PROCESS_REQUEST bool neededProcessRequest; @@ -251,21 +250,11 @@ void WaitWinChange () bool IsWinChanged (int winHeight, int winWidth, int buffHeight, int buffWidth) { - if (!consoleDriver.EnableConsoleScrolling) { - if (winWidth != consoleDriver.Cols || winHeight != consoleDriver.Rows) { - var w = Math.Max (winWidth, 0); - var h = Math.Max (winHeight, 0); - GetWindowSizeEvent (new Size (w, h)); - return true; - } - } else { - if (winWidth != consoleDriver.Cols || winHeight != lastWindowHeight - || buffWidth != consoleDriver.Cols || buffHeight != consoleDriver.Rows) { - - lastWindowHeight = Math.Max (winHeight, 0); - GetWindowSizeEvent (new Size (winWidth, lastWindowHeight)); - return true; - } + if (winWidth != consoleDriver.Cols || winHeight != consoleDriver.Rows) { + var w = Math.Max (winWidth, 0); + var h = Math.Max (winHeight, 0); + GetWindowSizeEvent (new Size (w, h)); + return true; } return false; } @@ -584,20 +573,15 @@ internal class NetDriver : ConsoleDriver { public override int Rows => rows; public override int Left => left; public override int Top => top; + [Obsolete ("This API is deprecated", false)] public override bool EnableConsoleScrolling { get; set; } - [Obsolete ("This API is deprecated; use EnableConsoleScrolling instead.", false)] - public override bool HeightAsBuffer { - get => EnableConsoleScrolling; - set => EnableConsoleScrolling = value; - } - + [Obsolete ("This API is deprecated", false)] + public override bool HeightAsBuffer { get; set; } public NetWinVTConsole NetWinConsole { get; } public bool IsWinPlatform { get; } public override IClipboard Clipboard { get; } public override int [,,] Contents => contents; - int largestBufferHeight; - public NetDriver () { var p = Environment.OSVersion.Platform; @@ -752,14 +736,8 @@ public override void Init (Action terminalResized) Console.TreatControlCAsInput = true; - if (EnableConsoleScrolling) { - largestBufferHeight = Console.BufferHeight; - } else { - largestBufferHeight = Console.WindowHeight; - } - cols = Console.WindowWidth; - rows = largestBufferHeight; + rows = Console.WindowHeight; CurrentAttribute = MakeColor (Color.White, Color.Black); InitalizeColorSchemes (); @@ -775,54 +753,31 @@ public override void Init (Action terminalResized) public override void ResizeScreen () { - if (!EnableConsoleScrolling) { - if (Console.WindowHeight > 0) { - // Not supported on Unix. - if (IsWinPlatform) { - // Can raise an exception while is still resizing. - try { -#pragma warning disable CA1416 - Console.CursorTop = 0; - Console.CursorLeft = 0; - Console.WindowTop = 0; - Console.WindowLeft = 0; - if (Console.WindowHeight > Rows) { - Console.SetWindowSize (Cols, Rows); - } - Console.SetBufferSize (Cols, Rows); -#pragma warning restore CA1416 - } catch (System.IO.IOException) { - setClip (); - } catch (ArgumentOutOfRangeException) { - setClip (); - } - } else { - Console.Out.Write ($"\x1b[8;{Rows};{Cols}t"); - } - } - } else { + if (Console.WindowHeight > 0) { + // Not supported on Unix. if (IsWinPlatform) { - if (Console.WindowHeight > 0) { - // Can raise an exception while is still resizing. - try { + // Can raise an exception while is still resizing. + try { #pragma warning disable CA1416 - Console.CursorTop = 0; - Console.CursorLeft = 0; - if (Console.WindowHeight > Rows) { - Console.SetWindowSize (Cols, Rows); - } - Console.SetBufferSize (Cols, Rows); -#pragma warning restore CA1416 - } catch (System.IO.IOException) { - setClip (); - } catch (ArgumentOutOfRangeException) { - setClip (); + Console.CursorTop = 0; + Console.CursorLeft = 0; + Console.WindowTop = 0; + Console.WindowLeft = 0; + if (Console.WindowHeight > Rows) { + Console.SetWindowSize (Cols, Rows); } + Console.SetBufferSize (Cols, Rows); +#pragma warning restore CA1416 + } catch (System.IO.IOException) { + setClip (); + } catch (ArgumentOutOfRangeException) { + setClip (); } } else { - Console.Out.Write ($"\x1b[30;{Rows};{Cols}t"); + Console.Out.Write ($"\x1b[8;{Rows};{Cols}t"); } } + setClip (); void setClip () @@ -864,9 +819,7 @@ public override void Refresh () public override void UpdateScreen () { - if (winChanging || Console.WindowHeight < 1 || contents.Length != Rows * Cols * 3 - || (!EnableConsoleScrolling && Rows != Console.WindowHeight) - || (EnableConsoleScrolling && Rows != largestBufferHeight)) { + if (winChanging || Console.WindowHeight < 1 || contents.Length != Rows * Cols * 3 || Rows != Console.WindowHeight) { return; } @@ -1021,23 +974,6 @@ bool SetCursorPosition (int col, int row) private void SetWindowPosition (int col, int row) { - if (IsWinPlatform && EnableConsoleScrolling) { - var winTop = Math.Max (Rows - Console.WindowHeight - row, 0); - winTop = Math.Min (winTop, Rows - Console.WindowHeight + 1); - winTop = Math.Max (winTop, 0); - if (winTop != Console.WindowTop) { - try { - if (!EnsureBufferSize ()) { - return; - } -#pragma warning disable CA1416 - Console.SetWindowPosition (col, winTop); -#pragma warning restore CA1416 - } catch (System.IO.IOException) { - - } catch (System.ArgumentOutOfRangeException) { } - } - } top = Console.WindowTop; left = Console.WindowLeft; } @@ -1287,15 +1223,10 @@ void ProcessInput (NetEvents.InputResult inputEvent) void ChangeWin (Size size) { winChanging = true; - if (!EnableConsoleScrolling) { - largestBufferHeight = Math.Max (size.Height, 0); - } else { - largestBufferHeight = Math.Max (size.Height, largestBufferHeight); - } top = 0; left = 0; cols = size.Width; - rows = largestBufferHeight; + rows = Math.Max (size.Height, 0); ResizeScreen (); UpdateOffScreen (); winChanging = false; diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index aaf964c56a..71bd85a97c 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -714,12 +714,10 @@ internal class WindowsDriver : ConsoleDriver { public override int Rows => rows; public override int Left => left; public override int Top => top; + [Obsolete ("This API is deprecated", false)] public override bool EnableConsoleScrolling { get; set; } - [Obsolete ("This API is deprecated; use EnableConsoleScrolling instead.", false)] - public override bool HeightAsBuffer { - get => EnableConsoleScrolling; - set => EnableConsoleScrolling = value; - } + [Obsolete ("This API is deprecated", false)] + public override bool HeightAsBuffer { get; set; } public override IClipboard Clipboard => clipboard; public override int [,,] Contents => contents; diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 8d929682bc..233b0c1fac 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -111,8 +111,6 @@ public static Toplevel MdiTop { /// public static View WantContinuousButtonPressedView { get; private set; } - private static bool? _enableConsoleScrolling; - /// /// The current used in the terminal. /// @@ -128,32 +126,17 @@ public static Toplevel MdiTop { /// In this case console scrolling is enabled and the contents ( high) will scroll /// as the console scrolls. /// - /// This API was previously named 'HeightAsBuffer` but was renamed to make its purpose more clear. + /// This API is deprecated and has no impact when enabled. + /// This API was previously named 'HeightAsBuffer` but was renamed to make its purpose more clear. /// - public static bool EnableConsoleScrolling { - get { - if (Driver == null) { - return _enableConsoleScrolling.HasValue && _enableConsoleScrolling.Value; - } - return Driver.EnableConsoleScrolling; - } - set { - _enableConsoleScrolling = value; - if (Driver == null) { - return; - } - Driver.EnableConsoleScrolling = value; - } - } + [Obsolete ("This API is deprecated and has no impact when enabled.", false)] + public static bool EnableConsoleScrolling { get; set; } /// /// This API is deprecated; use instead. /// - [Obsolete ("This API is deprecated; use EnableConsoleScrolling instead.", false)] - public static bool HeightAsBuffer { - get => EnableConsoleScrolling; - set => EnableConsoleScrolling = value; - } + [Obsolete ("This API is deprecated and has no impact when enabled.", false)] + public static bool HeightAsBuffer { get; set; } static Key alternateForwardKey = Key.PageDown | Key.CtrlMask; @@ -449,7 +432,6 @@ internal static void InternalInit (Func topLevelFactory, ConsoleDriver MainLoop = new MainLoop (mainLoopDriver); try { - Driver.EnableConsoleScrolling = EnableConsoleScrolling; Driver.Init (TerminalResized); } catch (InvalidOperationException ex) { // This is a case where the driver is unable to initialize the console. @@ -1125,7 +1107,6 @@ static void ResetState () NotifyStopRunState = null; _initialized = false; mouseGrabView = null; - _enableConsoleScrolling = false; // Reset synchronization context to allow the user to run async/await, // as the main loop has been ended, the synchronization context from diff --git a/Terminal.Gui/Core/ConsoleDriver.cs b/Terminal.Gui/Core/ConsoleDriver.cs index 1a7fed26c6..1c51e0ac13 100644 --- a/Terminal.Gui/Core/ConsoleDriver.cs +++ b/Terminal.Gui/Core/ConsoleDriver.cs @@ -696,16 +696,16 @@ public abstract class ConsoleDriver { /// /// /// - /// NOTE: This functionaliy is currently broken on Windows Terminal. + /// NOTE: Changes to Windows Terminal prevents this functionality from working. It only really worked on Windows 'conhost' previously. /// + [Obsolete ("This API is deprecated and has no impact when enabled.", false)] public abstract bool EnableConsoleScrolling { get; set; } - /// - /// This API is deprecated; use instead. + /// This API is deprecated and has no impact when enabled. /// - [Obsolete ("This API is deprecated; use EnableConsoleScrolling instead.", false)] + [Obsolete ("This API is deprecated and has no impact when enabled.", false)] public abstract bool HeightAsBuffer { get; set; } - + /// /// The format is rows, columns and 3 values on the last column: Rune, Attribute and Dirty Flag /// diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index b49d70312e..86cc3ba026 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -121,8 +121,6 @@ static Scenario RunUICatalogTopLevel () // a Scenario was selected. Otherwise, the user wants to exit UI Catalog. Application.Init (); - Application.EnableConsoleScrolling = _enableConsoleScrolling; - Application.Run (); Application.Shutdown (); @@ -144,7 +142,6 @@ static Scenario RunUICatalogTopLevel () static bool _useSystemConsole = false; static ConsoleDriver.DiagnosticFlags _diagnosticFlags; - static bool _enableConsoleScrolling = false; static bool _isFirstRunning = true; static ColorScheme _colorScheme; @@ -154,7 +151,6 @@ static Scenario RunUICatalogTopLevel () /// class UICatalogTopLevel : Toplevel { public MenuItem miIsMouseDisabled; - public MenuItem miEnableConsoleScrolling; public FrameView LeftPane; public ListView CategoryListView; @@ -282,7 +278,6 @@ void LoadedHandler () } miIsMouseDisabled.Checked = Application.IsMouseDisabled; - miEnableConsoleScrolling.Checked = Application.EnableConsoleScrolling; DriverName.Title = $"Driver: {Driver.GetType ().Name}"; OS.Title = $"OS: {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystem} {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion}"; @@ -319,7 +314,6 @@ List CreateDiagnosticMenuItems () List menuItems = new List (); menuItems.Add (CreateDiagnosticFlagsMenuItems ()); menuItems.Add (new MenuItem [] { null }); - menuItems.Add (CreateEnableConsoleScrollingMenuItems ()); menuItems.Add (CreateDisabledEnabledMouseItems ()); menuItems.Add (CreateKeybindingsMenuItems ()); return menuItems; @@ -357,22 +351,6 @@ MenuItem [] CreateKeybindingsMenuItems () return menuItems.ToArray (); } - MenuItem [] CreateEnableConsoleScrollingMenuItems () - { - List menuItems = new List (); - miEnableConsoleScrolling = new MenuItem (); - miEnableConsoleScrolling.Title = "_Enable Console Scrolling"; - miEnableConsoleScrolling.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miEnableConsoleScrolling.Title.ToString ().Substring (1, 1) [0]; - miEnableConsoleScrolling.CheckType |= MenuItemCheckStyle.Checked; - miEnableConsoleScrolling.Action += () => { - miEnableConsoleScrolling.Checked = !miEnableConsoleScrolling.Checked; - Application.EnableConsoleScrolling = miEnableConsoleScrolling.Checked; - }; - menuItems.Add (miEnableConsoleScrolling); - - return menuItems.ToArray (); - } - MenuItem [] CreateDiagnosticFlagsMenuItems () { const string OFF = "Diagnostics: _Off"; diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index 637174d172..9a293a1b50 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -24,7 +24,6 @@ void Pre_Init_State () Assert.Null (Application.Driver); Assert.Null (Application.Top); Assert.Null (Application.Current); - Assert.False (Application.EnableConsoleScrolling); Assert.Null (Application.MainLoop); Assert.Null (Application.Iteration); Assert.Null (Application.RootMouseEvent); @@ -36,7 +35,6 @@ void Post_Init_State () Assert.NotNull (Application.Driver); Assert.NotNull (Application.Top); Assert.NotNull (Application.Current); - Assert.False (Application.EnableConsoleScrolling); Assert.NotNull (Application.MainLoop); Assert.Null (Application.Iteration); Assert.Null (Application.RootMouseEvent); diff --git a/UnitTests/Drivers/ConsoleDriverTests.cs b/UnitTests/Drivers/ConsoleDriverTests.cs index 6444b8f1c0..cf64659209 100644 --- a/UnitTests/Drivers/ConsoleDriverTests.cs +++ b/UnitTests/Drivers/ConsoleDriverTests.cs @@ -169,29 +169,16 @@ public void TerminalResized_Simulation (Type driverType) Assert.Equal (40, Application.Driver.Rows); Assert.True (wasTerminalResized); - // MockDriver will still be 120x40 - wasTerminalResized = false; - Application.EnableConsoleScrolling = true; - driver.SetWindowSize (40, 20); - Assert.Equal (120, Application.Driver.Cols); - Assert.Equal (40, Application.Driver.Rows); - Assert.Equal (120, Console.BufferWidth); - Assert.Equal (40, Console.BufferHeight); - Assert.Equal (40, Console.WindowWidth); - Assert.Equal (20, Console.WindowHeight); - Assert.True (wasTerminalResized); - Application.Shutdown (); } [Theory] [InlineData (typeof (FakeDriver))] - public void EnableConsoleScrolling_Is_False_Left_And_Top_Is_Always_Zero (Type driverType) + public void Left_And_Top_Is_Always_Zero (Type driverType) { var driver = (FakeDriver)Activator.CreateInstance (driverType); Application.Init (driver); - Assert.False (Application.EnableConsoleScrolling); Assert.Equal (0, Console.WindowLeft); Assert.Equal (0, Console.WindowTop); @@ -201,124 +188,7 @@ public void EnableConsoleScrolling_Is_False_Left_And_Top_Is_Always_Zero (Type dr Application.Shutdown (); } - - [Theory] - [InlineData (typeof (FakeDriver))] - public void EnableConsoleScrolling_Is_True_Left_Cannot_Be_Greater_Than_WindowWidth (Type driverType) - { - var driver = (FakeDriver)Activator.CreateInstance (driverType); - Application.Init (driver); - - Application.EnableConsoleScrolling = true; - Assert.True (Application.EnableConsoleScrolling); - - driver.SetWindowPosition (81, 25); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - - Application.Shutdown (); - } - - [Theory] - [InlineData (typeof (FakeDriver))] - public void EnableConsoleScrolling_Is_True_Left_Cannot_Be_Greater_Than_BufferWidth_Minus_WindowWidth (Type driverType) - { - var driver = (FakeDriver)Activator.CreateInstance (driverType); - Application.Init (driver); - - Application.EnableConsoleScrolling = true; - Assert.True (Application.EnableConsoleScrolling); - - driver.SetWindowPosition (81, 25); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - - // MockDriver will now be sets to 120x25 - driver.SetBufferSize (120, 25); - Assert.Equal (120, Application.Driver.Cols); - Assert.Equal (25, Application.Driver.Rows); - Assert.Equal (120, Console.BufferWidth); - Assert.Equal (25, Console.BufferHeight); - Assert.Equal (80, Console.WindowWidth); - Assert.Equal (25, Console.WindowHeight); - driver.SetWindowPosition (121, 25); - Assert.Equal (40, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - - driver.SetWindowSize (90, 25); - Assert.Equal (120, Application.Driver.Cols); - Assert.Equal (25, Application.Driver.Rows); - Assert.Equal (120, Console.BufferWidth); - Assert.Equal (25, Console.BufferHeight); - Assert.Equal (90, Console.WindowWidth); - Assert.Equal (25, Console.WindowHeight); - driver.SetWindowPosition (121, 25); - Assert.Equal (30, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - - Application.Shutdown (); - } - - [Theory] - [InlineData (typeof (FakeDriver))] - public void EnableConsoleScrolling_Is_True_Top_Cannot_Be_Greater_Than_WindowHeight (Type driverType) - { - var driver = (FakeDriver)Activator.CreateInstance (driverType); - Application.Init (driver); - - Application.EnableConsoleScrolling = true; - Assert.True (Application.EnableConsoleScrolling); - - driver.SetWindowPosition (80, 26); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - - Application.Shutdown (); - } - - [Theory] - [InlineData (typeof (FakeDriver))] - public void EnableConsoleScrolling_Is_True_Top_Cannot_Be_Greater_Than_BufferHeight_Minus_WindowHeight (Type driverType) - { - var driver = (FakeDriver)Activator.CreateInstance (driverType); - Application.Init (driver); - - Application.EnableConsoleScrolling = true; - Assert.True (Application.EnableConsoleScrolling); - - driver.SetWindowPosition (80, 26); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - - // MockDriver will now be sets to 80x40 - driver.SetBufferSize (80, 40); - Assert.Equal (80, Application.Driver.Cols); - Assert.Equal (40, Application.Driver.Rows); - Assert.Equal (80, Console.BufferWidth); - Assert.Equal (40, Console.BufferHeight); - Assert.Equal (80, Console.WindowWidth); - Assert.Equal (25, Console.WindowHeight); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (0, Console.WindowTop); - driver.SetWindowPosition (80, 40); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (15, Console.WindowTop); - - driver.SetWindowSize (80, 20); - Assert.Equal (80, Application.Driver.Cols); - Assert.Equal (40, Application.Driver.Rows); - Assert.Equal (80, Console.BufferWidth); - Assert.Equal (40, Console.BufferHeight); - Assert.Equal (80, Console.WindowWidth); - Assert.Equal (20, Console.WindowHeight); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (15, Console.WindowTop); - driver.SetWindowPosition (80, 41); - Assert.Equal (0, Console.WindowLeft); - Assert.Equal (20, Console.WindowTop); - - Application.Shutdown (); - } + [Fact, AutoInitShutdown] public void AddRune_On_Clip_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space () diff --git a/UnitTests/xunit.runner.json b/UnitTests/xunit.runner.json index d47a70ea08..c108763855 100644 --- a/UnitTests/xunit.runner.json +++ b/UnitTests/xunit.runner.json @@ -2,5 +2,5 @@ "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", "parallelizeTestCollections": false, "parallelizeAssembly": false, - "stopOnFail": false + "stopOnFail": true }