aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-08-02 23:18:13 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-08-02 23:18:13 +0530
commitb3f2e471737345e0bead3d44da05e59eada6db01 (patch)
tree5200c4dc70071820d9e4d1b1725ab43b4e0c5b21 /src
parentb948423a80759becf7c1ca2c9831960b5b43c5f8 (diff)
downloadnnn-b3f2e471737345e0bead3d44da05e59eada6db01.tar.gz
Revert "Reduce processing if NNN_COLORS is unset"
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 781fad8..336c0c1 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1586,56 +1586,54 @@ static bool initcurses(void *oldmask)
char *colors = getenv(env_cfg[NNN_COLORS]);
if (colors || !getenv("NO_COLOR")) {
- uint *pclr;
+ uint *pcode;
char ch;
bool ext = FALSE;
start_color();
use_default_colors();
- if (colors) {
- if (*colors == '#') {
- char *sep = strchr(colors, ';');
+ if (colors && *colors == '#') {
+ char *sep = strchr(colors, ';');
- if (COLORS >= 256) {
- ++colors;
- ext = TRUE;
+ 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;
- }
+ /*
+ * 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;
}
+ }
- /* 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';
+ /* Get and set the context colors */
+ for (uchar i = 0; i < CTX_MAX; ++i) {
+ pcode = &g_ctx[i].color;
+
+ if (colors && *colors) {
+ if (ext) {
+ ch = *colors;
+ if (*++colors) {
+ *pcode = (16 * xchartohex(ch)) + xchartohex(*colors);
++colors;
- }
- } else
- *pclr = 4;
+ } else
+ *pcode = xchartohex(ch);
+ } else {
+ *pcode = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
+ ++colors;
+ }
+ } else
+ *pcode = 4;
- init_pair(i + 1, *pclr, -1);
- }
+ init_pair(i + 1, *pcode, -1);
}
}