This is a small library / class that I wrote to be able to handle ANSI escape code on gnome-terminal / mate-terminal without importing fancy libs with lots of stuff that I don't actually need. It should work fine on any terminal emulator with 256 colors support as it basically handle ANSI escape codes. It can convert hexadecimal RGB values (as in #FF3100) into the closest ANSI value available, so you can use RGB colors to print to the terminal.

As I just needed to be able to handle foreground/background colors and font decoration I focused on that and wrote some methods to control it as straightforwardly as I could.

To handle all the possible colors, the class basically generates the 216 values in a 6x6x6 predefined ANSI cube matrix as per it's pre-determined value increments, besides attributing the standard ANSI values for the 16 basic colors and 16 shades of gray.