color: Cleanup code to remove "magic" offset + 7
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
This commit is contained in:
parent
24b058a2a4
commit
99b89c518e
13
lib/color.c
13
lib/color.c
|
|
@ -45,8 +45,8 @@ static const char * const color_codes[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum color attr_colors[] = {
|
/* light background */
|
||||||
/* light background */
|
static enum color attr_colors_light[] = {
|
||||||
C_CYAN,
|
C_CYAN,
|
||||||
C_YELLOW,
|
C_YELLOW,
|
||||||
C_MAGENTA,
|
C_MAGENTA,
|
||||||
|
|
@ -54,8 +54,10 @@ static enum color attr_colors[] = {
|
||||||
C_GREEN,
|
C_GREEN,
|
||||||
C_RED,
|
C_RED,
|
||||||
C_CLEAR,
|
C_CLEAR,
|
||||||
|
};
|
||||||
|
|
||||||
/* dark background */
|
/* dark background */
|
||||||
|
static enum color attr_colors_dark[] = {
|
||||||
C_BOLD_CYAN,
|
C_BOLD_CYAN,
|
||||||
C_BOLD_YELLOW,
|
C_BOLD_YELLOW,
|
||||||
C_BOLD_MAGENTA,
|
C_BOLD_MAGENTA,
|
||||||
|
|
@ -109,8 +111,9 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += fprintf(fp, "%s",
|
ret += fprintf(fp, "%s", color_codes[is_dark_bg ?
|
||||||
color_codes[attr_colors[is_dark_bg ? attr + 7 : attr]]);
|
attr_colors_dark[attr] : attr_colors_light[attr]]);
|
||||||
|
|
||||||
ret += vfprintf(fp, fmt, args);
|
ret += vfprintf(fp, fmt, args);
|
||||||
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
|
ret += fprintf(fp, "%s", color_codes[C_CLEAR]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue