private IBrush GetBackgroundBrush(TerminalAttribute attribute, bool invert)
        {
            var flip = Terminal.CursorState.ReverseVideoMode ^ attribute.Reverse ^ invert;

            if (flip)
            {
                if (attribute.ForegroundRgb == null)
                {
                    if (attribute.Bright)
                    {
                        return(AttributeBrushes[(int)attribute.ForegroundColor + 8]);
                    }

                    return(AttributeBrushes[(int)attribute.ForegroundColor]);
                }
                else
                {
                    return(new SolidColorBrush(Color.FromArgb(255, (byte)attribute.ForegroundRgb.Red, (byte)attribute.ForegroundRgb.Green, (byte)attribute.ForegroundRgb.Blue)));
                }
            }
            else
            {
                if (attribute.BackgroundRgb == null)
                {
                    return(AttributeBrushes[(int)attribute.BackgroundColor]);
                }
                else
                {
                    return(new SolidColorBrush(Color.FromArgb(255, (byte)attribute.BackgroundRgb.Red, (byte)attribute.BackgroundRgb.Green, (byte)attribute.BackgroundRgb.Blue)));
                }
            }
        }
예제 #2
0
        private NSColor GetForegroundColor(TerminalAttribute attribute, bool invert)
        {
            var flip = Terminal.CursorState.ReverseVideoMode ^ attribute.Reverse ^ invert;

            if (flip)
            {
                return(AttributeColors[(int)attribute.BackgroundColor]);
            }

            if (attribute.Bright)
            {
                return(AttributeColors[(int)attribute.ForegroundColor + 8]);
            }

            return(AttributeColors[(int)attribute.ForegroundColor]);
        }
        private void SetCharacter(int currentColumn, int currentRow, char ch, TerminalAttribute attribute)
        {
            while (Buffer.Count < (currentRow + TopRow + 1))
            {
                Buffer.Add(new TerminalLine());
            }

            var line = Buffer[currentRow + TopRow];

            while (line.Count < (currentColumn + 1))
            {
                line.Add(new TerminalCharacter {
                    Char = ' ', Attributes = CursorState.Attribute
                });
            }

            var character = line[currentColumn];

            character.Char       = ch;
            character.Attributes = attribute.Clone();
        }