protected override void ConfigureActions() { Parser.AddAction(new AnsiCsiAction(NormalColor, () => { CloseScope(); ForegroundColor = null; BackgroundColor = null; })); Parser.AddAction(new AnsiCsiAction(ForegroundBold, () => { CloseScope(); if (ForegroundColor.HasValue && (int)ForegroundColor < 8) { ForegroundColor = ForegroundColor + 8; } OpenScope(); })); Parser.AddAction(new AnsiCsiAction(BackgroundColorBlack, () => SetBackgroundColor(ConsoleColor.Black))); Parser.AddAction(new AnsiCsiAction(BackgroundColorRed, () => SetBackgroundColor(ConsoleColor.DarkRed))); Parser.AddAction(new AnsiCsiAction(BackgroundColorGreen, () => SetBackgroundColor(ConsoleColor.DarkGreen))); Parser.AddAction(new AnsiCsiAction(BackgroundColorYellow, () => SetBackgroundColor(ConsoleColor.DarkYellow))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBlue, () => SetBackgroundColor(ConsoleColor.DarkBlue))); Parser.AddAction(new AnsiCsiAction(BackgroundColorMagenta, () => SetBackgroundColor(ConsoleColor.DarkMagenta))); Parser.AddAction(new AnsiCsiAction(BackgroundColorCyan, () => SetBackgroundColor(ConsoleColor.DarkCyan))); Parser.AddAction(new AnsiCsiAction(BackgroundColorWhite, () => SetBackgroundColor(ConsoleColor.DarkGray))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldBlack, () => SetBackgroundColor(ConsoleColor.Gray))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldRed, () => SetBackgroundColor(ConsoleColor.Red))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldGreen, () => SetBackgroundColor(ConsoleColor.Green))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldYellow, () => SetBackgroundColor(ConsoleColor.Yellow))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldBlue, () => SetBackgroundColor(ConsoleColor.Blue))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldMagenta, () => SetBackgroundColor(ConsoleColor.Magenta))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldCyan, () => SetBackgroundColor(ConsoleColor.Cyan))); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldWhite, () => SetBackgroundColor(ConsoleColor.White))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBlack, () => SetForegroundColor(ConsoleColor.Black))); Parser.AddAction(new AnsiCsiAction(ForegroundColorRed, () => SetForegroundColor(ConsoleColor.DarkRed))); Parser.AddAction(new AnsiCsiAction(ForegroundColorGreen, () => SetForegroundColor(ConsoleColor.DarkGreen))); Parser.AddAction(new AnsiCsiAction(ForegroundColorYellow, () => SetForegroundColor(ConsoleColor.DarkYellow))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBlue, () => SetForegroundColor(ConsoleColor.DarkBlue))); Parser.AddAction(new AnsiCsiAction(ForegroundColorMagenta, () => SetForegroundColor(ConsoleColor.DarkMagenta))); Parser.AddAction(new AnsiCsiAction(ForegroundColorCyan, () => SetForegroundColor(ConsoleColor.DarkCyan))); Parser.AddAction(new AnsiCsiAction(ForegroundColorWhite, () => SetForegroundColor(ConsoleColor.DarkGray))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldBlack, () => SetForegroundColor(ConsoleColor.Gray))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldRed, () => SetForegroundColor(ConsoleColor.Red))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldGreen, () => SetForegroundColor(ConsoleColor.Green))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldYellow, () => SetForegroundColor(ConsoleColor.Yellow))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldBlue, () => SetForegroundColor(ConsoleColor.Blue))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldMagenta, () => SetForegroundColor(ConsoleColor.Magenta))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldCyan, () => SetForegroundColor(ConsoleColor.Cyan))); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldWhite, () => SetForegroundColor(ConsoleColor.White))); }
private void ConfigureActions() { Parser.AddAction(new AnsiCsiAction(NormalColor, () => Console.ResetColor())); Parser.AddAction(new AnsiCsiAction(ForegroundBold, () => { if ((int)Console.ForegroundColor < 8) { Console.ForegroundColor = Console.ForegroundColor + 8; } })); Parser.AddAction(new AnsiCsiAction(BackgroundColorBlack, () => Console.BackgroundColor = ConsoleColor.Black)); Parser.AddAction(new AnsiCsiAction(BackgroundColorRed, () => Console.BackgroundColor = ConsoleColor.DarkRed)); Parser.AddAction(new AnsiCsiAction(BackgroundColorGreen, () => Console.BackgroundColor = ConsoleColor.DarkGreen)); Parser.AddAction(new AnsiCsiAction(BackgroundColorYellow, () => Console.BackgroundColor = ConsoleColor.DarkYellow)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBlue, () => Console.BackgroundColor = ConsoleColor.DarkBlue)); Parser.AddAction(new AnsiCsiAction(BackgroundColorMagenta, () => Console.BackgroundColor = ConsoleColor.DarkMagenta)); Parser.AddAction(new AnsiCsiAction(BackgroundColorCyan, () => Console.BackgroundColor = ConsoleColor.DarkCyan)); Parser.AddAction(new AnsiCsiAction(BackgroundColorWhite, () => Console.BackgroundColor = ConsoleColor.DarkGray)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldBlack, () => Console.BackgroundColor = ConsoleColor.Gray)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldRed, () => Console.BackgroundColor = ConsoleColor.Red)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldGreen, () => Console.BackgroundColor = ConsoleColor.Green)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldYellow, () => Console.BackgroundColor = ConsoleColor.Yellow)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldBlue, () => Console.BackgroundColor = ConsoleColor.Blue)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldMagenta, () => Console.BackgroundColor = ConsoleColor.Magenta)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldCyan, () => Console.BackgroundColor = ConsoleColor.Cyan)); Parser.AddAction(new AnsiCsiAction(BackgroundColorBoldWhite, () => Console.BackgroundColor = ConsoleColor.White)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBlack, () => Console.ForegroundColor = ConsoleColor.Black)); Parser.AddAction(new AnsiCsiAction(ForegroundColorRed, () => Console.ForegroundColor = ConsoleColor.DarkRed)); Parser.AddAction(new AnsiCsiAction(ForegroundColorGreen, () => Console.ForegroundColor = ConsoleColor.DarkGreen)); Parser.AddAction(new AnsiCsiAction(ForegroundColorYellow, () => Console.ForegroundColor = ConsoleColor.DarkYellow)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBlue, () => Console.ForegroundColor = ConsoleColor.DarkBlue)); Parser.AddAction(new AnsiCsiAction(ForegroundColorMagenta, () => Console.ForegroundColor = ConsoleColor.DarkMagenta)); Parser.AddAction(new AnsiCsiAction(ForegroundColorCyan, () => Console.ForegroundColor = ConsoleColor.DarkCyan)); Parser.AddAction(new AnsiCsiAction(ForegroundColorWhite, () => Console.ForegroundColor = ConsoleColor.DarkGray)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldBlack, () => Console.ForegroundColor = ConsoleColor.Gray)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldRed, () => Console.ForegroundColor = ConsoleColor.Red)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldGreen, () => Console.ForegroundColor = ConsoleColor.Green)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldYellow, () => Console.ForegroundColor = ConsoleColor.Yellow)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldBlue, () => Console.ForegroundColor = ConsoleColor.Blue)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldMagenta, () => Console.ForegroundColor = ConsoleColor.Magenta)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldCyan, () => Console.ForegroundColor = ConsoleColor.Cyan)); Parser.AddAction(new AnsiCsiAction(ForegroundColorBoldWhite, () => Console.ForegroundColor = ConsoleColor.White)); }