Merge default colors into color table.
This commit is contained in:
parent
a68b0d4f08
commit
79859cff84
|
@ -135,7 +135,7 @@ bool TextAttribute::IsLegacy() const noexcept
|
|||
// - boldIsBright: true if "bold" should be interpreted as bright. (defaults to true)
|
||||
// Return Value:
|
||||
// - the foreground and background colors that should be displayed.
|
||||
std::pair<COLORREF, COLORREF> TextAttribute::CalculateRgbColors(const std::array<COLORREF, 256>& colorTable,
|
||||
std::pair<COLORREF, COLORREF> TextAttribute::CalculateRgbColors(const std::array<COLORREF, TextColor::TABLE_SIZE>& colorTable,
|
||||
const COLORREF defaultFgColor,
|
||||
const COLORREF defaultBgColor,
|
||||
const bool reverseScreenMode,
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
static TextAttribute StripErroneousVT16VersionsOfLegacyDefaults(const TextAttribute& attribute) noexcept;
|
||||
WORD GetLegacyAttributes() const noexcept;
|
||||
|
||||
std::pair<COLORREF, COLORREF> CalculateRgbColors(const std::array<COLORREF, 256>& colorTable,
|
||||
std::pair<COLORREF, COLORREF> CalculateRgbColors(const std::array<COLORREF, TextColor::TABLE_SIZE>& colorTable,
|
||||
const COLORREF defaultFgColor,
|
||||
const COLORREF defaultBgColor,
|
||||
const bool reverseScreenMode = false,
|
||||
|
|
|
@ -143,7 +143,7 @@ void TextColor::SetDefault() noexcept
|
|||
// - brighten: if true, we'll brighten a dark color table index.
|
||||
// Return Value:
|
||||
// - a COLORREF containing the real value of this TextColor.
|
||||
COLORREF TextColor::GetColor(const std::array<COLORREF, 256>& colorTable, const COLORREF defaultColor, bool brighten) const noexcept
|
||||
COLORREF TextColor::GetColor(const std::array<COLORREF, TextColor::TABLE_SIZE>& colorTable, const COLORREF defaultColor, bool brighten) const noexcept
|
||||
{
|
||||
if (IsDefault())
|
||||
{
|
||||
|
|
|
@ -65,6 +65,10 @@ public:
|
|||
static constexpr BYTE BRIGHT_CYAN = 14;
|
||||
static constexpr BYTE BRIGHT_WHITE = 15;
|
||||
|
||||
static constexpr size_t DEFAULT_FOREGROUND = 256;
|
||||
static constexpr size_t DEFAULT_BACKGROUND = 257;
|
||||
static constexpr size_t TABLE_SIZE = 258;
|
||||
|
||||
constexpr TextColor() noexcept :
|
||||
_meta{ ColorType::IsDefault },
|
||||
_red{ 0 },
|
||||
|
@ -103,7 +107,7 @@ public:
|
|||
void SetIndex(const BYTE index, const bool isIndex256) noexcept;
|
||||
void SetDefault() noexcept;
|
||||
|
||||
COLORREF GetColor(const std::array<COLORREF, 256>& colorTable, const COLORREF defaultColor, bool brighten = false) const noexcept;
|
||||
COLORREF GetColor(const std::array<COLORREF, TABLE_SIZE>& colorTable, const COLORREF defaultColor, bool brighten = false) const noexcept;
|
||||
BYTE GetLegacyIndex(const BYTE defaultIndex) const noexcept;
|
||||
|
||||
constexpr BYTE GetIndex() const noexcept
|
||||
|
|
|
@ -24,7 +24,7 @@ class TextAttributeTests
|
|||
TEST_METHOD(TestRoundtripDefaultColors);
|
||||
TEST_METHOD(TestBoldAsBright);
|
||||
|
||||
std::array<COLORREF, 256> _colorTable;
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
COLORREF _defaultFg = RGB(1, 2, 3);
|
||||
COLORREF _defaultBg = RGB(4, 5, 6);
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ class TextColorTests
|
|||
TEST_METHOD(TestRgbColor);
|
||||
TEST_METHOD(TestChangeColor);
|
||||
|
||||
std::array<COLORREF, 256> _colorTable;
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
COLORREF _defaultFg = RGB(1, 2, 3);
|
||||
COLORREF _defaultBg = RGB(4, 5, 6);
|
||||
};
|
||||
|
|
|
@ -41,8 +41,6 @@ Terminal::Terminal() :
|
|||
_mutableViewport{ Viewport::Empty() },
|
||||
_title{},
|
||||
_colorTable{},
|
||||
_defaultFg{ RGB(255, 255, 255) },
|
||||
_defaultBg{ ARGB(0, 0, 0, 0) },
|
||||
_screenReversed{ false },
|
||||
_pfnWriteInput{ nullptr },
|
||||
_scrollOffset{ 0 },
|
||||
|
@ -81,6 +79,9 @@ Terminal::Terminal() :
|
|||
_terminalInput = std::make_unique<TerminalInput>(passAlongInput);
|
||||
|
||||
_InitializeColorTable();
|
||||
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = RGB(255, 255, 255);
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = ARGB(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void Terminal::Create(COORD viewportSize, SHORT scrollbackLines, IRenderTarget& renderTarget)
|
||||
|
@ -180,9 +181,11 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
|||
{
|
||||
// Set the default background as transparent to prevent the
|
||||
// DX layer from overwriting the background image or acrylic effect
|
||||
til::color newBackgroundColor{ appearance.DefaultBackground() };
|
||||
_defaultBg = newBackgroundColor.with_alpha(0);
|
||||
_defaultFg = appearance.DefaultForeground();
|
||||
const til::color newBackgroundColor{ appearance.DefaultBackground() };
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = newBackgroundColor.with_alpha(0);
|
||||
const til::color newForegroundColor{ appearance.DefaultForeground() };
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = newForegroundColor;
|
||||
|
||||
_intenseIsBright = appearance.IntenseIsBright();
|
||||
_adjustIndistinguishableColors = appearance.AdjustIndistinguishableColors();
|
||||
|
||||
|
|
|
@ -281,9 +281,7 @@ private:
|
|||
std::optional<til::color> _startingTabColor;
|
||||
|
||||
// This is still stored as a COLORREF because it interacts with some code in ConTypes
|
||||
std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
|
||||
til::color _defaultFg;
|
||||
til::color _defaultBg;
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
CursorType _defaultCursorShape;
|
||||
bool _screenReversed;
|
||||
mutable Microsoft::Console::Render::BlinkingState _blinkingState;
|
||||
|
|
|
@ -451,7 +451,7 @@ bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) noex
|
|||
bool Terminal::SetDefaultForeground(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_defaultFg = color;
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = color;
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
|
@ -468,7 +468,7 @@ CATCH_RETURN_FALSE()
|
|||
bool Terminal::SetDefaultBackground(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_defaultBg = color;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = color;
|
||||
_pfnBackgroundColorChanged(color);
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
|
@ -479,7 +479,7 @@ CATCH_RETURN_FALSE()
|
|||
|
||||
til::color Terminal::GetDefaultBackground() const noexcept
|
||||
{
|
||||
return _defaultBg;
|
||||
return _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
bool Terminal::SetInputMode(const TerminalInput::Mode mode, const bool enabled) noexcept
|
||||
|
|
|
@ -73,19 +73,19 @@ std::pair<COLORREF, COLORREF> Terminal::GetAttributeColors(const TextAttribute&
|
|||
if (attr.IsReverseVideo() ^ _screenReversed)
|
||||
{
|
||||
colors.first = _adjustedForegroundColors[fgIndex][bgIndex];
|
||||
colors.second = fgTextColor.GetColor(_colorTable, _defaultFg);
|
||||
colors.second = fgTextColor.GetColor(_colorTable, _colorTable.at(TextColor::DEFAULT_FOREGROUND));
|
||||
}
|
||||
else
|
||||
{
|
||||
colors.first = _adjustedForegroundColors[bgIndex][fgIndex];
|
||||
colors.second = bgTextColor.GetColor(_colorTable, _defaultBg);
|
||||
colors.second = bgTextColor.GetColor(_colorTable, _colorTable.at(TextColor::DEFAULT_BACKGROUND));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = attr.CalculateRgbColors(_colorTable,
|
||||
_defaultFg,
|
||||
_defaultBg,
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND),
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND),
|
||||
_screenReversed,
|
||||
_blinkingState.IsBlinkingFaint(),
|
||||
_intenseIsBright);
|
||||
|
@ -312,8 +312,8 @@ void Terminal::_MakeAdjustedColorArray()
|
|||
// to include the default background and default foreground colors
|
||||
std::array<COLORREF, 18> colorTableWithDefaults;
|
||||
std::copy_n(std::begin(_colorTable), 16, std::begin(colorTableWithDefaults));
|
||||
colorTableWithDefaults[DefaultBgIndex] = _defaultBg;
|
||||
colorTableWithDefaults[DefaultFgIndex] = _defaultFg;
|
||||
colorTableWithDefaults[DefaultBgIndex] = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
colorTableWithDefaults[DefaultFgIndex] = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
for (auto fgIndex = 0; fgIndex < 18; ++fgIndex)
|
||||
{
|
||||
const auto fg = til::at(colorTableWithDefaults, fgIndex);
|
||||
|
|
|
@ -96,8 +96,8 @@ class TerminalCoreUnitTests::ConptyRoundtripTests final
|
|||
auto& g = ServiceLocator::LocateGlobals();
|
||||
auto& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, INVALID_COLOR);
|
||||
gci.SetFillAttribute(0x07); // DARK_WHITE on DARK_BLACK
|
||||
|
||||
m_state->PrepareNewTextBufferInfo(true, TerminalViewWidth, TerminalViewHeight);
|
||||
|
|
|
@ -59,7 +59,6 @@ void TerminalApiTest::SetColorTableEntry()
|
|||
VERIFY_IS_TRUE(term.SetColorTableEntry(128, 100));
|
||||
VERIFY_IS_TRUE(term.SetColorTableEntry(255, 100));
|
||||
|
||||
VERIFY_IS_FALSE(term.SetColorTableEntry(256, 100));
|
||||
VERIFY_IS_FALSE(term.SetColorTableEntry(512, 100));
|
||||
}
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ InputBuffer* const CONSOLE_INFORMATION::GetActiveInputBuffer() const
|
|||
// - the default foreground color of the console.
|
||||
COLORREF CONSOLE_INFORMATION::GetDefaultForeground() const noexcept
|
||||
{
|
||||
const auto fg = GetDefaultForegroundColor();
|
||||
const auto fg = GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
return fg != INVALID_COLOR ? fg : GetLegacyColorTableEntry(LOBYTE(GetFillAttribute()) & FG_ATTRS);
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ COLORREF CONSOLE_INFORMATION::GetDefaultForeground() const noexcept
|
|||
// - the default background color of the console.
|
||||
COLORREF CONSOLE_INFORMATION::GetDefaultBackground() const noexcept
|
||||
{
|
||||
const auto bg = GetDefaultBackgroundColor();
|
||||
const auto bg = GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
return bg != INVALID_COLOR ? bg : GetLegacyColorTableEntry((LOBYTE(GetFillAttribute()) & BG_ATTRS) >> 4);
|
||||
}
|
||||
|
||||
|
|
|
@ -2031,7 +2031,7 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo)
|
|||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetDefaultForegroundColor(value);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, value);
|
||||
|
||||
// Update the screen colors if we're not a pty
|
||||
// No need to force a redraw in pty mode.
|
||||
|
@ -2058,7 +2058,7 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo)
|
|||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetDefaultBackgroundColor(value);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, value);
|
||||
|
||||
// Update the screen colors if we're not a pty
|
||||
// No need to force a redraw in pty mode.
|
||||
|
|
|
@ -314,6 +314,30 @@ 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);
|
||||
}
|
||||
|
||||
GetEditKeys(hConsoleKey);
|
||||
|
||||
// Close the registry keys
|
||||
|
|
|
@ -56,8 +56,6 @@ Settings::Settings() :
|
|||
_fScreenReversed(false),
|
||||
// window size pixels initialized below
|
||||
_fInterceptCopyPaste(0),
|
||||
_DefaultForeground(INVALID_COLOR),
|
||||
_DefaultBackground(INVALID_COLOR),
|
||||
_fUseDx(UseDx::Disabled),
|
||||
_fCopyColor(false)
|
||||
{
|
||||
|
@ -83,6 +81,9 @@ Settings::Settings() :
|
|||
|
||||
gsl::span<COLORREF> tableView = { _colorTable.data(), _colorTable.size() };
|
||||
::Microsoft::Console::Utils::InitializeColorTable(tableView);
|
||||
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = INVALID_COLOR;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -232,8 +233,8 @@ void Settings::InitFromStateInfo(_In_ PCONSOLE_STATE_INFO pStateInfo)
|
|||
_CursorColor = pStateInfo->CursorColor;
|
||||
_CursorType = static_cast<CursorType>(pStateInfo->CursorType);
|
||||
_fInterceptCopyPaste = pStateInfo->InterceptCopyPaste;
|
||||
_DefaultForeground = pStateInfo->DefaultForeground;
|
||||
_DefaultBackground = pStateInfo->DefaultBackground;
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = pStateInfo->DefaultForeground;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = pStateInfo->DefaultBackground;
|
||||
_TerminalScrolling = pStateInfo->TerminalScrolling;
|
||||
}
|
||||
|
||||
|
@ -277,8 +278,8 @@ CONSOLE_STATE_INFO Settings::CreateConsoleStateInfo() const
|
|||
csi.CursorColor = _CursorColor;
|
||||
csi.CursorType = static_cast<unsigned int>(_CursorType);
|
||||
csi.InterceptCopyPaste = _fInterceptCopyPaste;
|
||||
csi.DefaultForeground = _DefaultForeground;
|
||||
csi.DefaultBackground = _DefaultBackground;
|
||||
csi.DefaultForeground = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
csi.DefaultBackground = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
csi.TerminalScrolling = _TerminalScrolling;
|
||||
return csi;
|
||||
}
|
||||
|
@ -330,16 +331,20 @@ void Settings::Validate()
|
|||
WI_ClearAllFlags(_wFillAttribute, ~(FG_ATTRS | BG_ATTRS));
|
||||
WI_ClearAllFlags(_wPopupFillAttribute, ~(FG_ATTRS | BG_ATTRS));
|
||||
|
||||
const auto defaultForeground = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
const auto defaultBackground = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
|
||||
// If the extended color options are set to invalid values (all the same color), reset them.
|
||||
if (_CursorColor != Cursor::s_InvertCursorColor && _CursorColor == _DefaultBackground)
|
||||
if (_CursorColor != Cursor::s_InvertCursorColor && _CursorColor == defaultBackground)
|
||||
{
|
||||
_CursorColor = Cursor::s_InvertCursorColor;
|
||||
}
|
||||
|
||||
if (_DefaultForeground != INVALID_COLOR && _DefaultForeground == _DefaultBackground)
|
||||
if (defaultForeground != INVALID_COLOR && defaultForeground == defaultBackground)
|
||||
{
|
||||
// INVALID_COLOR is used as an "unset" sentinel in future attribute functions.
|
||||
_DefaultForeground = _DefaultBackground = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = INVALID_COLOR;
|
||||
// If the damaged settings _further_ propagated to the default fill attribute, fix it.
|
||||
if (_wFillAttribute == 0)
|
||||
{
|
||||
|
@ -790,26 +795,6 @@ void Settings::SetInterceptCopyPaste(const bool interceptCopyPaste) noexcept
|
|||
_fInterceptCopyPaste = interceptCopyPaste;
|
||||
}
|
||||
|
||||
COLORREF Settings::GetDefaultForegroundColor() const noexcept
|
||||
{
|
||||
return _DefaultForeground;
|
||||
}
|
||||
|
||||
void Settings::SetDefaultForegroundColor(const COLORREF defaultForeground) noexcept
|
||||
{
|
||||
_DefaultForeground = defaultForeground;
|
||||
}
|
||||
|
||||
COLORREF Settings::GetDefaultBackgroundColor() const noexcept
|
||||
{
|
||||
return _DefaultBackground;
|
||||
}
|
||||
|
||||
void Settings::SetDefaultBackgroundColor(const COLORREF defaultBackground) noexcept
|
||||
{
|
||||
_DefaultBackground = defaultBackground;
|
||||
}
|
||||
|
||||
bool Settings::IsTerminalScrolling() const noexcept
|
||||
{
|
||||
return _TerminalScrolling;
|
||||
|
|
|
@ -167,7 +167,7 @@ public:
|
|||
void SetHistoryNoDup(const bool fHistoryNoDup);
|
||||
|
||||
// The first 16 items of the color table are the same as the 16-color palette.
|
||||
inline const std::array<COLORREF, XTERM_COLOR_TABLE_SIZE>& GetColorTable() const noexcept
|
||||
inline const std::array<COLORREF, TextColor::TABLE_SIZE>& GetColorTable() const noexcept
|
||||
{
|
||||
return _colorTable;
|
||||
}
|
||||
|
@ -186,12 +186,6 @@ public:
|
|||
bool GetInterceptCopyPaste() const noexcept;
|
||||
void SetInterceptCopyPaste(const bool interceptCopyPaste) noexcept;
|
||||
|
||||
COLORREF GetDefaultForegroundColor() const noexcept;
|
||||
void SetDefaultForegroundColor(const COLORREF defaultForeground) noexcept;
|
||||
|
||||
COLORREF GetDefaultBackgroundColor() const noexcept;
|
||||
void SetDefaultBackgroundColor(const COLORREF defaultBackground) noexcept;
|
||||
|
||||
bool IsTerminalScrolling() const noexcept;
|
||||
void SetTerminalScrolling(const bool terminalScrollingEnabled) noexcept;
|
||||
|
||||
|
@ -242,7 +236,7 @@ private:
|
|||
UseDx _fUseDx;
|
||||
bool _fCopyColor;
|
||||
|
||||
std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
|
||||
// this is used for the special STARTF_USESIZE mode.
|
||||
bool _fUseWindowSizePixels;
|
||||
|
@ -254,8 +248,6 @@ private:
|
|||
|
||||
bool _fInterceptCopyPaste;
|
||||
|
||||
COLORREF _DefaultForeground;
|
||||
COLORREF _DefaultBackground;
|
||||
bool _TerminalScrolling;
|
||||
friend class RegistrySerialization;
|
||||
};
|
||||
|
|
|
@ -67,8 +67,8 @@ class ConptyOutputTests
|
|||
// Set up some sane defaults
|
||||
auto& g = ServiceLocator::LocateGlobals();
|
||||
auto& gci = g.getConsoleInformation();
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, INVALID_COLOR);
|
||||
gci.SetFillAttribute(0x07); // DARK_WHITE on DARK_BLACK
|
||||
|
||||
m_state->PrepareNewTextBufferInfo(true, TerminalViewWidth, TerminalViewHeight);
|
||||
|
|
|
@ -59,8 +59,8 @@ class ScreenBufferTests
|
|||
{
|
||||
// Set up some sane defaults
|
||||
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, INVALID_COLOR);
|
||||
gci.SetFillAttribute(0x07); // DARK_WHITE on DARK_BLACK
|
||||
|
||||
m_state->PrepareNewTextBufferInfo();
|
||||
|
@ -1388,8 +1388,8 @@ void ScreenBufferTests::VtScrollMarginsNewlineColor()
|
|||
|
||||
const COLORREF yellow = RGB(255, 255, 0);
|
||||
const COLORREF magenta = RGB(255, 0, 255);
|
||||
gci.SetDefaultForegroundColor(yellow);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, yellow);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
const TextAttribute defaultAttrs = {};
|
||||
si.SetAttributes(defaultAttrs);
|
||||
|
||||
|
@ -2259,8 +2259,8 @@ void ScreenBufferTests::SetDefaultsIndividuallyBothDefault()
|
|||
COLORREF brightGreen = gci.GetColorTableEntry(TextColor::BRIGHT_GREEN);
|
||||
COLORREF darkBlue = gci.GetColorTableEntry(TextColor::DARK_BLUE);
|
||||
|
||||
gci.SetDefaultForegroundColor(yellow);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, yellow);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 6 X's:"));
|
||||
|
@ -2361,8 +2361,8 @@ void ScreenBufferTests::SetDefaultsTogether()
|
|||
COLORREF yellow = RGB(255, 255, 0);
|
||||
COLORREF color250 = gci.GetColorTableEntry(250);
|
||||
|
||||
gci.SetDefaultForegroundColor(yellow);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, yellow);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 6 X's:"));
|
||||
|
@ -2432,8 +2432,8 @@ void ScreenBufferTests::ReverseResetWithDefaultBackground()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 3 X's:"));
|
||||
|
@ -2501,7 +2501,7 @@ void ScreenBufferTests::BackspaceDefaultAttrs()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 2 X's, then backspace one."));
|
||||
|
@ -2564,7 +2564,7 @@ void ScreenBufferTests::BackspaceDefaultAttrsWriteCharsLegacy()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 2 X's, then backspace one."));
|
||||
|
@ -2632,7 +2632,7 @@ void ScreenBufferTests::BackspaceDefaultAttrsInPrompt()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
TextAttribute expectedDefaults{};
|
||||
|
||||
|
@ -2889,15 +2889,15 @@ void ScreenBufferTests::SetDefaultForegroundColor()
|
|||
|
||||
StateMachine& stateMachine = mainBuffer.GetStateMachine();
|
||||
|
||||
COLORREF originalColor = gci.GetDefaultForegroundColor();
|
||||
COLORREF newColor = gci.GetDefaultForegroundColor();
|
||||
COLORREF originalColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
COLORREF newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
COLORREF testColor = RGB(0x33, 0x66, 0x99);
|
||||
VERIFY_ARE_NOT_EQUAL(originalColor, testColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
stateMachine.ProcessString(L"\x1b]10;rgb:33/66/99\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultForegroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
|
@ -2905,7 +2905,7 @@ void ScreenBufferTests::SetDefaultForegroundColor()
|
|||
testColor = RGB(0xff, 0xff, 0xff);
|
||||
stateMachine.ProcessString(L"\x1b]10;rgb:ff/ff/ff\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultForegroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Invalid syntax");
|
||||
|
@ -2913,7 +2913,7 @@ void ScreenBufferTests::SetDefaultForegroundColor()
|
|||
testColor = RGB(153, 102, 51);
|
||||
stateMachine.ProcessString(L"\x1b]10;99/66/33\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultForegroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
VERIFY_ARE_NOT_EQUAL(testColor, newColor);
|
||||
// it will, in fact leave the color the way it was
|
||||
VERIFY_ARE_EQUAL(originalColor, newColor);
|
||||
|
@ -2934,15 +2934,15 @@ void ScreenBufferTests::SetDefaultBackgroundColor()
|
|||
|
||||
StateMachine& stateMachine = mainBuffer.GetStateMachine();
|
||||
|
||||
COLORREF originalColor = gci.GetDefaultBackgroundColor();
|
||||
COLORREF newColor = gci.GetDefaultBackgroundColor();
|
||||
COLORREF originalColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
COLORREF newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
COLORREF testColor = RGB(0x33, 0x66, 0x99);
|
||||
VERIFY_ARE_NOT_EQUAL(originalColor, testColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
stateMachine.ProcessString(L"\x1b]11;rgb:33/66/99\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultBackgroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
|
@ -2950,7 +2950,7 @@ void ScreenBufferTests::SetDefaultBackgroundColor()
|
|||
testColor = RGB(0xff, 0xff, 0xff);
|
||||
stateMachine.ProcessString(L"\x1b]11;rgb:ff/ff/ff\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultBackgroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Invalid Syntax");
|
||||
|
@ -2958,7 +2958,7 @@ void ScreenBufferTests::SetDefaultBackgroundColor()
|
|||
testColor = RGB(153, 102, 51);
|
||||
stateMachine.ProcessString(L"\x1b]11;99/66/33\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultBackgroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
VERIFY_ARE_NOT_EQUAL(testColor, newColor);
|
||||
// it will, in fact leave the color the way it was
|
||||
VERIFY_ARE_EQUAL(originalColor, newColor);
|
||||
|
|
|
@ -37,4 +37,3 @@ enum class CursorType : unsigned int
|
|||
constexpr COLORREF INVALID_COLOR = 0xffffffff;
|
||||
|
||||
constexpr WORD COLOR_TABLE_SIZE = 16;
|
||||
constexpr WORD XTERM_COLOR_TABLE_SIZE = 256;
|
||||
|
|
|
@ -376,8 +376,8 @@ void Menu::s_ShowPropertiesDialog(HWND const hwnd, BOOL const Defaults)
|
|||
pStateInfo->InterceptCopyPaste = gci.GetInterceptCopyPaste();
|
||||
|
||||
// Get the properties from the settings
|
||||
pStateInfo->DefaultForeground = gci.GetDefaultForegroundColor();
|
||||
pStateInfo->DefaultBackground = gci.GetDefaultBackgroundColor();
|
||||
pStateInfo->DefaultForeground = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
pStateInfo->DefaultBackground = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
|
||||
pStateInfo->TerminalScrolling = gci.IsTerminalScrolling();
|
||||
// end console v2 properties
|
||||
|
@ -579,8 +579,8 @@ void Menu::s_PropertiesUpdate(PCONSOLE_STATE_INFO pStateInfo)
|
|||
gci.SetFillAttribute(pStateInfo->ScreenAttributes);
|
||||
gci.SetPopupFillAttribute(pStateInfo->PopupAttributes);
|
||||
// Store our updated Default Color values
|
||||
gci.SetDefaultForegroundColor(pStateInfo->DefaultForeground);
|
||||
gci.SetDefaultBackgroundColor(pStateInfo->DefaultBackground);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, pStateInfo->DefaultForeground);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, pStateInfo->DefaultBackground);
|
||||
|
||||
// Make sure the updated fill attributes are passed on to the TextAttribute class.
|
||||
TextAttribute::SetLegacyDefaultAttributes(pStateInfo->ScreenAttributes);
|
||||
|
|
|
@ -60,8 +60,6 @@ const RegistrySerialization::_RegPropertyMap RegistrySerialization::s_PropertyMa
|
|||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_CURSORCOLOR, SET_FIELD_AND_SIZE(_CursorColor) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_CURSORTYPE, SET_FIELD_AND_SIZE(_CursorType) },
|
||||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_INTERCEPTCOPYPASTE, SET_FIELD_AND_SIZE(_fInterceptCopyPaste) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTFOREGROUND, SET_FIELD_AND_SIZE(_DefaultForeground) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTBACKGROUND, SET_FIELD_AND_SIZE(_DefaultBackground) },
|
||||
{ _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) }
|
||||
|
|
Loading…
Reference in a new issue