Wednesday, 27 May 2015

Put some colour in your C code

I like colours.

Colours make things easier to spot, especially if you have to look at a few metres of test output bumpf --- looking for something blue or pink is much quicker.

So, I made myself a little color.h file that lives in /usr/include/ where it is available anywhere I need some colour in my code.

You will probably notice the colour names --- I took the liberty of renaming 'green' to 'moss', 'bold green' to just 'green' and 'magenta' to 'purple' and so on.  It's less to type, more descriptive, and, also functions as a small cheat map to understand the weird names the fashionistas in your life use to describe colour shades.

You can find the source for color.h here, note that the test code is present in the file in a comment, ready to be copied into a *.c file.