Fixes #786. Workaround for resizing with Init/Shutdown.

This commit is contained in:
BDisp
2020-07-15 19:25:13 +01:00
parent 5d0d924128
commit 874224d9f8
4 changed files with 27 additions and 7 deletions

View File

@@ -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 ();

View File

@@ -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;
/// <summary>
/// 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)

View File

@@ -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);
}
/// <summary>

View File

@@ -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;
}