I was messing around with debug and colors.js to get more colors than the limited 4-6 colors but I'm stuck at figuring out this coloring syntax
args[0] = ' \u001b[9' + c + 'm' + name + ' '
+ '\u001b[3' + c + 'm\u001b[90m'
+ args[0] + '\u001b[3' + c + 'm'
+ ' +' + exports.humanize(ms) + '\u001b[0m';
'blue' : ['\x1B[34m', '\x1B[39m'],
'cyan' : ['\x1B[36m', '\x1B[39m'],
'green' : ['\x1B[32m', '\x1B[39m'],
'magenta' : ['\x1B[35m', '\x1B[39m'],
'red' : ['\x1B[31m', '\x1B[39m'],
'yellow' : ['\x1B[33m', '\x1B[39m'],
I know windows console allows more colors than just those six, as color /?
shows
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
How do I go about understanding this syntax and adding the extra colors that windows has to offer?
Those are ANSI terminal escape codes. Specifically, they're "select graphic rendition" (SGR) escape codes, which consist of:
\x1B
(ESC) and [
,m
, ending the code and indicating that this is an SGR code.There are many possible numeric commands (and many other escape codes besides SGR), but the most relevant ones are:
Thus, for example, one could select bright purple text on a green background (eww!) with the code \x1B[35;1;42m
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With