#include <time.h>
#endif
#include <string.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/ioctl.h>
#ifndef NAJOR
#define MAJOR(dev) (((dev)>>8)&0xff)
static unsigned short terminal_width;
static unsigned short column_width;
static unsigned short tabstops;
+#else
+static unsigned short column_width = COLUMN_WIDTH;
#endif
static int status = EXIT_SUCCESS;
column++;
}
}
- nexttab= column + column_width + COLUMN_GAP ;
+ nexttab= column + column_width + COLUMN_GAP;
}
/*----------------------------------------------------------------------*/
;
if (column_width < len) column_width= len;
}
-#endif
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
+#else
+ ncols= TERMINAL_WIDTH;
+#endif
switch (style_fmt) {
case STYLE_LONG: /* one record per line, extended info */
case STYLE_SINGLE: /* one record per line */
int opt;
int oi, ac;
char **av;
+#ifdef BB_FEATURE_AUTOWIDTH
+ struct winsize win = { 0, 0, 0, 0 };
+#endif
disp_opts= DISP_NORMAL;
style_fmt= STYLE_AUTO;
time_fmt= TIME_MOD;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
- terminal_width = TERMINAL_WIDTH;
- column_width = COLUMN_WIDTH;
- tabstops = 8;
+ ioctl(fileno(stdout), TIOCGWINSZ, &win);
+ if (win.ws_row > 4)
+ column_width = win.ws_row - 2;
+ if (win.ws_col > 0)
+ terminal_width = win.ws_col - 1;
#endif
+ tabstops = 8;
nfiles=0;
/* process options */
showdirs(dnd, dndirs);
}
}
-
return(status);
print_usage_message: