public static string ColorANSI16(ANSIColor_16 foreground, ANSIColor_8 background) { int bgColor = (int)background + 40; int fgColor = (int)foreground + 30; int bold = 0; if (fgColor >= 40) { bold = 1; fgColor -= 10; } return(string.Format("{0}[{1};{2};{3}m", (char)27, bold, fgColor, bgColor)); }
public static string SetColorANSI16(string text, ANSIColor_16 foreground, ANSIColor_8 background) { return(string.Format("{0}{1}{2}", ColorANSI16(foreground, background), text, ClearFormat())); }