Ejemplo n.º 1
0
        public void WHEN_UsingAnsiColorConsole_THEN_()
        {
            IColorConsole con = new AnsiColorConsole();

            con.wl("stuff");
            con.wl(ConsoleColor.Red, "red");
            //con.w("State:").wl(SystemConsole.State);
        }
Ejemplo n.º 2
0
        static void DoColor(bool doBackground)
        {
            var c2 = new AnsiColorConsole();

            Console.WriteLine(doBackground ? "Background" : "Foreground");

            int    ansix = doBackground ? 4 : 3;
            string text  = doBackground ? "ab" : "\u2588\u2588";

            Console.Write("ANSI [0-7] :");
            for (int i = 0; i < 8; i++)
            {
                var c = i;
                Console.Write($"\u001b[{ansix}{c}m{c,2}{text}");
            }
            Console.WriteLine("\u001b[0m");
            Console.Write("DOS  [0-7] :");
            for (int i = 0; i < 8; i++)
            {
                if (doBackground)
                {
                    Console.BackgroundColor = (ConsoleColor)i;
                }
                else
                {
                    Console.ForegroundColor = (ConsoleColor)i;
                }
                Console.Write($"{i,2}{text}");
            }
            Console.WriteLine();
            Console.ResetColor();
            Console.Write("ANSI [8-15]:");
            for (int i = 0; i < 8; i++)
            {
                var c = i;
                Console.Write($"\u001b[{ansix}{c};1m{c,2}{text}");
            }
            Console.WriteLine("\u001b[0m");
            if (doBackground)
            {
                Console.Write("ANSIx[8-15]:");
                for (int i = 0; i < 8; i++)
                {
                    var c = i;
                    Console.Write($"\u001b[48;5;{c + 8}m{c,2}{text}");
                }
                Console.WriteLine("\u001b[0m");
            }

            Console.Write("DOS  [8-15]:");
            for (int i = 8; i < 16; i++)
            {
                if (doBackground)
                {
                    Console.BackgroundColor = (ConsoleColor)i;
                }
                else
                {
                    Console.ForegroundColor = (ConsoleColor)i;
                }
                Console.Write($"{i,2}{text}");
            }
            Console.ResetColor();
            Console.WriteLine();
            Console.WriteLine("IColorConsole implementations:");

            WriteConsoleImplementation(new ColorConsole(), "DOS ", doBackground);
            WriteConsoleImplementation(new AnsiColorConsole(), "ANSI", doBackground);
            WriteConsoleImplementation(SystemConsole.CreateColorConsole(), "AUTO", doBackground);
        }