Column fix when stdout is redirected. Default to 80.
This commit is contained in:
parent
23f0f778ef
commit
d59585c24f
1 changed files with 6 additions and 0 deletions
|
@ -54,6 +54,12 @@ extern int neednl;
|
||||||
/* gets the current screen column width */
|
/* gets the current screen column width */
|
||||||
int getcols()
|
int getcols()
|
||||||
{
|
{
|
||||||
|
if(!isatty(1)) {
|
||||||
|
/* We will default to 80 columns if we're not a tty
|
||||||
|
* this seems a fairly standard file width.
|
||||||
|
*/
|
||||||
|
return 80;
|
||||||
|
}
|
||||||
#ifdef TIOCGSIZE
|
#ifdef TIOCGSIZE
|
||||||
struct ttysize win;
|
struct ttysize win;
|
||||||
if(ioctl(1, TIOCGSIZE, &win) == 0) {
|
if(ioctl(1, TIOCGSIZE, &win) == 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue