-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnsiColors.cs
223 lines (188 loc) · 8.32 KB
/
AnsiColors.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
namespace CopperDevs.Logger
{
public static class AnsiColors
{
private static string ForeColor(int code) => $"\u001B[38;5;{code}m";
private static string BackColor(int code) => $"\u001B[48;5;{code}m";
public static string Reset => "\u001B[0m";
public static string Bold => "\u001B[1m";
public static string Black => "\u001B[30m";
public static string BlackBackground => "\u001B[40m";
public static string BrightBlack => "\u001B[90m";
public static string BrightBlackBackground => "\u001B[100m";
public static string Red => "\u001B[31m";
public static string RedBackground => "\u001B[41m";
public static string BrightRed => "\u001B[91m";
public static string BrightRedBackground => "\u001B[101m";
public static string Green => "\u001B[32m";
public static string GreenBackground => "\u001B[42m";
public static string BrightGreen => "\u001B[92m";
public static string BrightGreenBackground => "\u001B[102m";
public static string Yellow => "\u001B[33m";
public static string YellowBackground => "\u001B[43m";
public static string BrightYellow => "\u001B[93m";
public static string BrightYellowBackground => "\u001B[103m";
public static string Blue => "\u001B[34m";
public static string BlueBackground => "\u001B[44m";
public static string BrightBlue => "\u001B[94m";
public static string BrightBlueBackground => "\u001B[104m";
public static string Purple => "\u001B[35m";
public static string PurpleBackground => "\u001B[45m";
public static string BrightPurple => "\u001B[95m";
public static string BrightPurpleBackground => "\u001B[105m";
public static string Cyan => "\u001B[36m";
public static string CyanBackground => "\u001B[46m";
public static string BrightCyan => "\u001B[96m";
public static string BrightCyanBackground => "\u001B[106m";
public static string White => "\u001B[37m";
public static string WhiteBackground => "\u001B[47m";
public static string BrightWhite => "\u001B[97m";
public static string BrightWhiteBackground => "\u001B[107m";
public static string Gray => ForeColor(244);
public static string GrayBackground => BackColor(244);
public static string Orange => ForeColor(202);
public static string OrangeBackground => BackColor(202);
public static string Pink => ForeColor(200);
public static string PinkBackground => BackColor(200);
public static string CutePink => ForeColor(205);
public static string CutePinkBackground => BackColor(205);
public static string Aqua => ForeColor(45);
public static string AquaBackground => BackColor(45);
public static string Gold => ForeColor(220);
public static string GoldBackground => BackColor(220);
public static string LightGreen => ForeColor(82);
public static string LightGreenBackground => BackColor(82);
public static string LightBlue => ForeColor(39);
public static string LightBlueBackground => BackColor(39);
public static string Magenta => ForeColor(13);
public static string MagentaBackground => BackColor(13);
public static string LightCyan => ForeColor(51);
public static string LightCyanBackground => BackColor(51);
public static string LightGray => ForeColor(247);
public static string LightGrayBackground => BackColor(247);
public static string DarkRed => ForeColor(88);
public static string DarkRedBackground => BackColor(88);
public static string DarkGreen => ForeColor(22);
public static string DarkGreenBackground => BackColor(22);
public static string DarkBlue => ForeColor(19);
public static string DarkBlueBackground => BackColor(19);
public static string DarkYellow => ForeColor(136);
public static string DarkYellowBackground => BackColor(136);
public static string DarkPurple => ForeColor(55);
public static string DarkPurpleBackground => BackColor(55);
public static string GetColor(Names color)
{
return color switch
{
Names.Black => Black,
Names.Red => Red,
Names.Green => Green,
Names.Yellow => Yellow,
Names.Blue => Blue,
Names.Purple => Purple,
Names.Cyan => Cyan,
Names.White => White,
Names.BrightBlack => BrightBlack,
Names.BrightRed => BrightRed,
Names.BrightGreen => BrightGreen,
Names.BrightYellow => BrightYellow,
Names.BrightBlue => BrightBlue,
Names.BrightPurple => BrightPurple,
Names.BrightCyan => BrightCyan,
Names.BrightWhite => BrightWhite,
Names.Gray => Gray,
Names.Orange => Orange,
Names.Pink => Pink,
Names.CutePink => CutePink,
Names.Aqua => Aqua,
Names.Gold => Gold,
Names.LightGreen => LightGreen,
Names.LightBlue => LightBlue,
Names.Magenta => Magenta,
Names.LightCyan => LightCyan,
Names.LightGray => LightGray,
Names.DarkRed => DarkRed,
Names.DarkGreen => DarkGreen,
Names.DarkBlue => DarkBlue,
Names.DarkYellow => DarkYellow,
Names.DarkPurple => DarkPurple,
_ => throw new ArgumentOutOfRangeException(nameof(color), color, null)
};
}
public static string GetBackgroundColor(Names color)
{
return color switch
{
Names.Black => BlackBackground,
Names.Red => RedBackground,
Names.Green => GreenBackground,
Names.Yellow => YellowBackground,
Names.Blue => BlueBackground,
Names.Purple => PurpleBackground,
Names.Cyan => CyanBackground,
Names.White => WhiteBackground,
Names.BrightBlack => BrightBlackBackground,
Names.BrightRed => BrightRedBackground,
Names.BrightGreen => BrightGreenBackground,
Names.BrightYellow => BrightYellowBackground,
Names.BrightBlue => BrightBlueBackground,
Names.BrightPurple => BrightPurpleBackground,
Names.BrightCyan => BrightCyanBackground,
Names.BrightWhite => BrightWhiteBackground,
Names.Gray => GrayBackground,
Names.Orange => OrangeBackground,
Names.Pink => PinkBackground,
Names.CutePink => CutePinkBackground,
Names.Aqua => AquaBackground,
Names.Gold => GoldBackground,
Names.LightGreen => LightGreenBackground,
Names.LightBlue => LightBlueBackground,
Names.Magenta => MagentaBackground,
Names.LightCyan => LightCyanBackground,
Names.LightGray => LightGrayBackground,
Names.DarkRed => DarkRedBackground,
Names.DarkGreen => DarkGreenBackground,
Names.DarkBlue => DarkBlueBackground,
Names.DarkYellow => DarkYellowBackground,
Names.DarkPurple => DarkPurpleBackground,
_ => throw new ArgumentOutOfRangeException(nameof(color), color, null)
};
}
public enum Names
{
Black,
Red,
Green,
Yellow,
Blue,
Purple,
Cyan,
White,
BrightBlack,
BrightRed,
BrightGreen,
BrightYellow,
BrightBlue,
BrightPurple,
BrightCyan,
BrightWhite,
Gray,
Orange,
Pink,
CutePink,
Aqua,
Gold,
LightGreen,
LightBlue,
Magenta,
LightCyan,
LightGray,
DarkRed,
DarkGreen,
DarkBlue,
DarkYellow,
DarkPurple,
}
}
}