diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index ed140fed6..c0b780ebd 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -109,7 +109,7 @@ public static partial class Application { /// /// The to use. If neither or are specified the default driver for the platform will be used. /// The short name (e.g. "net", "windows", "ansi", "fake", or "curses") of the to use. If neither or are specified the default driver for the platform will be used. - public static void Init (ConsoleDriver driver = null, string driverName = null) => InternalInit (Toplevel.Create, driver, driverName); + public static void Init (ConsoleDriver driver = null, string driverName = null) => InternalInit (() => new Toplevel(), driver, driverName); internal static bool _initialized = false; internal static int _mainThreadId = -1; @@ -194,6 +194,10 @@ public static partial class Application { Top = topLevelFactory (); Current = Top; + + // Ensure Top's layout is up to date. + Current.SetRelativeLayout (new Rect (0, 0, Driver.Cols, Driver.Rows)); + _cachedSupportedCultures = GetSupportedCultures (); _mainThreadId = Thread.CurrentThread.ManagedThreadId; _initialized = true; diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index 313753fb5..9df50b683 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -52,16 +52,6 @@ public partial class Toplevel : View { Height = Dim.Fill (); } - /// - /// Convenience factory method that creates a new Toplevel. - /// - /// - /// The and properties - /// will be set to the dimensions of the terminal using . - /// - /// The created Toplevel. - public static Toplevel Create () => new (); // BUGBUG: Should be ComputedLayout - /// /// Gets or sets whether the main loop for this is running or not. /// diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index 0b49293fb..5dbc3a9c0 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -570,8 +570,6 @@ public class ApplicationTests { public void Begin_Sets_Application_Top_To_Console_Size () { Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame); - - ((FakeDriver)Application.Driver).SetBufferSize (5, 5); Application.Begin (Application.Top); Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame); ((FakeDriver)Application.Driver).SetBufferSize (5, 5); diff --git a/UnitTests/View/NavigationTests.cs b/UnitTests/View/NavigationTests.cs index d34e54aed..fad71ef06 100644 --- a/UnitTests/View/NavigationTests.cs +++ b/UnitTests/View/NavigationTests.cs @@ -1001,7 +1001,7 @@ namespace Terminal.Gui.ViewTests { { // Arrange Application.Init (); - using var top = Toplevel.Create (); + using var top = new Toplevel (); using var view = new View ( x: 0, y: 1, diff --git a/UnitTests/Views/Toplevel/ToplevelTests.cs b/UnitTests/Views/Toplevel/ToplevelTests.cs index b66f0ca12..071252e9d 100644 --- a/UnitTests/Views/Toplevel/ToplevelTests.cs +++ b/UnitTests/Views/Toplevel/ToplevelTests.cs @@ -36,7 +36,7 @@ public class ToplevelTests { [AutoInitShutdown] public void Create_Toplevel () { - var top = Toplevel.Create (); + var top = new Toplevel (); Assert.Equal (Colors.TopLevel, top.ColorScheme); Assert.Equal ("Fill(0)", top.Width.ToString ());