Skip to content

Commit

Permalink
[v1.05] Add support for NO_COLOR (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Noob committed Feb 13, 2024
1 parent c01f60f commit 4a8a756
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/common/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ struct ascii_logo* choose_ascii_art_aux(struct ascii_logo* logo_long, struct asc
}
}

// https://no-color.org/
bool is_color_enabled(void) {
const char *var_name = "NO_COLOR";
char *no_color = getenv(var_name);
return no_color == NULL || no_color[0] == '\0';
}

void choose_ascii_art(struct ascii* art, struct color** cs, struct terminal* term, int lf) {
// 1. Choose logo
#ifdef ARCH_X86
Expand Down Expand Up @@ -394,6 +401,9 @@ void choose_ascii_art(struct ascii* art, struct color** cs, struct terminal* ter

// 2. Choose colors
struct ascii_logo* logo = art->art;
bool color = is_color_enabled();
if (!color)
art->style = STYLE_LEGACY;

switch(art->style) {
case STYLE_LEGACY:
Expand Down

0 comments on commit 4a8a756

Please sign in to comment.