diff --git a/Examples/UICatalog/Scenarios/CombiningMarks.cs b/Examples/UICatalog/Scenarios/CombiningMarks.cs index 7d8437a23..6e0467ce0 100644 --- a/Examples/UICatalog/Scenarios/CombiningMarks.cs +++ b/Examples/UICatalog/Scenarios/CombiningMarks.cs @@ -13,7 +13,7 @@ public class CombiningMarks : Scenario top.DrawComplete += (s, e) => { // Forces reset _lineColsOffset because we're dealing with direct draw - Application.Top!.SetNeedsDraw (); + Application.ClearScreenNextIteration = true; var i = -1; top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616."); diff --git a/Examples/UICatalog/Scenarios/Shortcuts.cs b/Examples/UICatalog/Scenarios/Shortcuts.cs index c96dccd7c..73ec7a5dd 100644 --- a/Examples/UICatalog/Scenarios/Shortcuts.cs +++ b/Examples/UICatalog/Scenarios/Shortcuts.cs @@ -12,7 +12,6 @@ public class Shortcuts : Scenario public override void Main () { Application.Init (); - var quitKey = Application.QuitKey; Window app = new (); app.Loaded += App_Loaded; @@ -20,7 +19,6 @@ public class Shortcuts : Scenario Application.Run (app); app.Dispose (); Application.Shutdown (); - Application.QuitKey = quitKey; } // Setting everything up in Loaded handler because we change the diff --git a/Terminal.Gui/App/Application.Screen.cs b/Terminal.Gui/App/Application.Screen.cs index 1ceed1d7c..cc9dcb0b6 100644 --- a/Terminal.Gui/App/Application.Screen.cs +++ b/Terminal.Gui/App/Application.Screen.cs @@ -82,8 +82,8 @@ public static partial class Application // Screen related stuff /// Gets or sets whether the screen will be cleared, and all Views redrawn, during the next Application iteration. /// /// - /// This is typical set to true when a View's changes and that view has no + /// This is typicall set to true when a View's changes and that view has no /// SuperView (e.g. when is moved or resized. /// - internal static bool ClearScreenNextIteration { get; set; } + public static bool ClearScreenNextIteration { get; set; } } diff --git a/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs b/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs index 6c5f806c7..4c14cd6ed 100644 --- a/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs +++ b/Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs @@ -100,8 +100,6 @@ 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 () { @@ -119,16 +117,8 @@ internal partial class WindowsOutput : OutputBase, IConsoleOutput if (_isVirtualTerminal) { - if (Environment.GetEnvironmentVariable ("VSAPPIDNAME") is null) - { - //Enable alternative screen buffer. - Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll); - } - else - { - _foreground = Console.ForegroundColor; - _background = Console.BackgroundColor; - } + //Enable alternative screen buffer. + Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll); } else { @@ -512,18 +502,8 @@ internal partial class WindowsOutput : OutputBase, IConsoleOutput if (_isVirtualTerminal) { - if (Environment.GetEnvironmentVariable ("VSAPPIDNAME") is null) - { - //Disable alternative screen buffer. - Console.Out.Write (EscSeqUtils.CSI_RestoreCursorAndRestoreAltBufferWithBackscroll); - } - else - { - // Simulate restoring the color and clearing the screen. - Console.ForegroundColor = _foreground; - Console.BackgroundColor = _background; - Console.Clear (); - } + //Disable alternative screen buffer. + Console.Out.Write (EscSeqUtils.CSI_RestoreCursorAndRestoreAltBufferWithBackscroll); } else { diff --git a/Terminal.Gui/ViewBase/View.Layout.cs b/Terminal.Gui/ViewBase/View.Layout.cs index 72bb409b3..8f28cdba2 100644 --- a/Terminal.Gui/ViewBase/View.Layout.cs +++ b/Terminal.Gui/ViewBase/View.Layout.cs @@ -239,8 +239,6 @@ public partial class View // Layout APIs _x = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (X)} cannot be null"); PosDimSet (); - - NeedsClearScreenNextIteration (); } } @@ -283,8 +281,6 @@ public partial class View // Layout APIs _y = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Y)} cannot be null"); PosDimSet (); - - NeedsClearScreenNextIteration (); } } @@ -343,8 +339,6 @@ public partial class View // Layout APIs OnHeightChanged, HeightChanged, out Dim _); - - NeedsClearScreenNextIteration (); } } @@ -431,17 +425,6 @@ public partial class View // Layout APIs OnWidthChanged, WidthChanged, out Dim _); - - NeedsClearScreenNextIteration (); - } - } - - private void NeedsClearScreenNextIteration () - { - if (Application.Top is { } && Application.Top == this && Application.TopLevels.Count == 1) - { - // If this is the only TopLevel, we need to redraw the screen - Application.ClearScreenNextIteration = true; } } @@ -670,9 +653,10 @@ public partial class View // Layout APIs { SuperView?.SetNeedsDraw (); } - else + else if (Application.TopLevels.Count == 1) { - NeedsClearScreenNextIteration (); + // If this is the only TopLevel, we need to redraw the screen + Application.ClearScreenNextIteration = true; } } diff --git a/Terminal.Gui/ViewBase/View.cs b/Terminal.Gui/ViewBase/View.cs index 27c0780f7..3edf1e768 100644 --- a/Terminal.Gui/ViewBase/View.cs +++ b/Terminal.Gui/ViewBase/View.cs @@ -378,7 +378,7 @@ public partial class View : IDisposable, ISupportInitializeNotification } else { - NeedsClearScreenNextIteration (); + Application.ClearScreenNextIteration = true; } } } diff --git a/Tests/IntegrationTests/UICatalog/ScenarioTests.cs b/Tests/IntegrationTests/UICatalog/ScenarioTests.cs index 12517df84..7fa654e9e 100644 --- a/Tests/IntegrationTests/UICatalog/ScenarioTests.cs +++ b/Tests/IntegrationTests/UICatalog/ScenarioTests.cs @@ -41,9 +41,8 @@ public class ScenarioTests : TestsAllViews _output.WriteLine ($"Running Scenario '{scenarioType}'"); var scenario = Activator.CreateInstance (scenarioType) as Scenario; - var scenarioName = scenario!.GetName (); - uint abortTime = 2200; + uint abortTime = 2000; object? timeout = null; var initialized = false; var shutdownGracefully = false; @@ -71,7 +70,7 @@ public class ScenarioTests : TestsAllViews Assert.True (initialized); - Assert.True (shutdownGracefully, $"Scenario '{scenarioName}' Failed to Quit with {quitKey} after {abortTime}ms and {iterationCount} iterations. Force quit."); + Assert.True (shutdownGracefully, $"Scenario Failed to Quit with {quitKey} after {abortTime}ms and {iterationCount} iterations. Force quit."); #if DEBUG_IDISPOSABLE Assert.Empty (View.Instances); @@ -92,6 +91,11 @@ public class ScenarioTests : TestsAllViews { Application.Iteration += OnApplicationOnIteration; initialized = true; + + lock (_timeoutLock) + { + timeout = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), ForceCloseCallback); + } } else { @@ -122,15 +126,6 @@ public class ScenarioTests : TestsAllViews void OnApplicationOnIteration (object? s, IterationEventArgs a) { - if (iterationCount == 0) - { - // Start the timeout countdown on the first iteration - lock (_timeoutLock) - { - timeout = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), ForceCloseCallback); - } - } - iterationCount++; if (Application.Initialized) diff --git a/Tests/UnitTests/Application/ApplicationScreenTests.cs b/Tests/UnitTests/Application/ApplicationScreenTests.cs index 675b683ad..0086cb01b 100644 --- a/Tests/UnitTests/Application/ApplicationScreenTests.cs +++ b/Tests/UnitTests/Application/ApplicationScreenTests.cs @@ -47,7 +47,7 @@ public class ApplicationScreenTests Assert.Equal (0, clearedContentsRaised); // Act - Application.Top!.SetNeedsLayout (); + Application.Top.SetNeedsLayout (); Application.LayoutAndDraw (); // Assert @@ -67,20 +67,6 @@ public class ApplicationScreenTests // Assert Assert.Equal (2, clearedContentsRaised); - // Act - Application.Top.Y = 1; - Application.LayoutAndDraw (); - - // Assert - Assert.Equal (3, clearedContentsRaised); - - // Act - Application.Top.Height = 10; - Application.LayoutAndDraw (); - - // Assert - Assert.Equal (4, clearedContentsRaised); - Application.End (rs); return; diff --git a/Tests/UnitTests/Application/SynchronizatonContextTests.cs b/Tests/UnitTests/Application/SynchronizatonContextTests.cs index e049dcb03..6546692df 100644 --- a/Tests/UnitTests/Application/SynchronizatonContextTests.cs +++ b/Tests/UnitTests/Application/SynchronizatonContextTests.cs @@ -10,7 +10,7 @@ public class SyncrhonizationContextTests public void SynchronizationContext_CreateCopy () { ConsoleDriver.RunningUnitTests = true; - Application.Init (null, "fake"); + Application.Init (); SynchronizationContext context = SynchronizationContext.Current; Assert.NotNull (context); diff --git a/Tests/UnitTests/Configuration/ConfigurationMangerTests.cs b/Tests/UnitTests/Configuration/ConfigurationMangerTests.cs index 77ac743c0..4e0774f1f 100644 --- a/Tests/UnitTests/Configuration/ConfigurationMangerTests.cs +++ b/Tests/UnitTests/Configuration/ConfigurationMangerTests.cs @@ -1010,6 +1010,8 @@ public class ConfigurationManagerTests (ITestOutputHelper output) finally { Disable (resetToHardCodedDefaults: true); + } } + } diff --git a/Tests/UnitTests/Views/ComboBoxTests.cs b/Tests/UnitTests/Views/ComboBoxTests.cs index a8caab2c7..9466b47fb 100644 --- a/Tests/UnitTests/Views/ComboBoxTests.cs +++ b/Tests/UnitTests/Views/ComboBoxTests.cs @@ -525,9 +525,7 @@ public class ComboBoxTests (ITestOutputHelper output) Assert.True (cb.IsShow); Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); - Assert.False (Application.ClearScreenNextIteration); - Assert.True (cb.NeedsLayout); - Assert.True (cb.NeedsDraw); + cb.Layout (); cb.Draw ();