Overview
Comment: | OFStdIOStream: Don't use isatty() on iOS
When having Xcode attached to see the log, isatty() returns true, but |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a98ad80cd3b8433fbafb74dae2942525 |
User & Date: | js on 2020-06-24 22:30:40 |
Other Links: | manifest | tags |
Context
2020-06-24
| ||
22:34 | Correct the path for DerivedData in ignore-glob check-in: 7aba87d1eb user: js tags: trunk | |
22:30 | OFStdIOStream: Don't use isatty() on iOS check-in: a98ad80cd3 user: js tags: trunk | |
20:53 | Fix missing cast check-in: ca3e874157 user: js tags: trunk | |
Changes
Modified src/OFStdIOStream.m from [26a72da19c] to [10bbd8e570].
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_AMIGAOS # include <proto/exec.h> # include <proto/dos.h> #endif /* References for static linking */ #ifdef OF_WINDOWS void _reference_to_OFWin32ConsoleStdIOStream(void) { | > > > > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_IOS # undef HAVE_ISATTY #endif #ifdef OF_AMIGAOS # include <proto/exec.h> # include <proto/dos.h> # undef HAVE_ISATTY #endif /* References for static linking */ #ifdef OF_WINDOWS void _reference_to_OFWin32ConsoleStdIOStream(void) { |
︙ | ︙ | |||
94 95 96 97 98 99 100 | [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } #ifdef HAVE_ISATTY static int colorToANSI(OFColor *color) { if ([color isEqual: [OFColor black]]) return 30; if ([color isEqual: [OFColor maroon]]) return 31; |
︙ | ︙ | |||
384 385 386 387 388 389 390 | - (unsigned int)retainCount { return OF_RETAIN_COUNT_MAX; } - (bool)hasTerminal { | | | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | - (unsigned int)retainCount { return OF_RETAIN_COUNT_MAX; } - (bool)hasTerminal { #ifdef HAVE_ISATTY return isatty(_fd); #else return false; #endif } - (int)columns |
︙ | ︙ | |||
421 422 423 424 425 426 427 | #else return -1; #endif } - (void)setForegroundColor: (OFColor *)color { | | | | | | | | | | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | #else return -1; #endif } - (void)setForegroundColor: (OFColor *)color { #ifdef HAVE_ISATTY int code; if (!isatty(_fd)) return; if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code]; #endif } - (void)setBackgroundColor: (OFColor *)color { #ifdef HAVE_ISATTY int code; if (!isatty(_fd)) return; if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code + 10]; #endif } - (void)reset { #ifdef HAVE_ISATTY if (!isatty(_fd)) return; [self writeString: @"\033[0m"]; #endif } - (void)clear { #ifdef HAVE_ISATTY if (!isatty(_fd)) return; [self writeString: @"\033[2J"]; #endif } - (void)eraseLine { #ifdef HAVE_ISATTY if (!isatty(_fd)) return; [self writeString: @"\033[2K"]; #endif } - (void)setCursorColumn: (unsigned int)column { #ifdef HAVE_ISATTY if (!isatty(_fd)) return; [self writeFormat: @"\033[%uG", column + 1]; #endif } - (void)setCursorPosition: (of_point_t)position { if (position.x < 0 || position.y < 0) @throw [OFInvalidArgumentException exception]; #ifdef HAVE_ISATTY if (!isatty(_fd)) return; [self writeFormat: @"\033[%u;%uH", (unsigned)position.y + 1, (unsigned)position.x + 1]; #endif } - (void)setRelativeCursorPosition: (of_point_t)position { #ifdef HAVE_ISATTY if (!isatty(_fd)) return; if (position.x > 0) [self writeFormat: @"\033[%uC", (unsigned)position.x]; else if (position.x < 0) [self writeFormat: @"\033[%uD", (unsigned)-position.x]; |
︙ | ︙ |