/* Shortlist of ANSI-VT100 Escape Sequence */ /* cf. Palettes/palette-*.h pour versions etendues */ #define ATT_RST "\e[0m" /* = Reset */ #define ATT_BOLD "\e[1m" /* = Bold */ #define ATT_UND "\e[4m" /* = Underline */ #define ATT_REV "\e[7m" /* = Rev. Video */ #define ATT_FG1 "\e[31m" /* RED */ #define ATT_FG2 "\e[32m" /* GREEN */ #define ATT_FG4 "\e[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(ATT_RST); if (i!=0) printf(color_map[(i-1)%color_map_size]); }