Это это "цвет по умолчанию". То, что соответствует "Screen Text" и "Screen Background" в свойствах консоли. То, что задаётся командой color в cmd.exe. То, что будет использовано если в консоль просто писать по printf/std::cout/WriteConsole, без явного указания цвета.
| 242 | // То, что будет использовано если в консоль просто писать |
| 243 | // по printf/std::cout/WriteConsole, без явного указания цвета. |
| 244 | BOOL ExtGetAttributes(ExtAttributesParm* Info) |
| 245 | { |
| 246 | if (!Info) |
| 247 | { |
| 248 | _ASSERTE(Info!=NULL); |
| 249 | SetLastError(E_INVALIDARG); |
| 250 | return FALSE; |
| 251 | } |
| 252 | |
| 253 | BOOL lbTrueColor = ExtCheckBuffers(Info->ConsoleOutput); |
| 254 | UNREFERENCED_PARAMETER(lbTrueColor); |
| 255 | |
| 256 | HANDLE h = Info->ConsoleOutput; |
| 257 | CONSOLE_SCREEN_BUFFER_INFO csbi = {}; |
| 258 | SMALL_RECT srWork = {}; |
| 259 | if (!ExtGetBufferInfo(h, csbi, srWork)) |
| 260 | { |
| 261 | _ASSERTE(FALSE && "ExtGetBufferInfo failed in ExtGetAttributes"); |
| 262 | gExtCurrentAttr.WasSet = false; |
| 263 | gExtCurrentAttr.CEColor.Flags = ConEmu::ColorFlags::None; |
| 264 | gExtCurrentAttr.CEColor.ForegroundColor = defConForeIdx; |
| 265 | gExtCurrentAttr.CEColor.BackgroundColor = defConBackIdx; |
| 266 | memset(&gExtCurrentAttr.AIColor, 0, sizeof(gExtCurrentAttr.AIColor)); |
| 267 | return FALSE; |
| 268 | } |
| 269 | |
| 270 | // Что-то в некоторых случаях сбивается цвет вывода для printf |
| 271 | //_ASSERTE("GetTextAttributes" && ((csbi.wAttributes & 0xFF) == 0x07)); |
| 272 | |
| 273 | TODO("По хорошему, gExtCurrentAttr нада ветвить по разным h"); |
| 274 | if (gExtCurrentAttr.WasSet && (csbi.wAttributes == gExtCurrentAttr.CONColor)) |
| 275 | { |
| 276 | Info->Attributes = gExtCurrentAttr.CEColor; |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | gExtCurrentAttr.WasSet = false; |
| 281 | memset(&gExtCurrentAttr.CEColor, 0, sizeof(gExtCurrentAttr.CEColor)); |
| 282 | memset(&gExtCurrentAttr.AIColor, 0, sizeof(gExtCurrentAttr.AIColor)); |
| 283 | |
| 284 | Info->Attributes.Flags = ConEmu::ColorFlags::None; |
| 285 | Info->Attributes.ForegroundColor = CONFORECOLOR(csbi.wAttributes); |
| 286 | Info->Attributes.BackgroundColor = CONBACKCOLOR(csbi.wAttributes); |
| 287 | } |
| 288 | |
| 289 | return TRUE; |
| 290 | } |
| 291 | |
| 292 | static void ExtPrepareColor(const ConEmu::Color& Attributes, AnnotationInfo& t, WORD& n) |
| 293 | { |
no test coverage detected