An object to smoothly use color codes on the Terminal, just use the color codes like this:
console.log( C["&a"] + C["&l"] + "Lorem ipsum dolor sit amet" + C["&r"] )
// Will appear green and bold on the Terminal
C["&a"]
means GreenC["&l"]
means BoldC["&r"]
is to reset all previous style
More complicated example:
console.log( C["&c"] + C["&l"] + "Danger! " + C["&r"] + C["&e"] + C["&n"] + "Don't do that!" + C["&r"] + " " +C["&bg"] + C["&b"] + " Be careful "+ C["&r"] )
The C
object in the JavaScript code provides an easy way to print text with different colors in the terminal without having to remember the corresponding ANSI codes. The object contains several properties, each of which is associated with a specific color or style code that can be used to format text in the terminal.
There are 2 types of codes; color and format. You can combine color with formats, for example, Green with Bold (example above).
To use them, just put the code like this C["CODE"]
The "Codes" are just properties of the object C, on with there is the respective ANSI code that the terminal will interpret.
Here are the Color Codes: (For each color, there is a brighter and darker color)
Allways remember to reset any style at the end of the line by using the reset code,
C["&r"]
Because its great to use color on the terminal, if it's not for you just don't use it. :)
The main place is the terminal, and that's why I made this. But it also works on the javascript dev's console! I don't recommend it tho, there are better ways to manipulate the style and color there, here are some links: Link 1, Link 2.
Because I pretty much took the colors from Minecraft's color codes and made them into ANSI codes. Also, on there, the way of using them is to put a &
before the code, so that's why I made it this way. I already knew the color and their code so it was really easy for me to make it this way.