Exemplo n.º 1
0
        private void SetPalette(FormatToken token, ConsolePalette palette, bool colorize)
        {
            if (colorize && token is PropertyToken)
            {
                if (palette.ArgumentBackground != Constants.DefaultConsoleColor)
                {
                    _console.BackgroundColor = palette.ArgumentBackground;
                }

                if (palette.ArgumentForeground != Constants.DefaultConsoleColor)
                {
                    _console.ForegroundColor = palette.ArgumentForeground;
                }
            }
            else
            {
                if (palette.Background != Constants.DefaultConsoleColor)
                {
                    _console.BackgroundColor = palette.Background;
                }

                if (palette.Foreground != Constants.DefaultConsoleColor)
                {
                    _console.ForegroundColor = palette.Foreground;
                }
            }
        }
Exemplo n.º 2
0
 private void SetPalette(FormatToken token, ConsolePalette palette, bool colorize)
 {
     if (colorize && token is PropertyToken)
     {
         _console.BackgroundColor = palette.ArgumentBackground;
         _console.ForegroundColor = palette.ArgumentForeground;
     }
     else
     {
         _console.BackgroundColor = palette.Background;
         _console.ForegroundColor = palette.Foreground;
     }
 }
 private string GetColorEscapeCode(FormatToken token, ConsolePalette palette)
 {
     if (token is PropertyToken)
     {
         var result = _ansiBackgroundLookup[palette.ArgumentBackground];
         result += _ansiLookup[palette.ArgumentForeground];
         return(result);
     }
     else
     {
         var result = _ansiBackgroundLookup[palette.Background];
         result += _ansiLookup[palette.Foreground];
         return(result);
     }
 }
Exemplo n.º 4
0
        private void SetPalette(FormatToken token, ConsolePalette palette)
        {
            var property = token as PropertyToken;

            if (property != null)
            {
                _console.BackgroundColor = palette.ArgumentBackground;
                _console.ForegroundColor = palette.ArgumentForeground;
            }
            else
            {
                _console.BackgroundColor = palette.Background;
                _console.ForegroundColor = palette.Foreground;
            }
        }
Exemplo n.º 5
0
        public AnsiConsoleRenderer(IConsole console)
        {
            _console = console ?? throw new ArgumentNullException(nameof(console));
            _palette = ConsolePalette.CreateLookup(_console);

            _ansiLookup = new Dictionary <ConsoleColor, string>
            {
                { Constants.DefaultConsoleColor, string.Empty }, // Default
                { ConsoleColor.DarkGray, "\u001b[30;1m" },       // Bright black
                { ConsoleColor.Red, "\u001b[31;1m" },            // Bright red
                { ConsoleColor.Green, "\u001b[32;1m" },          // Bright green
                { ConsoleColor.Yellow, "\u001b[33;1m" },         // Bright yellow
                { ConsoleColor.Blue, "\u001b[34;1m" },           // Bright blue
                { ConsoleColor.Magenta, "\u001b[35;1m" },        // Bright magenta
                { ConsoleColor.Cyan, "\u001b[36;1m" },           // Bright cyan
                { ConsoleColor.White, "\u001b[37;1m" },          // Bright white
                { ConsoleColor.Black, "\u001b[30m" },            // Black
                { ConsoleColor.DarkRed, "\u001b[31m" },          // Red
                { ConsoleColor.DarkGreen, "\u001b[32m" },        // Green
                { ConsoleColor.DarkYellow, "\u001b[33m" },       // Yellow
                { ConsoleColor.DarkBlue, "\u001b[34m" },         // Blue
                { ConsoleColor.DarkMagenta, "\u001b[35m" },      // Magenta
                { ConsoleColor.DarkCyan, "\u001b[36m" },         // Cyan
                { ConsoleColor.Gray, "\u001b[37m" },             // White
            };

            _ansiBackgroundLookup = new Dictionary <ConsoleColor, string>
            {
                { Constants.DefaultConsoleColor, string.Empty }, // Default
                { ConsoleColor.DarkGray, "\u001b[40;1m" },       // Bright black
                { ConsoleColor.Red, "\u001b[41;1m" },            // Bright red
                { ConsoleColor.Green, "\u001b[42;1m" },          // Bright green
                { ConsoleColor.Yellow, "\u001b[43;1m" },         // Bright yellow
                { ConsoleColor.Blue, "\u001b[44;1m" },           // Bright blue
                { ConsoleColor.Magenta, "\u001b[45;1m" },        // Bright magenta
                { ConsoleColor.Cyan, "\u001b[46;1m" },           // Bright cyan
                { ConsoleColor.White, "\u001b[47;1m" },          // Bright white
                { ConsoleColor.Black, "\u001b[40m" },            // Black
                { ConsoleColor.DarkRed, "\u001b[41m" },          // Red
                { ConsoleColor.DarkGreen, "\u001b[42m" },        // Green
                { ConsoleColor.DarkYellow, "\u001b[43m" },       // Yellow
                { ConsoleColor.DarkBlue, "\u001b[44m" },         // Blue
                { ConsoleColor.DarkMagenta, "\u001b[45m" },      // Magenta
                { ConsoleColor.DarkCyan, "\u001b[46m" },         // Cyan
                { ConsoleColor.Gray, "\u001b[47m" },             // White
            };
        }
Exemplo n.º 6
0
 public ConsoleRenderer(IConsole console)
 {
     _console = console ?? throw new ArgumentNullException();
     _palette = ConsolePalette.CreateLookup(_console);
 }