Simplify registry queries for special colors.

This commit is contained in:
James Holderness 2021-11-14 20:48:58 +00:00
parent 7004ba73db
commit a1e98f56bc
2 changed files with 5 additions and 38 deletions

View file

@ -314,42 +314,6 @@ void Registry::LoadFromRegistry(_In_ PCWSTR const pwszConsoleTitle)
}
}
// Default foreground color
Status = RegistrySerialization::s_QueryValue(hTitleKey,
CONSOLE_REGISTRY_DEFAULTFOREGROUND,
sizeof(dwValue),
REG_DWORD,
(PBYTE)&dwValue,
nullptr);
if (NT_SUCCESS(Status))
{
_pSettings->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, dwValue);
}
// Default background color
Status = RegistrySerialization::s_QueryValue(hTitleKey,
CONSOLE_REGISTRY_DEFAULTBACKGROUND,
sizeof(dwValue),
REG_DWORD,
(PBYTE)&dwValue,
nullptr);
if (NT_SUCCESS(Status))
{
_pSettings->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, dwValue);
}
// Cursor color
Status = RegistrySerialization::s_QueryValue(hTitleKey,
CONSOLE_REGISTRY_CURSORCOLOR,
sizeof(dwValue),
REG_DWORD,
(PBYTE)&dwValue,
nullptr);
if (NT_SUCCESS(Status))
{
_pSettings->SetColorTableEntry(TextColor::CURSOR_COLOR, dwValue);
}
GetEditKeys(hConsoleKey);
// Close the registry keys

View file

@ -7,7 +7,7 @@
#pragma hdrstop
#define SET_FIELD_AND_SIZE(x) FIELD_OFFSET(Settings, x), RTL_FIELD_SIZE(Settings, x)
#define SET_FIELD_AND_SIZE(x) UFIELD_OFFSET(Settings, x), RTL_FIELD_SIZE(Settings, x)
#define NT_TESTNULL(var) (((var) == nullptr) ? STATUS_NO_MEMORY : STATUS_SUCCESS)
@ -61,7 +61,10 @@ const RegistrySerialization::_RegPropertyMap RegistrySerialization::s_PropertyMa
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_INTERCEPTCOPYPASTE, SET_FIELD_AND_SIZE(_fInterceptCopyPaste) },
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_TERMINALSCROLLING, SET_FIELD_AND_SIZE(_TerminalScrolling) },
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_USEDX, SET_FIELD_AND_SIZE(_fUseDx) },
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_COPYCOLOR, SET_FIELD_AND_SIZE(_fCopyColor) }
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_COPYCOLOR, SET_FIELD_AND_SIZE(_fCopyColor) },
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTFOREGROUND, SET_FIELD_AND_SIZE(_colorTable[TextColor::DEFAULT_FOREGROUND]) },
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTBACKGROUND, SET_FIELD_AND_SIZE(_colorTable[TextColor::DEFAULT_BACKGROUND]) },
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_CURSORCOLOR, SET_FIELD_AND_SIZE(_colorTable[TextColor::CURSOR_COLOR]) }
};
const size_t RegistrySerialization::s_PropertyMappingsSize = ARRAYSIZE(s_PropertyMappings);