in src/agent/Scraper.cc [397:432]
WORD Scraper::attributesMask()
{
const auto WINPTY_ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4u;
const auto WINPTY_ENABLE_LVB_GRID_WORLDWIDE = 0x10u;
const auto WINPTY_COMMON_LVB_REVERSE_VIDEO = 0x4000u;
const auto WINPTY_COMMON_LVB_UNDERSCORE = 0x8000u;
const auto cp = GetConsoleOutputCP();
const auto isCjk = (cp == 932 || cp == 936 || cp == 949 || cp == 950);
const DWORD outputMode = [this]{
ASSERT(this->m_consoleBuffer != nullptr);
DWORD mode = 0;
if (!GetConsoleMode(this->m_consoleBuffer->conout(), &mode)) {
mode = 0;
}
return mode;
}();
const bool hasEnableLvbGridWorldwide =
(outputMode & WINPTY_ENABLE_LVB_GRID_WORLDWIDE) != 0;
const bool hasEnableVtProcessing =
(outputMode & WINPTY_ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
// The new Windows 10 console (as of 14393) seems to respect
// COMMON_LVB_REVERSE_VIDEO even in CP437 w/o the other enabling modes, so
// try to match that behavior.
const auto isReverseSupported =
isCjk || hasEnableLvbGridWorldwide || hasEnableVtProcessing || m_console.isNewW10();
const auto isUnderscoreSupported =
isCjk || hasEnableLvbGridWorldwide || hasEnableVtProcessing;
WORD mask = ~0;
if (!isReverseSupported) { mask &= ~WINPTY_COMMON_LVB_REVERSE_VIDEO; }
if (!isUnderscoreSupported) { mask &= ~WINPTY_COMMON_LVB_UNDERSCORE; }
return mask;
}