/* Shortlist of ANSI-VT100 Escape Sequence */ /* cf. Palettes/palette-*.h pour versions etendues */ #define ATT_RST "\x1B[0m" /* =  Reset  */ #define ATT_BOLD "\x1B[1m" /* =  BOLD  */ #define ATT_UND "\x1B[4m" /* =  UNDERLINE  */ #define ATT_REV "\x1B[7m" /* =  REVERSE  */ #define ATT_FG1 "\x1B[31m" /* =  RED  */ #define ATT_FG2 "\x1B[32m" /* =  GREEN  */ #define ATT_FG4 "\x1B[34m" /* =  BLUE  */ /* Macro cpp pour Colorer une chaine */ /* ex : printf( RED("[ %s ]") , str); */ /* ex : printf( GREEN("%s")" / "RED("%s") , str1, str2); */ #define GREEN(str) ATT_FG2 str ATT_RST #define RED(str) ATT_FG1 str ATT_RST #define BLUE(str) ATT_FG4 str ATT_RST #define REV(str) ATT_REV str ATT_RST /* Fonction pour changer la couleur de stdout */ /* SET_COLOR(0) reset a la couleur par defaut */ /* SET_COLOR(i) passe a la couleur i (modulo N) */ #include static int color_map_size = 6; static char *color_map[] = { /* Green, Red, Blue, Rev_Green, Rev_Red, Rev Blue */ ATT_FG2, ATT_FG1 , ATT_FG4 , ATT_REV ATT_FG2, ATT_REV ATT_FG1 , ATT_REV ATT_FG4 } ; static __attribute__((unused)) void SET_COLOR (int i) { printf("%s",ATT_RST); if (i!=0) printf("%s",color_map[(i-1)%color_map_size]); }