aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-03-08 03:13:28 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-03-08 04:49:43 +0530
commit879beb70cf94b342d0c82c50fda3d48d41cd3d85 (patch)
tree750a7866b642a73afd61b5f66eb103769fe83993 /src/nnn.c
parent4885b5fc2f7e9a0f81ac5f41c85f72a851beaad1 (diff)
downloadnnn-879beb70cf94b342d0c82c50fda3d48d41cd3d85.tar.gz
Combine checks
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/nnn.c b/src/nnn.c
index e083473..48be271 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2741,9 +2741,9 @@ static void populate(char *path, char *lastname)
static void redraw(char *path)
{
- static char buf[NAME_MAX + 65] __attribute__ ((aligned));
+ char buf[NAME_MAX + 65];
char c;
- size_t ncols = COLS;
+ size_t ncols = (COLS <= PATH_MAX) ? COLS : PATH_MAX;
int nlines = MIN(LINES - 4, ndents), i, attrs;
/* Clear screen */
@@ -2758,7 +2758,7 @@ static void redraw(char *path)
#endif
/* Fail redraw if < than 11 columns, context info prints 10 chars */
- if (COLS < 11) {
+ if (ncols < 11) {
printmsg("too few columns!");
return;
}
@@ -2766,9 +2766,6 @@ static void redraw(char *path)
DPRINTF_D(cur);
DPRINTF_S(path);
- if (ncols > PATH_MAX)
- ncols = PATH_MAX;
-
printw("[");
for (i = 0; i < CTX_MAX; ++i) {
if (!g_ctx[i].c_cfg.ctxactive)
@@ -2799,16 +2796,16 @@ static void redraw(char *path)
attroff(A_UNDERLINE);
path[ncols - 11] = c;
- /* Fallback to light mode if less than 35 columns */
- if (ncols < 35 && cfg.showdetail) {
- cfg.showdetail ^= 1;
- printptr = &printent;
- }
-
/* Calculate the number of cols available to print entry name */
- if (cfg.showdetail)
- ncols -= 35;
- else
+ if (cfg.showdetail) {
+ /* Fallback to light mode if less than 35 columns */
+ if (ncols < 36) {
+ cfg.showdetail ^= 1;
+ printptr = &printent;
+ ncols -= 5;
+ } else
+ ncols -= 35;
+ } else
ncols -= 5;
if (!cfg.wild) {