e9a7053629
ColorScheme is now a WinRT object. All of the JSON stuff can't be exposed via the idl. So the plan here is that we'll have the TerminalSettingsModel project handle all of the serialization when it's moved over. These functions will be exposed off of the `implementation` namespace, not projected namespace. References #7141 - ColorScheme is a settings object References #885 - this new settings object will be moved to a new TerminalSettingsModel project ## Validation Steps Performed - [x] Tests passed - [x] Deployment succeeded
71 lines
2.1 KiB
C++
71 lines
2.1 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- ColorScheme.hpp
|
|
|
|
Abstract:
|
|
- A color scheme is a single set of colors to use as the terminal colors. These
|
|
schemes are named, and can be used to quickly change all the colors of the
|
|
terminal to another scheme.
|
|
|
|
Author(s):
|
|
- Mike Griese - March 2019
|
|
|
|
--*/
|
|
#pragma once
|
|
#include "TerminalSettings.h"
|
|
#include "../../inc/conattrs.hpp"
|
|
|
|
#include "ColorScheme.g.h"
|
|
|
|
// fwdecl unittest classes
|
|
namespace TerminalAppLocalTests
|
|
{
|
|
class SettingsTests;
|
|
class ColorSchemeTests;
|
|
};
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
{
|
|
struct ColorScheme : ColorSchemeT<ColorScheme>
|
|
{
|
|
public:
|
|
ColorScheme();
|
|
ColorScheme(hstring name, Windows::UI::Color defaultFg, Windows::UI::Color defaultBg, Windows::UI::Color cursorColor);
|
|
~ColorScheme();
|
|
|
|
void ApplyScheme(const winrt::Microsoft::Terminal::TerminalControl::IControlSettings& terminalSettings) const;
|
|
|
|
static com_ptr<ColorScheme> FromJson(const Json::Value& json);
|
|
bool ShouldBeLayered(const Json::Value& json) const;
|
|
void LayerJson(const Json::Value& json);
|
|
|
|
hstring Name() const noexcept;
|
|
com_array<Windows::UI::Color> Table() const noexcept;
|
|
Windows::UI::Color Foreground() const noexcept;
|
|
Windows::UI::Color Background() const noexcept;
|
|
Windows::UI::Color SelectionBackground() const noexcept;
|
|
Windows::UI::Color CursorColor() const noexcept;
|
|
|
|
static std::optional<std::wstring> GetNameFromJson(const Json::Value& json);
|
|
|
|
private:
|
|
hstring _schemeName;
|
|
std::array<til::color, COLOR_TABLE_SIZE> _table;
|
|
til::color _defaultForeground;
|
|
til::color _defaultBackground;
|
|
til::color _selectionBackground;
|
|
til::color _cursorColor;
|
|
|
|
friend class TerminalAppLocalTests::SettingsTests;
|
|
friend class TerminalAppLocalTests::ColorSchemeTests;
|
|
};
|
|
}
|
|
|
|
namespace winrt::TerminalApp::factory_implementation
|
|
{
|
|
BASIC_FACTORY(ColorScheme);
|
|
}
|