Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -51,10 +51,15 @@ bool _closable; #endif bool _atEndOfStream; } +/*! + * @brief Whether there is an underlying terminal. + */ +@property (readonly, nonatomic) bool hasTerminal; + /*! * @brief The number of columns, or -1 if there is no underlying terminal or * the number of columns could not be queried. */ @property (readonly, nonatomic) int columns; Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -383,10 +383,19 @@ - (unsigned int)retainCount { return OF_RETAIN_COUNT_MAX; } + +- (bool)hasTerminal +{ +#if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) + return isatty(_fd); +#else + return false; +#endif +} - (int)columns { #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS) struct winsize ws; Index: src/OFWin32ConsoleStdIOStream.m ================================================================== --- src/OFWin32ConsoleStdIOStream.m +++ src/OFWin32ConsoleStdIOStream.m @@ -453,10 +453,19 @@ * since any incomplete write is an exception here anyway, we can just * return length. */ return length; } + +- (bool)hasTerminal +{ + /* + * We can never get here if there is no terminal, as the initializer + * changes the class to OFStdIOStream in that case. + */ + return true; +} - (int)columns { CONSOLE_SCREEN_BUFFER_INFO csbi;