public static WriteToConsole ( string text, |
||
text | string | |
lexer | ||
return | void |
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;
}