Skip to content

Commit 3a8cbf3

Browse files
authored
Revert "Fixes #4274. Using Windows Host Console v2win is rendering window siz…" (#4286)
This reverts commit 75f5a84.
1 parent 75f5a84 commit 3a8cbf3

File tree

11 files changed

+23
-80
lines changed

11 files changed

+23
-80
lines changed

Examples/UICatalog/Scenarios/CombiningMarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public override void Main ()
1313
top.DrawComplete += (s, e) =>
1414
{
1515
// Forces reset _lineColsOffset because we're dealing with direct draw
16-
Application.Top!.SetNeedsDraw ();
16+
Application.ClearScreenNextIteration = true;
1717

1818
var i = -1;
1919
top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616.");

Examples/UICatalog/Scenarios/Shortcuts.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ public class Shortcuts : Scenario
1212
public override void Main ()
1313
{
1414
Application.Init ();
15-
var quitKey = Application.QuitKey;
1615
Window app = new ();
1716

1817
app.Loaded += App_Loaded;
1918

2019
Application.Run (app);
2120
app.Dispose ();
2221
Application.Shutdown ();
23-
Application.QuitKey = quitKey;
2422
}
2523

2624
// Setting everything up in Loaded handler because we change the

Terminal.Gui/App/Application.Screen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public static bool OnSizeChanging (SizeChangedEventArgs args)
8282
/// Gets or sets whether the screen will be cleared, and all Views redrawn, during the next Application iteration.
8383
/// </summary>
8484
/// <remarks>
85-
/// This is typical set to true when a View's <see cref="View.Frame"/> changes and that view has no
85+
/// This is typicall set to true when a View's <see cref="View.Frame"/> changes and that view has no
8686
/// SuperView (e.g. when <see cref="Application.Top"/> is moved or resized.
8787
/// </remarks>
88-
internal static bool ClearScreenNextIteration { get; set; }
88+
public static bool ClearScreenNextIteration { get; set; }
8989
}

Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ [In] ref WindowsConsole.SmallRect lpConsoleWindow
100100
private readonly nint _outputHandle;
101101
private nint _screenBuffer;
102102
private readonly bool _isVirtualTerminal;
103-
private readonly ConsoleColor _foreground;
104-
private readonly ConsoleColor _background;
105103

106104
public WindowsOutput ()
107105
{
@@ -119,16 +117,8 @@ public WindowsOutput ()
119117

120118
if (_isVirtualTerminal)
121119
{
122-
if (Environment.GetEnvironmentVariable ("VSAPPIDNAME") is null)
123-
{
124-
//Enable alternative screen buffer.
125-
Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll);
126-
}
127-
else
128-
{
129-
_foreground = Console.ForegroundColor;
130-
_background = Console.BackgroundColor;
131-
}
120+
//Enable alternative screen buffer.
121+
Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll);
132122
}
133123
else
134124
{
@@ -512,18 +502,8 @@ public void Dispose ()
512502

513503
if (_isVirtualTerminal)
514504
{
515-
if (Environment.GetEnvironmentVariable ("VSAPPIDNAME") is null)
516-
{
517-
//Disable alternative screen buffer.
518-
Console.Out.Write (EscSeqUtils.CSI_RestoreCursorAndRestoreAltBufferWithBackscroll);
519-
}
520-
else
521-
{
522-
// Simulate restoring the color and clearing the screen.
523-
Console.ForegroundColor = _foreground;
524-
Console.BackgroundColor = _background;
525-
Console.Clear ();
526-
}
505+
//Disable alternative screen buffer.
506+
Console.Out.Write (EscSeqUtils.CSI_RestoreCursorAndRestoreAltBufferWithBackscroll);
527507
}
528508
else
529509
{

Terminal.Gui/ViewBase/View.Layout.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ public Pos X
239239
_x = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (X)} cannot be null");
240240

241241
PosDimSet ();
242-
243-
NeedsClearScreenNextIteration ();
244242
}
245243
}
246244

@@ -283,8 +281,6 @@ public Pos Y
283281

284282
_y = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Y)} cannot be null");
285283
PosDimSet ();
286-
287-
NeedsClearScreenNextIteration ();
288284
}
289285
}
290286

@@ -343,8 +339,6 @@ public Dim Height
343339
OnHeightChanged,
344340
HeightChanged,
345341
out Dim _);
346-
347-
NeedsClearScreenNextIteration ();
348342
}
349343
}
350344

@@ -431,17 +425,6 @@ public Dim Width
431425
OnWidthChanged,
432426
WidthChanged,
433427
out Dim _);
434-
435-
NeedsClearScreenNextIteration ();
436-
}
437-
}
438-
439-
private void NeedsClearScreenNextIteration ()
440-
{
441-
if (Application.Top is { } && Application.Top == this && Application.TopLevels.Count == 1)
442-
{
443-
// If this is the only TopLevel, we need to redraw the screen
444-
Application.ClearScreenNextIteration = true;
445428
}
446429
}
447430

