File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ OF_SUBCLASSING_RESTRICTED
53
53
bool _atEndOfStream;
54
54
}
55
55
56
+ /* !
57
+ * @brief Whether there is an underlying terminal.
58
+ */
59
+ @property (readonly , nonatomic ) bool hasTerminal;
60
+
56
61
/* !
57
62
* @brief The number of columns, or -1 if there is no underlying terminal or
58
63
* the number of columns could not be queried.
Original file line number Diff line number Diff line change @@ -386,6 +386,15 @@ - (unsigned int)retainCount
386
386
return OF_RETAIN_COUNT_MAX;
387
387
}
388
388
389
+ - (bool )hasTerminal
390
+ {
391
+ #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS)
392
+ return isatty (_fd);
393
+ #else
394
+ return false ;
395
+ #endif
396
+ }
397
+
389
398
- (int )columns
390
399
{
391
400
#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS)
Original file line number Diff line number Diff line change @@ -456,6 +456,15 @@ - (size_t)lowlevelWriteBuffer: (const void *)buffer_
456
456
return length;
457
457
}
458
458
459
+ - (bool )hasTerminal
460
+ {
461
+ /*
462
+ * We can never get here if there is no terminal, as the initializer
463
+ * changes the class to OFStdIOStream in that case.
464
+ */
465
+ return true ;
466
+ }
467
+
459
468
- (int )columns
460
469
{
461
470
CONSOLE_SCREEN_BUFFER_INFO csbi;
You can’t perform that action at this time.
0 commit comments