Differences From Artifact [01349f1730]:
- File
src/OFWin32ConsoleStdIOStream.m
— part of check-in
[627511b032]
at
2020-11-14 12:23:55
on branch trunk
— Rename of_malloc and of_calloc
The new names should be more accurate. (user: js, size: 14920) [annotate] [blame] [check-ins using] [more...]
To Artifact [0662c30238]:
- File src/OFWin32ConsoleStdIOStream.m — part of check-in [1b82d3bf4f] at 2021-03-07 20:25:21 on branch trunk — *.m: Fold methods into one line where it fits (user: js, size: 14786) [annotate] [blame] [check-ins using] [more...]
1 | /* | < < | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
122 123 124 125 126 127 128 | [self release]; @throw e; } return self; } | | < | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | [self release]; @throw e; } return self; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer_ length: (size_t)length { void *pool = objc_autoreleasePoolPush(); char *buffer = buffer_; of_char16_t *UTF16; size_t j = 0; if (length > UINT32_MAX) |
︙ | ︙ | |||
188 189 190 191 192 193 194 | if (UTF8Len <= length) { memcpy(buffer, UTF8, UTF8Len); j += UTF8Len; } else { if (rest == nil) rest = [OFMutableData data]; | | < | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | if (UTF8Len <= length) { memcpy(buffer, UTF8, UTF8Len); j += UTF8Len; } else { if (rest == nil) rest = [OFMutableData data]; [rest addItems: UTF8 count: UTF8Len]; } _incompleteUTF16Surrogate = 0; i++; } for (; i < UTF16Len; i++) { |
︙ | ︙ | |||
246 247 248 249 250 251 252 | if (j + UTF8Len <= length) { memcpy(buffer + j, UTF8, UTF8Len); j += UTF8Len; } else { if (rest == nil) rest = [OFMutableData data]; | | < | < | < | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | if (j + UTF8Len <= length) { memcpy(buffer + j, UTF8, UTF8Len); j += UTF8Len; } else { if (rest == nil) rest = [OFMutableData data]; [rest addItems: UTF8 count: UTF8Len]; } } if (rest != nil) [self unreadFromBuffer: rest.items length: rest.count]; } @finally { free(UTF16); } objc_autoreleasePoolPop(pool); return j; } - (size_t)lowlevelWriteBuffer: (const void *)buffer_ length: (size_t)length { const char *buffer = buffer_; of_char16_t *tmp; size_t i = 0, j = 0; if (length > SIZE_MAX / 2) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
489 490 491 492 493 494 495 | if (!GetConsoleScreenBufferInfo(_handle, &csbi)) return; csbi.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); | | < < < | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | if (!GetConsoleScreenBufferInfo(_handle, &csbi)) return; csbi.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); [color getRed: &red green: &green blue: &blue alpha: NULL]; if (red >= 0.25) csbi.wAttributes |= FOREGROUND_RED; if (green >= 0.25) csbi.wAttributes |= FOREGROUND_GREEN; if (blue >= 0.25) csbi.wAttributes |= FOREGROUND_BLUE; |
︙ | ︙ | |||
518 519 520 521 522 523 524 | if (!GetConsoleScreenBufferInfo(_handle, &csbi)) return; csbi.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY); | | < < < | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | if (!GetConsoleScreenBufferInfo(_handle, &csbi)) return; csbi.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY); [color getRed: &red green: &green blue: &blue alpha: NULL]; if (red >= 0.25) csbi.wAttributes |= BACKGROUND_RED; if (green >= 0.25) csbi.wAttributes |= BACKGROUND_GREEN; if (blue >= 0.25) csbi.wAttributes |= BACKGROUND_BLUE; |
︙ | ︙ |