@@ -670,9 +653,10 @@ public bool SetRelativeLayout (Size superviewContentSize)
670653
{
671654
SuperView?.SetNeedsDraw ();
672655
}
673-
else
656+
else if (Application.TopLevels.Count == 1)
674657
{
675-
NeedsClearScreenNextIteration ();
658+
// If this is the only TopLevel, we need to redraw the screen
659+
Application.ClearScreenNextIteration = true;
676660
}
677661
}
678662

Terminal.Gui/ViewBase/View.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public virtual bool Visible
378378
}
379379
else
380380
{
381-
NeedsClearScreenNextIteration ();
381+
Application.ClearScreenNextIteration = true;
382382
}
383383
}
384384
}

Tests/IntegrationTests/UICatalog/ScenarioTests.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public void All_Scenarios_Quit_And_Init_Shutdown_Properly (Type scenarioType)
4141

4242
_output.WriteLine ($"Running Scenario '{scenarioType}'");
4343
var scenario = Activator.CreateInstance (scenarioType) as Scenario;
44-
var scenarioName = scenario!.GetName ();
4544

46-
uint abortTime = 2200;
45+
uint abortTime = 2000;
4746
object? timeout = null;
4847
var initialized = false;
4948
var shutdownGracefully = false;
@@ -71,7 +70,7 @@ public void All_Scenarios_Quit_And_Init_Shutdown_Properly (Type scenarioType)
7170
Assert.True (initialized);
7271

7372

74-
Assert.True (shutdownGracefully, $"Scenario '{scenarioName}' Failed to Quit with {quitKey} after {abortTime}ms and {iterationCount} iterations. Force quit.");
73+
Assert.True (shutdownGracefully, $"Scenario Failed to Quit with {quitKey} after {abortTime}ms and {iterationCount} iterations. Force quit.");
7574

7675
#if DEBUG_IDISPOSABLE
7776
Assert.Empty (View.Instances);
@@ -92,6 +91,11 @@ void OnApplicationOnInitializedChanged (object? s, EventArgs<bool> a)
9291
{
9392
Application.Iteration += OnApplicationOnIteration;
9493
initialized = true;
94+
95+
lock (_timeoutLock)
96+
{
97+
timeout = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), ForceCloseCallback);
98+
}
9599
}
96100
else
97101
{
@@ -122,15 +126,6 @@ bool ForceCloseCallback ()
122126

123127
void OnApplicationOnIteration (object? s, IterationEventArgs a)
124128
{
125-
if (iterationCount == 0)
126-
{
127-
// Start the timeout countdown on the first iteration
128-
lock (_timeoutLock)
129-
{
130-
timeout = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), ForceCloseCallback);
131-
}
132-
}
133-
134129
iterationCount++;
135130

136131
if (Application.Initialized)

Tests/UnitTests/Application/ApplicationScreenTests.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void ClearContents_Called_When_Top_Frame_Changes ()
4747
Assert.Equal (0, clearedContentsRaised);
4848

4949
// Act
50-
Application.Top!.SetNeedsLayout ();
50+
Application.Top.SetNeedsLayout ();
5151
Application.LayoutAndDraw ();
5252

5353
// Assert
@@ -67,20 +67,6 @@ public void ClearContents_Called_When_Top_Frame_Changes ()
6767
// Assert
6868
Assert.Equal (2, clearedContentsRaised);
6969

70-
// Act
71-
Application.Top.Y = 1;
72-
Application.LayoutAndDraw ();
73-
74-
// Assert
75-
Assert.Equal (3, clearedContentsRaised);
76-
77-
// Act
78-
Application.Top.Height = 10;
79-
Application.LayoutAndDraw ();
80-
81-
// Assert
82-
Assert.Equal (4, clearedContentsRaised);
83-
8470
Application.End (rs);
8571

8672
return;

Tests/UnitTests/Application/SynchronizatonContextTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class SyncrhonizationContextTests
1010
public void SynchronizationContext_CreateCopy ()
1111
{
1212
ConsoleDriver.RunningUnitTests = true;
13-
Application.Init (null, "fake");
13+
Application.Init ();
1414
SynchronizationContext context = SynchronizationContext.Current;
1515
Assert.NotNull (context);
1616

Tests/UnitTests/Configuration/ConfigurationMangerTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,8 @@ public void UpdateFromJson ()
10101010
finally
10111011
{
10121012
Disable (resetToHardCodedDefaults: true);
1013+
10131014
}
10141015
}
1016+
10151017
}

0 commit comments

Comments
 (0)