示例#1
0
        public static void WriteToConsole(string text, Lexer lexer)
        {
            ConsoleColor foreground = Console.ForegroundColor;
            Colorizer colorizer = new Colorizer();

            int position = 0;
            TokenType lasttype = TokenType.Space;
            SetColor(lasttype);

            foreach (var colortype in colorizer.GetColorTypes(text, lexer))
            {
                if (colortype != lasttype)
                {
                    SetColor(colortype);
                    lasttype = colortype;
                }

                Console.Write(text[position]);
                position++;
            }

            Console.ForegroundColor = foreground;
        }