mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 01:38:01 +01:00
Fixes #787. Console default size is always restored on Driver Init.
This commit is contained in:
@@ -439,6 +439,23 @@ namespace Terminal.Gui {
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport ("kernel32.dll", ExactSpelling = true)]
|
||||
private static extern IntPtr GetConsoleWindow ();
|
||||
|
||||
[DllImport ("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern bool ShowWindow (IntPtr hWnd, int nCmdShow);
|
||||
|
||||
public const int HIDE = 0;
|
||||
public const int MAXIMIZE = 3;
|
||||
public const int MINIMIZE = 6;
|
||||
public const int RESTORE = 9;
|
||||
|
||||
internal void ShowWindow (int state)
|
||||
{
|
||||
IntPtr thisConsole = GetConsoleWindow ();
|
||||
ShowWindow (thisConsole, state);
|
||||
}
|
||||
|
||||
#if false // See: https://github.com/migueldeicaza/gui.cs/issues/357
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
public struct SMALL_RECT {
|
||||
@@ -495,30 +512,15 @@ 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 ();
|
||||
|
||||
if (cols == 0 && rows == 0) {
|
||||
cols = Console.WindowWidth;
|
||||
rows = Console.WindowHeight;
|
||||
} else {
|
||||
Console.SetWindowSize (cols, rows);
|
||||
}
|
||||
cols = Console.WindowWidth;
|
||||
rows = Console.WindowHeight;
|
||||
winConsole.ShowWindow (WindowsConsole.RESTORE);
|
||||
|
||||
WindowsConsole.SmallRect.MakeEmpty (ref damageRegion);
|
||||
|
||||
ResizeScreen ();
|
||||
|
||||
@@ -161,7 +161,6 @@ namespace Terminal.Gui {
|
||||
|
||||
internal static bool _initialized = false;
|
||||
|
||||
static int cols, rows;
|
||||
static IMainLoopDriver oldMainLoopDriver;
|
||||
static ConsoleDriver oldDriver;
|
||||
|
||||
@@ -189,7 +188,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 = cols == 0 && rows == 0 ? new WindowsDriver () : new WindowsDriver (cols, rows);
|
||||
var windowsDriver = new WindowsDriver ();
|
||||
mainLoopDriver = windowsDriver;
|
||||
Driver = windowsDriver;
|
||||
} else {
|
||||
@@ -557,8 +556,6 @@ namespace Terminal.Gui {
|
||||
}
|
||||
last?.PositionCursor ();
|
||||
Driver.Refresh ();
|
||||
cols = Driver.Cols;
|
||||
rows = Driver.Rows;
|
||||
}
|
||||
|
||||
internal static void End (View view, bool closeDriver = true)
|
||||
|
||||
Reference in New Issue
Block a user