public void Resize(int width, int height) { _display = new ScreenBuffer(this, width, height); Backbuffer = new ScreenBuffer(this, width, height); var newBuffer = Win32Console.CreateConsoleScreenBuffer( Win32Console.GENERIC_READ | Win32Console.GENERIC_WRITE, Win32Console.FILE_SHARE_READ, IntPtr.Zero, Win32Console.CONSOLE_TEXTMODE_BUFFER, IntPtr.Zero); Win32Console.SetConsoleScreenBufferSize(newBuffer, new Win32Console.COORD((short)width, (short)height)); var cci = new Win32Console.CONSOLE_CURSOR_INFO(); cci.dwSize = 100; cci.bVisible = false; Win32Console.SetConsoleCursorInfo(newBuffer, ref cci); var cfi = new Win32Console.CONSOLE_FONT_INFOEX(); cfi.cbSize = Marshal.SizeOf(cfi); cfi.nFont = 0; cfi.dwFontSize = new Win32Console.COORD(8, 14); cfi.FaceName = "Lucida Console"; cfi.FontFamily = 0; cfi.FontWeight = 0; Debug.Assert(Win32Console.SetCurrentConsoleFontEx(newBuffer, false, ref cfi)); Debug.Assert(Win32Console.SetConsoleActiveScreenBuffer(newBuffer)); if (_screenBuffer != IntPtr.Zero) { Debug.Assert(Win32Console.CloseHandle(_screenBuffer)); } _screenBuffer = newBuffer; }
public void Dispose() { Debug.Assert(Win32Console.SetConsoleActiveScreenBuffer(_defaultBuffer)); Debug.Assert(Win32Console.CloseHandle(_screenBuffer)); }