Differences From Artifact [470dd5a9cf]:
- File src/OFStdIOStream.m — part of check-in [27b401c7c2] at 2021-01-02 22:06:34 on branch amiga-library — Update copyright (user: js, size: 10477) [annotate] [blame] [check-ins using]
To Artifact [2787693b17]:
- File
src/OFStdIOStream.m
— part of check-in
[3c88df0ce4]
at
2021-05-09 14:45:19
on branch amiga-library
— Merge trunk into branch "amiga-library"
All necessary changes to adjust for the changes made in trunk are
included in the merge commit. (user: js, size: 10419) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
58 59 60 61 62 63 64 | _reference_to_OFWin32ConsoleStdIOStream(void) { [OFWin32ConsoleStdIOStream class]; } #endif #ifdef OF_AMIGAOS | | | | | | | | | | | | | | | | | | | | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 | _reference_to_OFWin32ConsoleStdIOStream(void) { [OFWin32ConsoleStdIOStream class]; } #endif #ifdef OF_AMIGAOS # undef OFStdIn # undef OFStdOut # undef OFStdErr #endif OFStdIOStream *OFStdIn = nil; OFStdIOStream *OFStdOut = nil; OFStdIOStream *OFStdErr = nil; #ifdef OF_AMIGAOS OFStdIOStream ** OFStdInRef(void) { return &OFStdIn; } OFStdIOStream ** OFStdOutRef(void) { return &OFStdOut; } OFStdIOStream ** OFStdErrRef(void) { return &OFStdErr; } #endif #ifdef OF_AMIGAOS OF_DESTRUCTOR() { [OFStdIn dealloc]; [OFStdOut dealloc]; [OFStdErr dealloc]; } #endif void OFLog(OFConstantString *format, ...) { va_list arguments; va_start(arguments, format); OFLogV(format, arguments); va_end(arguments); } void OFLogV(OFConstantString *format, va_list arguments) { void *pool = objc_autoreleasePoolPush(); OFDate *date; OFString *dateString, *me, *msg; date = [OFDate date]; dateString = [date localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; #ifdef OF_HAVE_FILES me = [OFApplication programName].lastPathComponent; #else me = [OFApplication programName]; #endif msg = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; [OFStdErr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } #ifdef HAVE_ISATTY static int colorToANSI(OFColor *color) |
︙ | ︙ | |||
182 183 184 185 186 187 188 | if (self != [OFStdIOStream class]) return; # ifndef OF_AMIGAOS int fd; if ((fd = fileno(stdin)) >= 0) | < | | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | if (self != [OFStdIOStream class]) return; # ifndef OF_AMIGAOS int fd; if ((fd = fileno(stdin)) >= 0) OFStdIn = [[OFStdIOStream alloc] of_initWithFileDescriptor: fd]; if ((fd = fileno(stdout)) >= 0) OFStdOut = [[OFStdIOStream alloc] of_initWithFileDescriptor: fd]; if ((fd = fileno(stderr)) >= 0) OFStdErr = [[OFStdIOStream alloc] of_initWithFileDescriptor: fd]; # else BPTR input, output, error; bool inputClosable = false, outputClosable = false, errorClosable = false; input = Input(); |
︙ | ︙ | |||
214 215 216 217 218 219 220 | } if (error == 0) { error = Open("*", MODE_OLDFILE); errorClosable = true; } | | | | | | | | < | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | } if (error == 0) { error = Open("*", MODE_OLDFILE); errorClosable = true; } OFStdIn = [[OFStdIOStream alloc] of_initWithHandle: input closable: inputClosable]; OFStdOut = [[OFStdIOStream alloc] of_initWithHandle: output closable: outputClosable]; OFStdErr = [[OFStdIOStream alloc] of_initWithHandle: error closable: errorClosable]; # endif } #endif - (instancetype)init { OF_INVALID_INIT_METHOD } #ifndef OF_AMIGAOS - (instancetype)of_initWithFileDescriptor: (int)fd { self = [super init]; _fd = fd; return self; } #else - (instancetype)of_initWithHandle: (BPTR)handle closable: (bool)closable { self = [super init]; _handle = handle; _closable = closable; return self; |
︙ | ︙ | |||
275 276 277 278 279 280 281 | if (_handle == 0) #endif @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } | | < | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | if (_handle == 0) #endif @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; #ifndef OF_AMIGAOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; |
︙ | ︙ | |||
317 318 319 320 321 322 323 | if (ret == 0) _atEndOfStream = true; return ret; } | | < | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | if (ret == 0) _atEndOfStream = true; return ret; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { #ifndef OF_AMIGAOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS ssize_t bytesWritten; |
︙ | ︙ | |||
415 416 417 418 419 420 421 | - (void)release { } - (unsigned int)retainCount { | | | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | - (void)release { } - (unsigned int)retainCount { return OFMaxRetainCount; } - (bool)hasTerminal { #ifdef HAVE_ISATTY return isatty(_fd); #else |
︙ | ︙ | |||
525 526 527 528 529 530 531 | if (!isatty(_fd)) return; [self writeFormat: @"\033[%uG", column + 1]; #endif } | | | | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | if (!isatty(_fd)) return; [self writeFormat: @"\033[%uG", column + 1]; #endif } - (void)setCursorPosition: (OFPoint)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: (OFPoint)position { #ifdef HAVE_ISATTY if (!isatty(_fd)) return; if (position.x > 0) [self writeFormat: @"\033[%uC", (unsigned)position.x]; |
︙ | ︙ |