Reduce processing if NNN_COLORS is unset

This commit is contained in:
Arun Prakash Jana 2020-08-02 23:15:48 +05:30
parent 359b6f7a37
commit b948423a80
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -1586,14 +1586,15 @@ 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 *pcode; uint *pclr;
char ch; char ch;
bool ext = FALSE; bool ext = FALSE;
start_color(); start_color();
use_default_colors(); use_default_colors();
if (colors && *colors == '#') { if (colors) {
if (*colors == '#') {
char *sep = strchr(colors, ';'); char *sep = strchr(colors, ';');
if (COLORS >= 256) { if (COLORS >= 256) {
@ -1616,24 +1617,25 @@ static bool initcurses(void *oldmask)
/* Get and set the context colors */ /* Get and set the context colors */
for (uchar i = 0; i < CTX_MAX; ++i) { for (uchar i = 0; i < CTX_MAX; ++i) {
pcode = &g_ctx[i].color; pclr = &g_ctx[i].color;
if (colors && *colors) { if (*colors) {
if (ext) { if (ext) {
ch = *colors; ch = *colors;
if (*++colors) { if (*++colors) {
*pcode = (16 * xchartohex(ch)) + xchartohex(*colors); *pclr = (16 * xchartohex(ch)) + xchartohex(*colors);
++colors; ++colors;
} else } else
*pcode = xchartohex(ch); *pclr = xchartohex(ch);
} else { } else {
*pcode = (*colors < '0' || *colors > '7') ? 4 : *colors - '0'; *pclr = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
++colors; ++colors;
} }
} else } else
*pcode = 4; *pclr = 4;
init_pair(i + 1, *pcode, -1); init_pair(i + 1, *pclr, -1);
}
} }
} }