@@ -22,10 +22,17 @@ # undef __USE_XOPEN #endif #include #include + +#ifdef HAVE_SYS_IOCTL_H +# include +#endif +#ifdef HAVE_SYS_TTYCOM_H +# include +#endif #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" @@ -202,6 +209,34 @@ - (void)dealloc { OF_DEALLOC_UNSUPPORTED } + +- (int)columns +{ +#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) + struct winsize ws; + + if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) + return -1; + + return ws.ws_col; +#else + return -1; +#endif +} + +- (int)rows +{ +#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) + struct winsize ws; + + if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) + return -1; + + return ws.ws_row; +#else + return -1; +#endif +} @end