Пример #1
0
        public void Write(char character)
        {
            if (ColorMappings.IsForegroundMapping(character))
            {
                _vga.ActiveForegroundColor = ColorMappings.GetForeground(character);
                return;
            }

            if (ColorMappings.IsBackgroundMapping(character))
            {
                _vga.ActiveBackgroundColor = ColorMappings.GetBackground(character);
                return;
            }

            if (character == '\uff40')
            {
                _vga.ActiveForegroundColor = _vga.DefaultForegroundColor;
                return;
            }

            if (character == '\ufe40')
            {
                _vga.ActiveBackgroundColor = _vga.DefaultBackgroundColor;
                return;
            }

            if (character == '\b')
            {
                MoveCursorBackwards();
                _vga.PutCharAt(' ', _vga.CursorX, _vga.CursorY);
            }
            else if (character == '\n')
            {
                _vga.CursorX = _vga.Margins.Left;
                _vga.CursorY++;

                if (_vga.CursorY >= _vga.TotalRows - _vga.Margins.Bottom)
                {
                    _vga.CursorY = (ushort)(_vga.TotalRows - _vga.Margins.Bottom - 1);
                    _vga.ScrollUp();
                }
            }
            else if (character == '\r')
            {
                _vga.CursorX = _vga.Margins.Left;
            }
            else
            {
                _vga.PutCharAt(character, _vga.CursorX, _vga.CursorY);
                MoveCursorForwards();
            }
        }