Ejemplo n.º 1
0
        private Character.ColorInfo GetColorInfoFromBasicColor(ConsoleBuffer.Commands.SetGraphicsRendition.Colors basicColor, bool isBright)
        {
            var paletteOffset = isBright ? 8 : 0;

            switch (basicColor)
            {
            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Black:
                return(this.Palette[0 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Red:
                return(this.Palette[1 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Green:
                return(this.Palette[2 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Yellow:
                return(this.Palette[3 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Blue:
                return(this.Palette[4 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Magenta:
                return(this.Palette[5 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.Cyan:
                return(this.Palette[6 + paletteOffset]);

            case ConsoleBuffer.Commands.SetGraphicsRendition.Colors.White:
                return(this.Palette[7 + paletteOffset]);

            default:
                throw new InvalidOperationException("Unexpected color value.");
            }
        }
Ejemplo n.º 2
0
        public void SGRBasicBackgroundColors(string data, ConsoleBuffer.Commands.SetGraphicsRendition.Colors expectedColor, bool expectedBright)
        {
            var parser = this.EnsureCommandParses($"\x1b[{data}m");
            var cmd    = parser.Command as ConsoleBuffer.Commands.SetGraphicsRendition;

            Assert.IsNotNull(cmd);
            Assert.IsTrue(cmd.HaveBasicBackground);
            Assert.AreEqual(expectedColor, cmd.BasicBackgroundColor);
            Assert.AreEqual(expectedBright ? ConsoleBuffer.Commands.SetGraphicsRendition.FlagValue.Set :
                            ConsoleBuffer.Commands.SetGraphicsRendition.FlagValue.None,
                            cmd.BackgroundBright);
        }