X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=color.c;h=3db214c24720496f13481b718e46810c21f53b8d;hb=f174a2583c9f42315b60205890fa67a79a1f1669;hp=6a5a54ec668e08ddef0d2f27359f3ebb3272243b;hpb=bac9c06ba093d9254cb2ab3eed074722a3e635a6;p=git.git diff --git a/color.c b/color.c index 6a5a54ec6..3db214c24 100644 --- a/color.c +++ b/color.c @@ -3,6 +3,28 @@ int git_use_color_default = 0; +/* + * The list of available column colors. + */ +const char *column_colors_ansi[] = { + GIT_COLOR_RED, + GIT_COLOR_GREEN, + GIT_COLOR_YELLOW, + GIT_COLOR_BLUE, + GIT_COLOR_MAGENTA, + GIT_COLOR_CYAN, + GIT_COLOR_BOLD_RED, + GIT_COLOR_BOLD_GREEN, + GIT_COLOR_BOLD_YELLOW, + GIT_COLOR_BOLD_BLUE, + GIT_COLOR_BOLD_MAGENTA, + GIT_COLOR_BOLD_CYAN, + GIT_COLOR_RESET, +}; + +/* Ignore the RESET at the end when giving the size */ +const int column_colors_ansi_max = ARRAY_SIZE(column_colors_ansi) - 1; + static int parse_color(const char *name, int len) { static const char * const color_names[] = { @@ -175,6 +197,15 @@ int git_color_default_config(const char *var, const char *value, void *cb) return git_default_config(var, value, cb); } +void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb) +{ + if (*color) + fprintf(fp, "%s", color); + fprintf(fp, "%s", sb->buf); + if (*color) + fprintf(fp, "%s", GIT_COLOR_RESET); +} + static int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args, const char *trail) {