aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-05 05:53:46 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-05 05:53:46 +0530
commit02c02c520d42ac769c3de2a82677fbb2fbd86df4 (patch)
tree06cd88a95e9c755317e85a1930d02f50e019cc4e /src/nnn.c
parent0e3146ebd2e19720401acb4f26bd0f9e7dd7526a (diff)
downloadnnn-02c02c520d42ac769c3de2a82677fbb2fbd86df4.tar.gz
Option -C to disable color
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 71d1c49..090a15c 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -400,6 +400,7 @@ static char g_pipepath[TMP_LEN_MAX] __attribute__ ((aligned));
#define STATE_TRASH 0x40
#define STATE_FORCEQUIT 0x80
#define STATE_FORTUNE 0x100
+#define STATE_NOCOLOR 0x200
static uint g_states;
@@ -1522,18 +1523,21 @@ static bool initcurses(void *oldmask)
mouseinterval(0);
#endif
curs_set(FALSE); /* Hide cursor */
- start_color();
- use_default_colors();
-
- /* Get and set the context colors */
- for (i = 0; i < CTX_MAX; ++i) {
- if (*colors) {
- g_ctx[i].color = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
- ++colors;
- } else
- g_ctx[i].color = 4;
- init_pair(i + 1, g_ctx[i].color, -1);
+ if (!(g_states & STATE_NOCOLOR)) {
+ start_color();
+ use_default_colors();
+
+ /* Get and set the context colors */
+ for (i = 0; i < CTX_MAX; ++i) {
+ if (*colors) {
+ g_ctx[i].color = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
+ ++colors;
+ } else
+ g_ctx[i].color = 4;
+
+ init_pair(i + 1, g_ctx[i].color, -1);
+ }
}
settimeout(); /* One second */
@@ -3206,7 +3210,7 @@ static char get_ind(mode_t mode, bool perms)
return '*';
return '\0';
case S_IFDIR:
- return perms ? 'd' : '\0';
+ return perms ? 'd' : '/';
case S_IFLNK:
return perms ? 'l' : '@';
case S_IFSOCK:
@@ -3303,16 +3307,19 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
addch('0' + (ent->mode & 7));
switch (ent->mode & S_IFMT) {
+ case S_IFDIR:
+ ind2 = '/'; // fallthrough
case S_IFREG:
- if (ent->flags & HARD_LINK)
- ln = TRUE;
+ if (!ind2) {
+ if (ent->flags & HARD_LINK)
+ ln = TRUE;
- if (ent->mode & 0100)
- ind2 = '*';
- // fallthrough
- case S_IFDIR:
- if (!ind2) /* Add a column if end indicator is not needed */
- ++namecols;
+ if (ent->mode & 0100)
+ ind2 = '*';
+
+ if (!ind2) /* Add a column if end indicator is not needed */
+ ++namecols;
+ }
size = coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size);
len = 10 - (uint)strlen(size);
@@ -6577,6 +6584,7 @@ static void usage(void)
" -A no dir auto-select\n"
" -b key open bookmark key\n"
" -c cli-only opener (overrides -e)\n"
+ " -C disable color\n"
" -d detail mode\n"
" -e text in $VISUAL/$EDITOR/vi\n"
" -E use EDITOR for undetached edits\n"
@@ -6748,7 +6756,7 @@ int main(int argc, char *argv[])
while ((opt = (env_opts_id > 0
? env_opts[--env_opts_id]
- : getopt(argc, argv, "Ab:cdeEfFgHKnop:QrRs:St:T:Vxh"))) != -1) {
+ : getopt(argc, argv, "Ab:cCdeEfFgHKnop:QrRs:St:T:Vxh"))) != -1) {
switch (opt) {
case 'A':
cfg.autoselect = 0;
@@ -6759,6 +6767,9 @@ int main(int argc, char *argv[])
case 'c':
cfg.cliopener = 1;
break;
+ case 'C':
+ g_states |= STATE_NOCOLOR;
+ break;
case 'S':
cfg.blkorder = 1;
nftw_fn = sum_bsize;