MCPcopy Create free account
hub / github.com/ConEmu/ConEmu / ExtGetAttributes

Function ExtGetAttributes

src/ConEmuHk/ExtConsole.cpp:244–290  ·  view source on GitHub ↗

Это это "цвет по умолчанию". То, что соответствует "Screen Text" и "Screen Background" в свойствах консоли. То, что задаётся командой color в cmd.exe. То, что будет использовано если в консоль просто писать по printf/std::cout/WriteConsole, без явного указания цвета.

Source from the content-addressed store, hash-verified

242// То, что будет использовано если в консоль просто писать
243// по printf/std::cout/WriteConsole, без явного указания цвета.
244BOOL 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
292static void ExtPrepareColor(const ConEmu::Color& Attributes, AnnotationInfo& t, WORD& n)
293{

Callers 4

ExtWriteTextFunction · 0.85
ExtFillOutputFunction · 0.85
ExtScrollLineFunction · 0.85
ExtScrollScreenFunction · 0.85

Calls 2

ExtCheckBuffersFunction · 0.85
ExtGetBufferInfoFunction · 0.85

Tested by

no test coverage detected