Skip to content

Commit

Permalink
Update the map between console color to VT sequences (#11891)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxian-dbw committed Feb 20, 2020
1 parent d3ad083 commit da94afa
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/System.Management.Automation/utils/VTUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ public enum VT
Inverse
}

private static readonly Dictionary<ConsoleColor, string> ConsoleColors = new Dictionary<ConsoleColor, string>
private static readonly Dictionary<ConsoleColor, string> ForegroundColorMap = new Dictionary<ConsoleColor, string>
{
{ ConsoleColor.Black, "\x1b[2;30m" },
{ ConsoleColor.Gray, "\x1b[2;37m" },
{ ConsoleColor.Red, "\x1b[1;31m" },
{ ConsoleColor.Green, "\x1b[1;32m" },
{ ConsoleColor.Yellow, "\x1b[1;33m" },
{ ConsoleColor.Blue, "\x1b[1;34m" },
{ ConsoleColor.Magenta, "\x1b[1;35m" },
{ ConsoleColor.Cyan, "\x1b[1;36m" },
{ ConsoleColor.White, "\x1b[1;37m" },
{ ConsoleColor.DarkRed, "\x1b[2;31m" },
{ ConsoleColor.DarkGreen, "\x1b[2;32m" },
{ ConsoleColor.DarkYellow, "\x1b[2;33m" },
{ ConsoleColor.DarkBlue, "\x1b[2;34m" },
{ ConsoleColor.DarkMagenta, "\x1b[2;35m" },
{ ConsoleColor.DarkCyan, "\x1b[2;36m" },
{ ConsoleColor.DarkGray, "\x1b[1;30m" },
{ ConsoleColor.Black, "\x1b[30m" },
{ ConsoleColor.Gray, "\x1b[37m" },
{ ConsoleColor.Red, "\x1b[91m" },
{ ConsoleColor.Green, "\x1b[92m" },
{ ConsoleColor.Yellow, "\x1b[93m" },
{ ConsoleColor.Blue, "\x1b[94m" },
{ ConsoleColor.Magenta, "\x1b[95m" },
{ ConsoleColor.Cyan, "\x1b[96m" },
{ ConsoleColor.White, "\x1b[97m" },
{ ConsoleColor.DarkRed, "\x1b[31m" },
{ ConsoleColor.DarkGreen, "\x1b[32m" },
{ ConsoleColor.DarkYellow, "\x1b[33m" },
{ ConsoleColor.DarkBlue, "\x1b[34m" },
{ ConsoleColor.DarkMagenta, "\x1b[35m" },
{ ConsoleColor.DarkCyan, "\x1b[36m" },
{ ConsoleColor.DarkGray, "\x1b[90m" },
};

private static readonly Dictionary<VT, string> VTCodes = new Dictionary<VT, string>
Expand All @@ -60,7 +60,7 @@ public enum VT
public static string GetEscapeSequence(ConsoleColor color)
{
string value = string.Empty;
ConsoleColors.TryGetValue(color, out value);
ForegroundColorMap.TryGetValue(color, out value);
return value;
}

Expand Down

0 comments on commit da94afa

Please sign in to comment.