Respect COLUMNS

This commit is contained in:
Roy Marples 2007-10-03 11:49:08 +00:00
parent b675ca4779
commit 932a4576ce

View File

@ -176,6 +176,15 @@ static bool colour_terminal (void)
static int get_term_columns (FILE *stream)
{
struct winsize ws;
char *env = getenv ("COLUMNS");
char *p;
int i;
if (env) {
i = strtol (env, &p, 10);
if (! *p)
return (i);
}
if (ioctl (fileno (stream), TIOCGWINSZ, &ws) == 0)
return (ws.ws_col);