@@ -76,22 +76,46 @@ int git_color_config(const char *var, const char *value, void *cb);
76
76
int git_color_default_config (const char * var , const char * value , void * cb );
77
77
78
78
/*
79
- * Set the color buffer (which must be COLOR_MAXLEN bytes)
80
- * to the raw color bytes; this is useful for initializing
81
- * default color variables.
79
+ * Parse a config option, which can be a boolean or one of
80
+ * "never", "auto", "always". Return a constant of
81
+ * GIT_COLOR_NEVER for "never" or negative boolean,
82
+ * GIT_COLOR_ALWAYS for "always" or a positive boolean,
83
+ * and GIT_COLOR_AUTO for "auto".
82
84
*/
83
- void color_set (char * dst , const char * color_bytes );
84
-
85
85
int git_config_colorbool (const char * var , const char * value );
86
+
87
+ /*
88
+ * Return a boolean whether to use color, where the argument 'var' is
89
+ * one of GIT_COLOR_UNKNOWN, GIT_COLOR_NEVER, GIT_COLOR_ALWAYS, GIT_COLOR_AUTO.
90
+ */
86
91
int want_color (int var );
92
+
93
+ /*
94
+ * Translate a Git color from 'value' into a string that the terminal can
95
+ * interpret and store it into 'dst'. The Git color values are of the form
96
+ * "foreground [background] [attr]" where fore- and background can be a color
97
+ * name ("red"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.
98
+ */
87
99
int color_parse (const char * value , char * dst );
88
100
int color_parse_mem (const char * value , int len , char * dst );
101
+
102
+ /*
103
+ * Output the formatted string in the specified color (and then reset to normal
104
+ * color so subsequent output is uncolored). Omits the color encapsulation if
105
+ * `color` is NULL. The `color_fprintf_ln` prints a new line after resetting
106
+ * the color. The `color_print_strbuf` prints the contents of the given
107
+ * strbuf (BUG: but only up to its first NUL character).
108
+ */
89
109
__attribute__((format (printf , 3 , 4 )))
90
110
int color_fprintf (FILE * fp , const char * color , const char * fmt , ...);
91
111
__attribute__((format (printf , 3 , 4 )))
92
112
int color_fprintf_ln (FILE * fp , const char * color , const char * fmt , ...);
93
113
void color_print_strbuf (FILE * fp , const char * color , const struct strbuf * sb );
94
114
115
+ /*
116
+ * Check if the given color is GIT_COLOR_NIL that means "no color selected".
117
+ * The caller needs to replace the color with the actual desired color.
118
+ */
95
119
int color_is_nil (const char * color );
96
120
97
121
#endif /* COLOR_H */
0 commit comments