mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Change to light mode if < 35 columns are available
This commit is contained in:
parent
2e3f013ce3
commit
7ec524c231
24
nnn.c
24
nnn.c
|
@ -1919,12 +1919,20 @@ redraw(char *path)
|
||||||
{
|
{
|
||||||
static int nlines, i;
|
static int nlines, i;
|
||||||
static size_t ncols;
|
static size_t ncols;
|
||||||
|
static bool mode_changed;
|
||||||
|
|
||||||
|
mode_changed = FALSE;
|
||||||
nlines = MIN(LINES - 4, ndents);
|
nlines = MIN(LINES - 4, ndents);
|
||||||
|
|
||||||
/* Clean screen */
|
/* Clean screen */
|
||||||
erase();
|
erase();
|
||||||
|
|
||||||
|
/* Fail redraw if < than 10 columns */
|
||||||
|
if (COLS < 10) {
|
||||||
|
printmsg("Too few columns!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Strip trailing slashes */
|
/* Strip trailing slashes */
|
||||||
for (i = xstrlen(path) - 1; i > 0; --i)
|
for (i = xstrlen(path) - 1; i > 0; --i)
|
||||||
if (path[i] == '/')
|
if (path[i] == '/')
|
||||||
|
@ -1944,7 +1952,16 @@ redraw(char *path)
|
||||||
ncols = COLS;
|
ncols = COLS;
|
||||||
if (ncols > PATH_MAX)
|
if (ncols > PATH_MAX)
|
||||||
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';
|
g_buf[ncols - 6] = '\0';
|
||||||
printw(CWD "%s\n\n", g_buf);
|
printw(CWD "%s\n\n", g_buf);
|
||||||
|
|
||||||
|
@ -2014,6 +2031,11 @@ redraw(char *path)
|
||||||
} else
|
} else
|
||||||
printmsg("0 items");
|
printmsg("0 items");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode_changed) {
|
||||||
|
cfg.showdetail ^= 1;
|
||||||
|
printptr = &printent_long;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue