Ejemplo n.º 1
0
        public void WriteCharactersAt(int x, int y, int count, char character, CharacterAttribute attribute)
        {
            var coord   = new COORD((short)x, (short)y);
            var winattr = _colorManager.AttributeToWin32Colors(attribute);

            ConsoleNative.FillConsoleOutputAttribute(_hstdout, (ushort)winattr, (uint)count, coord, out var numAttrWritten);
            ConsoleNative.FillConsoleOutputCharacter(_hstdout, (char)character, (uint)count, coord, out var numWritten);
        }
Ejemplo n.º 2
0
        public (int rows, int cols) GetConsoleWindowSize()
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            ConsoleNative.GetConsoleScreenBufferInfo(_hstdout, out csbi);
            var columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
            var rows    = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;

            return(rows, columns);
        }
Ejemplo n.º 3
0
 public Win32ConsoleDriver(ConsoleDriverOptions options)
 {
     _hstdin  = ConsoleNative.GetStdHandle(STDIN);
     _hstdout = ConsoleNative.GetStdHandle(STDOUT);
     _options = options;
     ConsoleNative.SetConsoleCP(CP_TOUSE);
     ConsoleNative.SetConsoleOutputCP(CP_TOUSE);
     ConsoleNative.GetConsoleMode(_hstdout, out uint dwOutModes);
     ConsoleNative.GetConsoleMode(_hstdin, out uint dwInputModes);
     SetConsoleMode(options, dwOutModes, dwInputModes);
     //ConsoleNative.SetConsoleMode(_hstdin, (uint)(ConsoleInputModes.ENABLE_MOUSE_INPUT | ConsoleInputModes.ENABLE_WINDOW_INPUT | ConsoleInputModes.ENABLE_VIRTUAL_TERMINAL_INPUT));
     dwOutModes   |= (uint)ConsoleOutputModes.ENABLE_VIRTUAL_TERMINAL_PROCESSING;
     SupportsVt100 = ConsoleNative.SetConsoleMode(_hstdout, dwOutModes);
 }
Ejemplo n.º 4
0
        public TvConsoleEvents ReadEvents()
        {
            ConsoleNative.GetNumberOfConsoleInputEvents(_hstdin, out var numEvents);

            if (numEvents > 0)
            {
                var buffer = new INPUT_RECORD[numEvents];
                ConsoleNative.ReadConsoleInput(_hstdin, buffer, (uint)buffer.Length, out var eventsRead);
                return(new TvConsoleEvents().Add(buffer));
            }
            else
            {
                return(TvConsoleEvents.Empty);
            }
        }
Ejemplo n.º 5
0
        public void Init()
        {
            var(rows, cols) = GetConsoleWindowSize();
            var requestedCols = _options.WindowOptions.Cols > 0 ? _options.WindowOptions.Cols : cols;
            var requestedRows = _options.WindowOptions.Rows > 0 ? _options.WindowOptions.Rows : rows;
            var rect          = new SMALL_RECT()
            {
                Left   = 0,
                Top    = 0,
                Bottom = (short)requestedRows,
                Right  = (short)requestedCols
            };

            if (_options.WindowOptions.Cols > 0 || _options.WindowOptions.Rows > 0)
            {
                ConsoleNative.SetConsoleWindowInfo(_hstdout, true, ref rect);
            }
            ConsoleNative.SetConsoleScreenBufferSize(_hstdout, new COORD((short)(rect.Right + 1), (short)(rect.Bottom + 1)));

            CONSOLE_CURSOR_INFO cursorInfo;

            ConsoleNative.GetConsoleCursorInfo(_hstdout, out cursorInfo);
            _initialCursorInfo = cursorInfo;
        }
Ejemplo n.º 6
0
 public static void Open()
 {
     ConsoleNative.AllocConsole();
 }
Ejemplo n.º 7
0
 public static void Close()
 {
     ConsoleNative.FreeConsole();
 }
Ejemplo n.º 8
0
 public void WriteCharacterAt(int x, int y, char character)
 {
     ConsoleNative.FillConsoleOutputCharacter(_hstdout, character, (uint)1, new COORD((short)x, (short)y), out var numWritten);
 }
Ejemplo n.º 9
0
        public void SetCursorVisibility(bool isVisible)
        {
            var info = new CONSOLE_CURSOR_INFO(isVisible, _initialCursorInfo.Size);

            ConsoleNative.SetConsoleCursorInfo(_hstdout, ref info);
        }
Ejemplo n.º 10
0
 public void SetCursorAt(int x, int y)
 {
     ConsoleNative.SetConsoleCursorPosition(_hstdout, new COORD((short)x, (short)y));
 }