Differences From Artifact [730550a384]:
- File
src/OFStdIOStream.m
— part of check-in
[3b43d51006]
at
2020-01-14 00:16:04
on branch trunk
— More consistent -[close] behavior
This means refusing to close twice, calling -[close] from -[dealloc] and
not calling -[cancelAsyncRequests].Calling -[cancelAsyncRequests] in -[close] is too dangerous, as -[close]
gets called by -[dealloc]: If the queue is the last reference to the
object, at the point where -[cancelAsyncRequests] removes it from the
queue, the object will start to deallocate and call into
-[cancelAsyncRequests] again, which is still in the middle of removing
it and now finds itself with an inconsistent state. (user: js, size: 7419) [annotate] [blame] [check-ins using] [more...]
To Artifact [26a72da19c]:
- File src/OFStdIOStream.m — part of check-in [d5eb0384c5] at 2020-05-28 00:15:05 on branch trunk — OFStdIOStream: Add -[hasTerminal] (user: js, size: 10423) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #endif #ifdef HAVE_SYS_TTYCOM_H # include <sys/ttycom.h> #endif #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFWin32ConsoleStdIOStream.h" #endif #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_AMIGAOS # include <proto/exec.h> | > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #endif #ifdef HAVE_SYS_TTYCOM_H # include <sys/ttycom.h> #endif #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFColor.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFWin32ConsoleStdIOStream.h" #endif #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> |
︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 | va_end(arguments); [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { if (self != [OFStdIOStream class]) return; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | va_end(arguments); [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) static int colorToANSI(OFColor *color) { if ([color isEqual: [OFColor black]]) return 30; if ([color isEqual: [OFColor maroon]]) return 31; if ([color isEqual: [OFColor green]]) return 32; if ([color isEqual: [OFColor olive]]) return 33; if ([color isEqual: [OFColor navy]]) return 34; if ([color isEqual: [OFColor purple]]) return 35; if ([color isEqual: [OFColor teal]]) return 36; if ([color isEqual: [OFColor silver]]) return 37; if ([color isEqual: [OFColor grey]]) return 90; if ([color isEqual: [OFColor red]]) return 91; if ([color isEqual: [OFColor lime]]) return 92; if ([color isEqual: [OFColor yellow]]) return 93; if ([color isEqual: [OFColor blue]]) return 94; if ([color isEqual: [OFColor fuchsia]]) return 95; if ([color isEqual: [OFColor aqua]]) return 96; if ([color isEqual: [OFColor white]]) return 97; return -1; } #endif @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { if (self != [OFStdIOStream class]) return; |
︙ | ︙ | |||
338 339 340 341 342 343 344 345 346 347 348 349 350 351 | { } - (unsigned int)retainCount { return OF_RETAIN_COUNT_MAX; } - (int)columns { #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) | > > > > > > > > > | 381 382 383 384 385 386 387 388 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 { #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; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) |
︙ | ︙ | |||
366 367 368 369 370 371 372 373 | return -1; return ws.ws_row; #else return -1; #endif } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 418 419 420 421 422 423 424 425 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 525 526 527 | return -1; return ws.ws_row; #else return -1; #endif } - (void)setForegroundColor: (OFColor *)color { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) int code; if (!isatty(_fd)) return; if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code]; #endif } - (void)setBackgroundColor: (OFColor *)color { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) int code; if (!isatty(_fd)) return; if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code + 10]; #endif } - (void)reset { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) if (!isatty(_fd)) return; [self writeString: @"\033[0m"]; #endif } - (void)clear { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) if (!isatty(_fd)) return; [self writeString: @"\033[2J"]; #endif } - (void)eraseLine { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) if (!isatty(_fd)) return; [self writeString: @"\033[2K"]; #endif } - (void)setCursorColumn: (unsigned int)column { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) 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]; #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) if (!isatty(_fd)) return; [self writeFormat: @"\033[%u;%uH", (unsigned)position.y + 1, (unsigned)position.x + 1]; #endif } - (void)setRelativeCursorPosition: (of_point_t)position { #if defined(HAVE_ISATTY) && !defined(OF_AMIGAOS) 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]; if (position.y > 0) [self writeFormat: @"\033[%uB", (unsigned)position.y]; else if (position.y < 0) [self writeFormat: @"\033[%uA", (unsigned)-position.y]; #endif } @end |