Console Colors

From Onix OS Wiki
Jump to: navigation, search

How to change output colors in console. (Wednesday, August 29, 2018)

The colorize() function is used to color the terminal. When needed, beautiful prints can be obtained by giving colors.


colorize(colorname, string)

If you have a terminal that supports colors with this utility, you can get color output directly. It is recommended that you use a terminal with ANSI+color support. For example, you can easily distinguish errors and print them in red.

Color example (colorize.ol)

colorize("red", "Hello Colorize!")
colorize("blue", "Hello Colorize!")
colorize("green", "Hello Colorize!")
colorize("yellow", "Hello Colorize!")
colorize("grey", "Hello Colorize!")
colorize("black", "Hello Colorize!")
colorize("bold", "Hello Colorize!")
colorize("magenta", "Hello Colorize!")
colorize("white", "Hello Colorize!")
colorize("red", "Hello Colorize!", true)
colorize("blue", "Hello Colorize!", true)
colorize("green", "Hello Colorize!", true)
colorize("yellow", "Hello Colorize!", true)
colorize("grey", "Hello Colorize!", true)
colorize("black", "Hello Colorize!", true)
colorize("bold", "Hello Colorize!", true)
colorize("magenta", "Hello Colorize!", true)
colorize("white", "Hello Colorize!", true);

We tested all the colors. However, it is recommended that you test the terminal output on your own terminal. You can perform this test on xterm or Linux-supported terminals. The CMD on Windows may not yield exactly the desired result.