Exemplo n.º 1
0
        internal void CopyToConsole(Win32Console console)
        {
            bool[] dirtyRows = new bool[_bufferDimensions.Height];

            for (int row = 0; row < _bufferDimensions.Height; row += 1)
            {
                for (int column = 0; column < _bufferDimensions.Width; column += 1)
                {
                    if (CellChanged(row, column))
                    {
                        dirtyRows[row] = true;
                        break;
                    }
                }
            }

            var spans = new List <RowSpan>();

            for (int row = 0; row < _bufferDimensions.Height; row += 1)
            {
                for (int column = 0; column < _bufferDimensions.Width; column += 1)
                {
                    if (!CellChanged(row, column))
                    {
                        continue;
                    }

                    int start = column;
                    while (column < _bufferDimensions.Width &&
                           CellChanged(row, column))
                    {
                        column += 1;
                    }

                    spans.Add(new RowSpan(row, start, column));
                }
            }

            console.WriteOutputBuffer(_backbufferChars, _backbufferForegroundColors, _backbufferBackgroundColors, _bufferDimensions.Width, _bufferDimensions.Height, spans);

            var tempbufferChars            = _frontbufferChars;
            var tempbufferForegroundColors = _frontbufferForegroundColors;
            var tempbufferBackgroundColors = _frontbufferBackgroundColors;

            _frontbufferChars            = _backbufferChars;
            _frontbufferForegroundColors = _backbufferForegroundColors;
            _frontbufferBackgroundColors = _backbufferBackgroundColors;

            _backbufferChars            = tempbufferChars;
            _backbufferForegroundColors = tempbufferForegroundColors;
            _backbufferBackgroundColors = tempbufferBackgroundColors;
        }
Exemplo n.º 2
0
        protected Screen()
        {
            ActiveControl = this;
            // TODO: Save existing console buffer before resizing to fit window,
            // TODO: then restore it in Dispose()
            Console.CursorSize = 8;
            Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight);
            _console = new Win32Console();
            _console.EnableInputEvents();
            var dim = _console.GetBufferDimensions();

            this.Left   = 0;
            this.Top    = 0;
            this.Width  = dim.Width;
            this.Height = dim.Height;
        }
Exemplo n.º 3
0
 internal void RestoreBufferToScreen(Win32Console console)
 {
     console.WriteOutputBuffer(_frontbufferChars, _frontbufferForegroundColors, _frontbufferBackgroundColors, _bufferDimensions.Width, _bufferDimensions.Height, null);
 }