@@ -16,19 +16,10 @@ #include "config.h" #include -#include - -#ifdef HAVE_SYS_IOCTL_H -# include -#endif -#ifdef HAVE_SYS_TTYCOM_H -# include -#endif - #import "OFDate.h" #import "OFStdIOStream.h" #import "OFTimer.h" #import "ProgressBar.h" @@ -91,21 +82,19 @@ } - (void)_drawProgress { float bars, percent; - unsigned short barWidth; -#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) - struct winsize ws; - - if (ioctl(0, TIOCGWINSZ, &ws) == 0 && ws.ws_col > 37) - barWidth = ws.ws_col - 37; - else - barWidth = 0; -#else - barWidth = 43; -#endif + int columns, barWidth; + + if ((columns = [of_stdout columns]) >= 0) { + if (columns > 37) + barWidth = columns - 37; + else + barWidth = 0; + } else + barWidth = 43; bars = (float)(_resumedFrom + _received) / (float)(_resumedFrom + _length) * barWidth; percent = (float)(_resumedFrom + _received) / (float)(_resumedFrom + _length) * 100;