diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index c507f9122..756fa880c 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -495,13 +495,30 @@ namespace Terminal.Gui { public override int Rows => rows; public WindowsDriver () + { + Initialize (); + } + + public WindowsDriver (int cols, int rows) + { + this.cols = cols; + this.rows = rows; + + Initialize (); + } + + void Initialize () { winConsole = new WindowsConsole (); SetupColorsAndBorders (); - cols = Console.WindowWidth; - rows = Console.WindowHeight; + if (cols == 0 && rows == 0) { + cols = Console.WindowWidth; + rows = Console.WindowHeight; + } else { + Console.SetWindowSize (cols, rows); + } WindowsConsole.SmallRect.MakeEmpty (ref damageRegion); ResizeScreen (); diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 9e4003c9f..e78801bae 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -161,8 +161,9 @@ namespace Terminal.Gui { internal static bool _initialized = false; + static int cols, rows; static IMainLoopDriver oldMainLoopDriver; - static ConsoleDriver oldDriver; + static ConsoleDriver oldDriver; /// /// Initializes the Terminal.Gui application @@ -188,7 +189,7 @@ namespace Terminal.Gui { mainLoopDriver = new NetMainLoop (() => Console.ReadKey (true)); Driver = new NetDriver (); } else if (p == PlatformID.Win32NT || p == PlatformID.Win32S || p == PlatformID.Win32Windows) { - var windowsDriver = new WindowsDriver (); + var windowsDriver = cols == 0 && rows == 0 ? new WindowsDriver () : new WindowsDriver (cols, rows); mainLoopDriver = windowsDriver; Driver = windowsDriver; } else { @@ -556,6 +557,8 @@ namespace Terminal.Gui { } last?.PositionCursor (); Driver.Refresh (); + cols = Driver.Cols; + rows = Driver.Rows; } internal static void End (View view, bool closeDriver = true) diff --git a/UICatalog/Scenario.cs b/UICatalog/Scenario.cs index 1073db24b..45d2aae16 100644 --- a/UICatalog/Scenario.cs +++ b/UICatalog/Scenario.cs @@ -198,7 +198,7 @@ namespace UICatalog { public virtual void Run () { // This method already performs a later automatic shutdown. - Application.Run (Top, false); + Application.Run (Top); } /// diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 2bb3866c0..5770a0246 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -127,7 +127,7 @@ namespace UICatalog { Application.UseSystemConsole = false; Application.Init (); - // Set this here because not initilzied until driver is loaded + // Set this here because not initialized until driver is loaded _baseColorScheme = Colors.Base; StringBuilder aboutMessage = new StringBuilder (); @@ -235,7 +235,7 @@ namespace UICatalog { } }; - Application.Run (_top, true); + Application.Run (_top); Application.Shutdown (); return _runningScenario; }