bb71179a24
This PR merges the default colors and cursor color into the main color table, enabling us to simplify the `ConGetSet` and `ITerminalApi` interfaces, with just two methods required for getting and setting any form of color palette entry. The is a follow-up to the color table standardization in #11602, and a another small step towards de-duplicating `AdaptDispatch` and `TerminalDispatch` for issue #3849. It should also make it easier to support color queries (#3718) and a configurable bold color (#5682) in the future. On the conhost side, default colors could originally be either indexed positions in the 16-color table, or separate standalone RGB values. With the new system, the default colors will always be in the color table, so we just need to track their index positions. To make this work, those positions need to be calculated at startup based on the loaded registry/shortcut settings, and updated when settings are changed (this is handled in `CalculateDefaultColorIndices`). But the plus side is that it's now much easier to lookup the default color values for rendering. For now the default colors in Windows Terminal use hardcoded positions, because it doesn't need indexed default colors like conhost. But in the future I'd like to extend the index handling to both terminals, so we can eventually support the VT525 indexed color operations. As for the cursor color, that was previously stored in the `Cursor` class, which meant that it needed to be copied around in various places where cursors were being instantiated. Now that it's managed separately in the color table, a lot of that code is no longer required. ## Validation Some of the unit test initialization code needed to be updated to setup the color table and default index values as required for the new system. There were also some adjustments needed to account for API changes, in particular for methods that now take index values for the default colors in place of COLORREFs. But for the most part, the essential behavior of the tests remains unchanged. I've also run a variety of manual tests looking at the legacy console APIs as well as the various VT color sequences, and checking that everything works as expected when color schemes are changed, both in Windows Terminal and conhost, and in the latter case with both indexed colors and RGB values. Closes #11768
73 lines
3.4 KiB
C++
73 lines
3.4 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
#pragma once
|
|
|
|
#include "../../terminal/adapter/DispatchTypes.hpp"
|
|
#include "../../terminal/input/terminalInput.hpp"
|
|
#include "../../buffer/out/TextAttribute.hpp"
|
|
#include "../../types/inc/Viewport.hpp"
|
|
|
|
namespace Microsoft::Terminal::Core
|
|
{
|
|
class ITerminalApi
|
|
{
|
|
public:
|
|
virtual ~ITerminalApi() {}
|
|
ITerminalApi(const ITerminalApi&) = default;
|
|
ITerminalApi(ITerminalApi&&) = default;
|
|
ITerminalApi& operator=(const ITerminalApi&) = default;
|
|
ITerminalApi& operator=(ITerminalApi&&) = default;
|
|
|
|
virtual bool PrintString(std::wstring_view string) noexcept = 0;
|
|
virtual bool ExecuteChar(wchar_t wch) noexcept = 0;
|
|
|
|
virtual TextAttribute GetTextAttributes() const noexcept = 0;
|
|
virtual void SetTextAttributes(const TextAttribute& attrs) noexcept = 0;
|
|
|
|
virtual Microsoft::Console::Types::Viewport GetBufferSize() noexcept = 0;
|
|
virtual bool SetCursorPosition(short x, short y) noexcept = 0;
|
|
virtual COORD GetCursorPosition() noexcept = 0;
|
|
virtual bool SetCursorVisibility(const bool visible) noexcept = 0;
|
|
virtual bool CursorLineFeed(const bool withReturn) noexcept = 0;
|
|
virtual bool EnableCursorBlinking(const bool enable) noexcept = 0;
|
|
|
|
virtual bool DeleteCharacter(const size_t count) noexcept = 0;
|
|
virtual bool InsertCharacter(const size_t count) noexcept = 0;
|
|
virtual bool EraseCharacters(const size_t numChars) noexcept = 0;
|
|
virtual bool EraseInLine(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept = 0;
|
|
virtual bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept = 0;
|
|
|
|
virtual bool WarningBell() noexcept = 0;
|
|
virtual bool SetWindowTitle(std::wstring_view title) noexcept = 0;
|
|
|
|
virtual COLORREF GetColorTableEntry(const size_t tableIndex) const noexcept = 0;
|
|
virtual bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept = 0;
|
|
|
|
virtual bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) 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;
|
|
virtual bool EnableXtermBracketedPasteMode(const bool enabled) noexcept = 0;
|
|
virtual bool IsXtermBracketedPasteModeEnabled() const = 0;
|
|
|
|
virtual bool IsVtInputEnabled() const = 0;
|
|
|
|
virtual bool CopyToClipboard(std::wstring_view content) noexcept = 0;
|
|
|
|
virtual bool AddHyperlink(std::wstring_view uri, std::wstring_view params) noexcept = 0;
|
|
virtual bool EndHyperlink() noexcept = 0;
|
|
|
|
virtual bool SetTaskbarProgress(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::TaskbarState state, const size_t progress) noexcept = 0;
|
|
|
|
virtual bool SetWorkingDirectory(std::wstring_view uri) noexcept = 0;
|
|
virtual std::wstring_view GetWorkingDirectory() noexcept = 0;
|
|
|
|
virtual bool PushGraphicsRendition(const ::Microsoft::Console::VirtualTerminal::VTParameters options) noexcept = 0;
|
|
virtual bool PopGraphicsRendition() noexcept = 0;
|
|
|
|
protected:
|
|
ITerminalApi() = default;
|
|
};
|
|
}
|