diff --git a/doc/ncdu.pod b/doc/ncdu.pod index 2fcc981..c300f30 100644 --- a/doc/ncdu.pod +++ b/doc/ncdu.pod @@ -136,9 +136,12 @@ accidentally press 'q' during or after a very long scan. =item --color I -Select a color scheme. Currently only two schemes are recognized: I to -disable colors (the default) and I for a color scheme intended for dark -backgrounds. +Select a color scheme. The following schemes are recognized: I to disable +colors, I for a color scheme intended for dark backgrounds and I +for a variation of the I color scheme that also works in terminals with a +light background. + +The default is I unless the C environment variable is set. =back diff --git a/src/main.c b/src/main.c index c72a208..9f1d798 100644 --- a/src/main.c +++ b/src/main.c @@ -122,6 +122,8 @@ static void argv_parse(int argc, char **argv) { char *import = NULL; char *dir = NULL; + uic_theme = getenv("NO_COLOR") ? 0 : 2; + static yopt_opt_t opts[] = { { 'h', 0, "-h,-?,--help" }, { 'q', 0, "-q" }, @@ -177,7 +179,7 @@ static void argv_parse(int argc, char **argv) { printf(" --exclude-firmlinks Exclude firmlinks on macOS\n"); #endif printf(" --confirm-quit Confirm quitting ncdu\n"); - printf(" --color SCHEME Set color scheme (off/dark)\n"); + printf(" --color SCHEME Set color scheme (off/dark/dark-bg)\n"); exit(0); case 'q': update_delay = 2000; break; case 'v': @@ -229,6 +231,7 @@ static void argv_parse(int argc, char **argv) { case 'c': if(strcmp(val, "off") == 0) { uic_theme = 0; } else if(strcmp(val, "dark") == 0) { uic_theme = 1; } + else if(strcmp(val, "dark-bg") == 0) { uic_theme = 2; } else { fprintf(stderr, "Unknown --color option: %s\n", val); exit(1); diff --git a/src/util.c b/src/util.c index 8ea0f49..91c4360 100644 --- a/src/util.c +++ b/src/util.c @@ -250,10 +250,16 @@ static const struct { short fg, bg; int attr; } color_defs[] = { -#define C(name, off_fg, off_bg, off_a, dark_fg, dark_bg, dark_a) \ - {off_fg, off_bg, off_a}, \ - {dark_fg, dark_bg, dark_a}, +#define COLOR__ -1 +#define B A_BOLD +#define R A_REVERSE +#define C(name, off_fg, off_bg, off_a, dark_fg, dark_bg, dark_a, darkbg_fg, darkbg_bg, darkbg_a) \ + {COLOR_##off_fg, COLOR_##off_bg, off_a}, \ + {COLOR_##dark_fg, COLOR_##dark_bg, dark_a}, \ + {COLOR_##darkbg_fg, COLOR_##darkbg_bg, darkbg_a}, UI_COLORS +#undef B +#undef R #undef C {0,0,0} }; @@ -264,7 +270,7 @@ void uic_init() { start_color(); use_default_colors(); for(i=0; i