diff --git a/inotify-info.cpp b/inotify-info.cpp index 7706e84..e62f8ee 100644 --- a/inotify-info.cpp +++ b/inotify-info.cpp @@ -78,6 +78,24 @@ static char thousands_sep = ','; static std::vector ignore_dirs; +const char *RESET = "\x1b[0m"; +const char *YELLOW = "\x1b[0;33m"; +const char *CYAN = "\x1b[0;36m"; +const char *BGRAY = "\x1b[1;30m"; +const char *BGREEN = "\x1b[1;32m"; +const char *BYELLOW = "\x1b[1;33m"; +const char *BCYAN = "\x1b[1;36m"; + +void set_no_color() { + RESET = ""; + YELLOW = ""; + CYAN = ""; + BGRAY = ""; + BGREEN = ""; + BYELLOW = ""; + BCYAN = ""; +} + /* * filename info */ @@ -1007,6 +1025,7 @@ static void parse_cmdline(int argc, char** argv, std::vector& cmdli { static struct option long_opts[] = { { "verbose", no_argument, 0, 0 }, + { "no-color", no_argument, 0, 0 }, { "threads", required_argument, 0, 0 }, { "ignoredir", required_argument, 0, 0 }, { "version", no_argument, 0, 0 }, @@ -1032,6 +1051,8 @@ static void parse_cmdline(int argc, char** argv, std::vector& cmdli } if (!strcasecmp("verbose", long_opts[opt_ind].name)) g_verbose++; + else if (!strcasecmp("no-color", long_opts[opt_ind].name)) + set_no_color(); else if (!strcasecmp("threads", long_opts[opt_ind].name)) g_numthreads = atoi(optarg); else if (!strcasecmp("ignoredir", long_opts[opt_ind].name)) { diff --git a/inotify-info.h b/inotify-info.h index 095da7a..5e271b8 100644 --- a/inotify-info.h +++ b/inotify-info.h @@ -22,24 +22,6 @@ * THE SOFTWARE. */ -#define RESET "\x1b[0m" -#define GRAY "\x1b[0;30m" -#define RED "\x1b[0;31m" -#define GREEN "\x1b[0;32m" -#define YELLOW "\x1b[0;33m" -#define BLUE "\x1b[0;34m" -#define MAGENTA "\x1b[0;35m" -#define CYAN "\x1b[0;36m" -#define WHITE "\x1b[0;37m" -#define BGRAY "\x1b[1;30m" -#define BRED "\x1b[1;31m" -#define BGREEN "\x1b[1;32m" -#define BYELLOW "\x1b[1;33m" -#define BBLUE "\x1b[1;34m" -#define BMAGENTA "\x1b[1;35m" -#define BCYAN "\x1b[1;36m" -#define BWHITE "\x1b[1;37m" - #define TO_STR(x) #x #define TO_STR_VALUE(x) TO_STR(x)