aboutsummaryrefslogtreecommitdiffstats
path: root/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-09-01 18:58:32 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-09-01 18:58:32 +0530
commit7ec524c231b6ee043062844a4c975bae6f2d0a1e (patch)
treebe341ba7c70d7dadc2c5acfe65dceaefb85f17d4 /nnn.c
parent2e3f013ce33fc1b37252e409fa4a778ddd3116e5 (diff)
downloadnnn-7ec524c231b6ee043062844a4c975bae6f2d0a1e.tar.gz
Change to light mode if < 35 columns are available
Diffstat (limited to 'nnn.c')
-rw-r--r--nnn.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/nnn.c b/nnn.c
index 8882561..c54c112 100644
--- a/nnn.c
+++ b/nnn.c
@@ -1919,12 +1919,20 @@ redraw(char *path)
{
static int nlines, i;
static size_t ncols;
+ static bool mode_changed;
+ mode_changed = FALSE;
nlines = MIN(LINES - 4, ndents);
/* Clean screen */
erase();
+ /* Fail redraw if < than 10 columns */
+ if (COLS < 10) {
+ printmsg("Too few columns!");
+ return;
+ }
+
/* Strip trailing slashes */
for (i = xstrlen(path) - 1; i > 0; --i)
if (path[i] == '/')
@@ -1944,7 +1952,16 @@ redraw(char *path)
ncols = COLS;
if (ncols > PATH_MAX)
ncols = PATH_MAX;
- /* - xstrlen(CWD) - 1 = 6 */
+
+ /* Fallback to light mode if less than 35 columns */
+ if (ncols < 35 && cfg.showdetail) {
+ cfg.showdetail ^= 1;
+ printptr = &printent;
+ mode_changed = TRUE;
+ }
+
+
+ /* Show CWD: - xstrlen(CWD) - 1 = 6 */
g_buf[ncols - 6] = '\0';
printw(CWD "%s\n\n", g_buf);
@@ -2014,6 +2031,11 @@ redraw(char *path)
} else
printmsg("0 items");
}
+
+ if (mode_changed) {
+ cfg.showdetail ^= 1;
+ printptr = &printent_long;
+ }
}
static void