private static void RestoreConsoleState() { NativeWin.SetConsoleMode(consoleHandle, initialConsoleMode); Console.WindowWidth = initialWindowWidth; Console.WindowHeight = initialWindowHeight; Console.BufferWidth = initialBufferWidth; Console.BufferHeight = initialBufferHeight; Console.Clear(); NativeWin.SetConsoleResizeEnabled(true); }
private static void SetupConsole() { initialBufferWidth = Console.BufferWidth; initialBufferHeight = Console.BufferHeight; initialWindowWidth = Console.WindowWidth; initialWindowHeight = Console.WindowHeight; SetConsoleSize(); consoleHandle = FastConsole.Native.GetStdHandle(FastConsole.Native.nStdHandle.STD_INPUT_HANDLE); NativeWin.GetConsoleMode((IntPtr)consoleHandle, ref initialConsoleMode); NativeWin.SetConsoleMode(consoleHandle, (uint)(NativeWin.ConsoleInputMode.ENABLE_MOUSE_INPUT | NativeWin.ConsoleInputMode.ENABLE_EXTENDED_FLAGS | NativeWin.ConsoleInputMode.ENABLE_WINDOW_INPUT)); ResizeFitConsole(); if (!resizable) { NativeWin.SetConsoleResizeEnabled(false); } }