Paste your codes to fayaa.com/code/new, then copy it's highlighted outputs here, need no plugins, like:
#include <stdio.h>
#define D_NONE "\033[m"
#define D_RED "\033[0;32;31m"
#define D_LIGHT_RED "\033[1;31m"
#define D_GREEN "\033[0;32;32m"
#define D_LIGHT_GREEN "\033[1;32m"
#define D_BLUE "\033[0;32;34m"
#define D_LIGHT_BLUE "\033[1;34m"
#define D_DARY_GRAY "\033[1;30m"
#define D_CYAN "\033[0;36m"
#define D_LIGHT_CYAN "\033[1;36m"
#define D_PURPLE "\033[0;35m"
#define D_LIGHT_PURPLE "\033[1;35m"
#define D_BROWN "\033[0;33m"
#define D_YELLOW "\033[1;33m"
#define D_LIGHT_GRAY "\033[0;37m"
#define D_WHITE "\033[1;37m"
int main()
{
printf(CYAN "current function is %s " GREEN " file line is %d\n" NONE,
__FUNCTION__, __LINE__ );
fprintf(stderr, RED "current function is %s " BLUE " file line is %d\n" NONE,
__FUNCTION__, __LINE__ );
return 0;
}
#define D_NONE "\033[m"
#define D_RED "\033[0;32;31m"
#define D_LIGHT_RED "\033[1;31m"
#define D_GREEN "\033[0;32;32m"
#define D_LIGHT_GREEN "\033[1;32m"
#define D_BLUE "\033[0;32;34m"
#define D_LIGHT_BLUE "\033[1;34m"
#define D_DARY_GRAY "\033[1;30m"
#define D_CYAN "\033[0;36m"
#define D_LIGHT_CYAN "\033[1;36m"
#define D_PURPLE "\033[0;35m"
#define D_LIGHT_PURPLE "\033[1;35m"
#define D_BROWN "\033[0;33m"
#define D_YELLOW "\033[1;33m"
#define D_LIGHT_GRAY "\033[0;37m"
#define D_WHITE "\033[1;37m"
int main()
{
printf(CYAN "current function is %s " GREEN " file line is %d\n" NONE,
__FUNCTION__, __LINE__ );
fprintf(stderr, RED "current function is %s " BLUE " file line is %d\n" NONE,
__FUNCTION__, __LINE__ );
return 0;
}
Yeah, so wonderful :)
And this's a trick to colorful program outputs, useful for debug.
When under shell(bash),
echo -e "\033[0;32;31m look at me \033[m"
echo -e "${D_RED}hello world${D_NONE}"
echo -e "${D_RED}hello world${D_NONE}"
'-e' means dealing with escaping chars.
Remember the following '\033[m', it's the ending & reseting mark.
Learned from here.
UPDATE:
I add a prefix D_ to every color macro, coz I met a bug.
#include "colorful.h"
enum {
GREEN = 0,
BLUE,
YELLOW,
ORANGE
RED
};
gcc complained that error: expected identifier before string constant .
A lot of time we'll define color name to express something else.
UPDATE:
I add a prefix D_ to every color macro, coz I met a bug.
#include "colorful.h"
enum {
GREEN = 0,
BLUE,
YELLOW,
ORANGE
RED
};
gcc complained that error: expected identifier before string constant .
A lot of time we'll define color name to express something else.