Eliminate default color APIs in ConGetSet and ITerminalApi.
This commit is contained in:
parent
79859cff84
commit
05e20f6ebc
|
@ -239,8 +239,8 @@ HRESULT HwndTerminal::Initialize()
|
|||
_terminal->SetBackgroundCallback([](auto) {});
|
||||
|
||||
_terminal->Create(COORD{ 80, 25 }, 1000, *_renderer);
|
||||
_terminal->SetDefaultBackground(RGB(12, 12, 12));
|
||||
_terminal->SetDefaultForeground(RGB(204, 204, 204));
|
||||
_terminal->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, RGB(12, 12, 12));
|
||||
_terminal->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, RGB(204, 204, 204));
|
||||
_terminal->SetWriteInputCallback([=](std::wstring& input) noexcept { _WriteTextToConnection(input); });
|
||||
localPointerToThread->EnablePainting();
|
||||
|
||||
|
@ -781,8 +781,8 @@ void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR font
|
|||
{
|
||||
auto lock = publicTerminal->_terminal->LockForWriting();
|
||||
|
||||
publicTerminal->_terminal->SetDefaultForeground(theme.DefaultForeground);
|
||||
publicTerminal->_terminal->SetDefaultBackground(theme.DefaultBackground);
|
||||
publicTerminal->_terminal->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, theme.DefaultForeground);
|
||||
publicTerminal->_terminal->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, theme.DefaultBackground);
|
||||
publicTerminal->_renderEngine->SetSelectionBackground(theme.DefaultSelectionBackground, theme.SelectionBackgroundAlpha);
|
||||
|
||||
// Set the font colors
|
||||
|
|
|
@ -1089,7 +1089,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
til::color ControlCore::BackgroundColor() const
|
||||
{
|
||||
return _terminal->GetDefaultBackground();
|
||||
return _terminal->GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -45,9 +45,6 @@ namespace Microsoft::Terminal::Core
|
|||
virtual bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) noexcept = 0;
|
||||
virtual bool SetCursorColor(const DWORD color) noexcept = 0;
|
||||
|
||||
virtual bool SetDefaultForeground(const DWORD color) noexcept = 0;
|
||||
virtual bool SetDefaultBackground(const DWORD color) noexcept = 0;
|
||||
|
||||
virtual bool SetInputMode(const ::Microsoft::Console::VirtualTerminal::TerminalInput::Mode mode, const bool enabled) noexcept = 0;
|
||||
|
||||
virtual bool SetScreenMode(const bool reverseMode) noexcept = 0;
|
||||
|
|
|
@ -109,8 +109,6 @@ public:
|
|||
bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept override;
|
||||
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) noexcept override;
|
||||
bool SetCursorColor(const COLORREF color) noexcept override;
|
||||
bool SetDefaultForeground(const COLORREF color) noexcept override;
|
||||
bool SetDefaultBackground(const COLORREF color) noexcept override;
|
||||
|
||||
bool SetInputMode(const ::Microsoft::Console::VirtualTerminal::TerminalInput::Mode mode, const bool enabled) noexcept override;
|
||||
|
||||
|
@ -212,7 +210,6 @@ public:
|
|||
void ClearPatternTree() noexcept;
|
||||
|
||||
const std::optional<til::color> GetTabColor() const noexcept;
|
||||
til::color GetDefaultBackground() const noexcept;
|
||||
|
||||
Microsoft::Console::Render::BlinkingState& GetBlinkingState() const noexcept;
|
||||
|
||||
|
|
|
@ -383,6 +383,11 @@ try
|
|||
{
|
||||
_colorTable.at(tableIndex) = color;
|
||||
|
||||
if (tableIndex == TextColor::DEFAULT_BACKGROUND)
|
||||
{
|
||||
_pfnBackgroundColorChanged(color);
|
||||
}
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
|
@ -442,46 +447,6 @@ bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) noex
|
|||
return true;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Updates the default foreground color from a COLORREF, format 0x00BBGGRR.
|
||||
// Arguments:
|
||||
// - color: the new COLORREF to use as the default foreground color
|
||||
// Return Value:
|
||||
// - true
|
||||
bool Terminal::SetDefaultForeground(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = color;
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
// Method Description:
|
||||
// - Updates the default background color from a COLORREF, format 0x00BBGGRR.
|
||||
// Arguments:
|
||||
// - color: the new COLORREF to use as the default background color
|
||||
// Return Value:
|
||||
// - true
|
||||
bool Terminal::SetDefaultBackground(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = color;
|
||||
_pfnBackgroundColorChanged(color);
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
til::color Terminal::GetDefaultBackground() const noexcept
|
||||
{
|
||||
return _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
bool Terminal::SetInputMode(const TerminalInput::Mode mode, const bool enabled) noexcept
|
||||
try
|
||||
{
|
||||
|
|
|
@ -247,7 +247,7 @@ CATCH_LOG_RETURN_FALSE()
|
|||
bool TerminalDispatch::SetDefaultForeground(const DWORD color) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.SetDefaultForeground(color);
|
||||
return _terminalApi.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, color);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
|
@ -260,7 +260,7 @@ CATCH_LOG_RETURN_FALSE()
|
|||
bool TerminalDispatch::SetDefaultBackground(const DWORD color) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.SetDefaultBackground(color);
|
||||
return _terminalApi.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, color);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
|
|
|
@ -1998,7 +1998,7 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo)
|
|||
// terminals as well is global, not per-screen-buffer.
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetColorTableEntry(const size_t index, const COLORREF value) noexcept
|
||||
{
|
||||
RETURN_HR_IF(E_INVALIDARG, index >= 256);
|
||||
RETURN_HR_IF(E_INVALIDARG, index >= TextColor::TABLE_SIZE);
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
|
@ -2018,60 +2018,6 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo)
|
|||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the default foreground color to the color specified in value.
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - S_OK
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultForegroundColor(const COLORREF value) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
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.
|
||||
if (g.pRender && !gci.IsInVtIoMode())
|
||||
{
|
||||
g.pRender->TriggerRedrawAll();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the default background color to the color specified in value.
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - S_OK
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultBackgroundColor(const COLORREF value) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
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.
|
||||
if (g.pRender && !gci.IsInVtIoMode())
|
||||
{
|
||||
g.pRender->TriggerRedrawAll();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - A private API call for filling a region of the screen buffer.
|
||||
// Arguments:
|
||||
|
|
|
@ -66,10 +66,6 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo);
|
|||
[[nodiscard]] HRESULT DoSrvPrivateGetColorTableEntry(const size_t index, COLORREF& value) noexcept;
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetColorTableEntry(const size_t index, const COLORREF value) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultForegroundColor(const COLORREF value) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultBackgroundColor(const COLORREF value) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateFillRegion(SCREEN_INFORMATION& screenInfo,
|
||||
const COORD startPosition,
|
||||
const size_t fillLength,
|
||||
|
|
|
@ -633,30 +633,6 @@ bool ConhostInternalGetSet::PrivateSetColorTableEntry(const size_t index, const
|
|||
return SUCCEEDED(DoSrvPrivateSetColorTableEntry(index, value));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Connects the PrivateSetDefaultForeground call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvPrivateSetDefaultForegroundColor). false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateSetDefaultForeground(const COLORREF value) const noexcept
|
||||
{
|
||||
return SUCCEEDED(DoSrvPrivateSetDefaultForegroundColor(value));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Connects the PrivateSetDefaultBackground call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvPrivateSetDefaultBackgroundColor). false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateSetDefaultBackground(const COLORREF value) const noexcept
|
||||
{
|
||||
return SUCCEEDED(DoSrvPrivateSetDefaultBackgroundColor(value));
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Connects the PrivateFillRegion call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
|
|
|
@ -122,10 +122,6 @@ public:
|
|||
bool PrivateGetColorTableEntry(const size_t index, COLORREF& value) const noexcept override;
|
||||
bool PrivateSetColorTableEntry(const size_t index, const COLORREF value) const noexcept override;
|
||||
|
||||
bool PrivateSetDefaultForeground(const COLORREF value) const noexcept override;
|
||||
|
||||
bool PrivateSetDefaultBackground(const COLORREF value) const noexcept override;
|
||||
|
||||
bool PrivateFillRegion(const COORD startPosition,
|
||||
const size_t fillLength,
|
||||
const wchar_t fillChar,
|
||||
|
|
|
@ -2293,10 +2293,10 @@ bool AdaptDispatch::SetColorTableEntry(const size_t tableIndex, const DWORD dwCo
|
|||
// - dwColor: The new RGB color value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// True if handled successfully. False otherwise.
|
||||
bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultForeground(const DWORD dwColor)
|
||||
bool AdaptDispatch::SetDefaultForeground(const DWORD dwColor)
|
||||
{
|
||||
bool success = true;
|
||||
success = _pConApi->PrivateSetDefaultForeground(dwColor);
|
||||
success = _pConApi->PrivateSetColorTableEntry(TextColor::DEFAULT_FOREGROUND, dwColor);
|
||||
|
||||
// If we're a conpty, always return false, so that we send the updated color
|
||||
// value to the terminal. Still handle the sequence so apps that use
|
||||
|
@ -2316,10 +2316,10 @@ bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultForeground(co
|
|||
// - dwColor: The new RGB color value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// True if handled successfully. False otherwise.
|
||||
bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultBackground(const DWORD dwColor)
|
||||
bool AdaptDispatch::SetDefaultBackground(const DWORD dwColor)
|
||||
{
|
||||
bool success = true;
|
||||
success = _pConApi->PrivateSetDefaultBackground(dwColor);
|
||||
success = _pConApi->PrivateSetColorTableEntry(TextColor::DEFAULT_BACKGROUND, dwColor);
|
||||
|
||||
// If we're a conpty, always return false, so that we send the updated color
|
||||
// value to the terminal. Still handle the sequence so apps that use
|
||||
|
|
|
@ -89,8 +89,6 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
|
||||
virtual bool PrivateGetColorTableEntry(const size_t index, COLORREF& value) const = 0;
|
||||
virtual bool PrivateSetColorTableEntry(const size_t index, const COLORREF value) const = 0;
|
||||
virtual bool PrivateSetDefaultForeground(const COLORREF value) const = 0;
|
||||
virtual bool PrivateSetDefaultBackground(const COLORREF value) const = 0;
|
||||
|
||||
virtual bool PrivateFillRegion(const COORD startPosition,
|
||||
const size_t fillLength,
|
||||
|
|
|
@ -465,28 +465,6 @@ public:
|
|||
return _privateSetColorTableEntryResult;
|
||||
}
|
||||
|
||||
bool PrivateSetDefaultForeground(const COLORREF value) const noexcept override
|
||||
{
|
||||
Log::Comment(L"PrivateSetDefaultForeground MOCK called...");
|
||||
if (_privateSetDefaultForegroundResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedDefaultForegroundColorValue, value);
|
||||
}
|
||||
|
||||
return _privateSetDefaultForegroundResult;
|
||||
}
|
||||
|
||||
bool PrivateSetDefaultBackground(const COLORREF value) const noexcept override
|
||||
{
|
||||
Log::Comment(L"PrivateSetDefaultForeground MOCK called...");
|
||||
if (_privateSetDefaultBackgroundResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedDefaultBackgroundColorValue, value);
|
||||
}
|
||||
|
||||
return _privateSetDefaultBackgroundResult;
|
||||
}
|
||||
|
||||
bool PrivateFillRegion(const COORD /*startPosition*/,
|
||||
const size_t /*fillLength*/,
|
||||
const wchar_t /*fillChar*/,
|
||||
|
@ -750,12 +728,6 @@ public:
|
|||
size_t _expectedColorTableIndex = SIZE_MAX;
|
||||
COLORREF _expectedColorValue = INVALID_COLOR;
|
||||
|
||||
bool _privateSetDefaultForegroundResult = false;
|
||||
COLORREF _expectedDefaultForegroundColorValue = INVALID_COLOR;
|
||||
|
||||
bool _privateSetDefaultBackgroundResult = false;
|
||||
COLORREF _expectedDefaultBackgroundColorValue = INVALID_COLOR;
|
||||
|
||||
SIZE _expectedCellSize = {};
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue