X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=color.h;h=03ca0647485e8044d4131f2c61c37b4e9408cd2a;hb=c14daa4845ff2ec0d27807fa50f9fac1ca4d6462;hp=3cb4b7fc890880b0fcf19a11c6bc7de6b10d6e8d;hpb=abf411e28d9df669b0e690578a1eb95c0bd29847;p=git.git diff --git a/color.h b/color.h index 3cb4b7fc8..03ca06474 100644 --- a/color.h +++ b/color.h @@ -1,8 +1,20 @@ #ifndef COLOR_H #define COLOR_H -/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ -#define COLOR_MAXLEN 24 +/* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */ +/* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */ +/* + * The maximum length of ANSI color sequence we would generate: + * - leading ESC '[' 2 + * - attr + ';' 2 * 8 (e.g. "1;") + * - fg color + ';' 9 (e.g. "38;5;2xx;") + * - fg color + ';' 9 (e.g. "48;5;2xx;") + * - terminating 'm' NUL 2 + * + * The above overcounts attr (we only use 5 not 8) and one semicolon + * but it is close enough. + */ +#define COLOR_MAXLEN 40 /* * IMPORTANT: Due to the way these color codes are emulated on Windows, @@ -18,7 +30,18 @@ #define GIT_COLOR_BLUE "\033[34m" #define GIT_COLOR_MAGENTA "\033[35m" #define GIT_COLOR_CYAN "\033[36m" +#define GIT_COLOR_BOLD_RED "\033[1;31m" +#define GIT_COLOR_BOLD_GREEN "\033[1;32m" +#define GIT_COLOR_BOLD_YELLOW "\033[1;33m" +#define GIT_COLOR_BOLD_BLUE "\033[1;34m" +#define GIT_COLOR_BOLD_MAGENTA "\033[1;35m" +#define GIT_COLOR_BOLD_CYAN "\033[1;36m" #define GIT_COLOR_BG_RED "\033[41m" +#define GIT_COLOR_BG_GREEN "\033[42m" +#define GIT_COLOR_BG_YELLOW "\033[43m" +#define GIT_COLOR_BG_BLUE "\033[44m" +#define GIT_COLOR_BG_MAGENTA "\033[45m" +#define GIT_COLOR_BG_CYAN "\033[46m" /* * This variable stores the value of color.ui @@ -38,6 +61,5 @@ __attribute__((format (printf, 3, 4))) int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); __attribute__((format (printf, 3, 4))) int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); -int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); #endif /* COLOR_H */