Revert "Reduce processing if NNN_COLORS is unset"

This reverts commit b948423a80.
This commit is contained in:
Arun Prakash Jana 2020-08-02 23:18:13 +05:30
parent b948423a80
commit b3f2e47173
1 changed files with 36 additions and 38 deletions

View File

@ -1586,56 +1586,54 @@ static bool initcurses(void *oldmask)
char *colors = getenv(env_cfg[NNN_COLORS]); char *colors = getenv(env_cfg[NNN_COLORS]);
if (colors || !getenv("NO_COLOR")) { if (colors || !getenv("NO_COLOR")) {
uint *pclr; uint *pcode;
char ch; char ch;
bool ext = FALSE; bool ext = FALSE;
start_color(); start_color();
use_default_colors(); use_default_colors();
if (colors) { if (colors && *colors == '#') {
if (*colors == '#') { char *sep = strchr(colors, ';');
char *sep = strchr(colors, ';');
if (COLORS >= 256) { if (COLORS >= 256) {
++colors;
ext = TRUE;
/*
* If fallback colors are specified, set the separator
* to NULL so we don't interpret separator and fallback
* if fewer than CTX_MAX xterm 256 colors are specified.
*/
if (sep)
*sep = '\0';
} else {
colors = sep; /* Detect if 8 colors fallback is appended */
if (colors)
++colors; ++colors;
ext = TRUE; }
}
/* /* Get and set the context colors */
* If fallback colors are specified, set the separator for (uchar i = 0; i < CTX_MAX; ++i) {
* to NULL so we don't interpret separator and fallback pcode = &g_ctx[i].color;
* if fewer than CTX_MAX xterm 256 colors are specified.
*/ if (colors && *colors) {
if (sep) if (ext) {
*sep = '\0'; ch = *colors;
if (*++colors) {
*pcode = (16 * xchartohex(ch)) + xchartohex(*colors);
++colors;
} else
*pcode = xchartohex(ch);
} else { } else {
colors = sep; /* Detect if 8 colors fallback is appended */ *pcode = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
if (colors) ++colors;
++colors;
} }
} } else
*pcode = 4;
/* Get and set the context colors */ init_pair(i + 1, *pcode, -1);
for (uchar i = 0; i < CTX_MAX; ++i) {
pclr = &g_ctx[i].color;
if (*colors) {
if (ext) {
ch = *colors;
if (*++colors) {
*pclr = (16 * xchartohex(ch)) + xchartohex(*colors);
++colors;
} else
*pclr = xchartohex(ch);
} else {
*pclr = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
++colors;
}
} else
*pclr = 4;
init_pair(i + 1, *pclr, -1);
}
} }
} }