Sfoglia il codice sorgente

Reduce processing if NNN_COLORS is unset

master
Arun Prakash Jana 4 anni fa
parent
commit
b948423a80
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: A75979F35C080412
1 ha cambiato i file con 38 aggiunte e 36 eliminazioni
  1. +38
    -36
      src/nnn.c

+ 38
- 36
src/nnn.c Vedi File

@@ -1586,54 +1586,56 @@ 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) {
char *sep = strchr(colors, ';'); if (*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 */
for (uchar i = 0; i < CTX_MAX; ++i) {
pcode = &g_ctx[i].color;


if (colors && *colors) { /*
if (ext) { * If fallback colors are specified, set the separator
ch = *colors; * to NULL so we don't interpret separator and fallback
if (*++colors) { * if fewer than CTX_MAX xterm 256 colors are specified.
*pcode = (16 * xchartohex(ch)) + xchartohex(*colors); */
++colors; if (sep)
} else *sep = '\0';
*pcode = xchartohex(ch);
} else { } else {
*pcode = (*colors < '0' || *colors > '7') ? 4 : *colors - '0'; colors = sep; /* Detect if 8 colors fallback is appended */
++colors; if (colors)
++colors;
} }
} else }
*pcode = 4; /* Get and set the context colors */
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, *pcode, -1); init_pair(i + 1, *pclr, -1);
}
} }
} }




||||||
x
 
000:0
Loading…
Annulla
Salva