This is a crazy idea but if it works, it'll be a game changer

This commit is contained in:
Mike Griese 2021-09-23 16:31:31 -05:00
parent dad065e0fe
commit 981d8cc9c8
3 changed files with 164 additions and 0 deletions

View file

@ -0,0 +1,71 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
--*/
#pragma once
#include "../../inc/cppwinrt_utils.h"
#include <DefaultSettings.h>
#include <conattrs.hpp>
// using IFontFeatureMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, uint32_t>;
// using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, float>;
namespace winrt::Microsoft::Terminal::Control::implementation
{
// --------------------------- Core Appearance ---------------------------
// All of these settings are defined in ICoreSettings.
#define CORE_APPEARANCE_SETTINGS(X) \
X(til::color, DefaultForeground, DEFAULT_FOREGROUND) \
X(til::color, DefaultBackground, DEFAULT_BACKGROUND) \
X(til::color, CursorColor, DEFAULT_CURSOR_COLOR) \
X(winrt::Microsoft::Terminal::Core::CursorStyle, CursorShape, winrt::Microsoft::Terminal::Core::CursorStyle::Vintage) \
X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \
X(bool, IntenseIsBright, true)
// --------------------------- Control Appearance ---------------------------
// All of these settings are defined in IControlSettings.
#define CONTROL_APPEARANCE_SETTINGS(X) \
X(til::color, SelectionBackground, DEFAULT_FOREGROUND) \
X(double, Opacity, .5) \
X(winrt::hstring, BackgroundImage) \
X(double, BackgroundImageOpacity, 1.0) \
X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \
X(winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center) \
X(winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center) \
X(bool, IntenseIsBold) \
X(bool, RetroTerminalEffect, false) \
X(winrt::hstring, PixelShaderPath)
struct ControlAppearance : public winrt::implements<ControlAppearance, Microsoft::Terminal::Core::ICoreAppearance, Microsoft::Terminal::Control::IControlAppearance>
{
#define CORE_SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__);
CORE_APPEARANCE_SETTINGS(CORE_SETTINGS_GEN)
#undef CORE_SETTINGS_GEN
#define CONTROL_SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__);
CONTROL_APPEARANCE_SETTINGS(CONTROL_SETTINGS_GEN)
#undef CONTROL_SETTINGS_GEN
private:
std::array<winrt::Microsoft::Terminal::Core::Color, COLOR_TABLE_SIZE> _ColorTable;
public:
winrt::Microsoft::Terminal::Core::Color GetColorTableEntry(int32_t index) noexcept { return _ColorTable.at(index); }
std::array<winrt::Microsoft::Terminal::Core::Color, 16> ColorTable() { return _ColorTable; }
void ColorTable(std::array<winrt::Microsoft::Terminal::Core::Color, 16> /*colors*/) {}
// ControlSettings()
// {
// const auto campbellSpan = ::Microsoft::Console::Utils::CampbellColorTable();
// std::transform(campbellSpan.begin(), campbellSpan.end(), _ColorTable.begin(), [](auto&& color) {
// return static_cast<winrt::Microsoft::Terminal::Core::Color>(til::color{ color });
// });
// }
};
}
// namespace winrt::Microsoft::Terminal::Control::factory_implementation
// {
// BASIC_FACTORY(ControlSettings);
// }

View file

@ -17,6 +17,7 @@
#include "EventArgs.h"
#include "ControlCore.g.h"
#include "ControlSettings.h"
#include "../../renderer/base/Renderer.hpp"
#include "../../renderer/dx/DxRenderer.hpp"
#include "../../renderer/uia/UiaRenderer.hpp"

View file

@ -0,0 +1,92 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
--*/
#pragma once
#include "../../inc/cppwinrt_utils.h"
#include <DefaultSettings.h>
#include <conattrs.hpp>
#include "ControlAppearance.h"
using IFontFeatureMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, uint32_t>;
using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, float>;
namespace winrt::Microsoft::Terminal::Control::implementation
{
// --------------------------- Core Settings ---------------------------
// All of these settings are defined in ICoreSettings.
#define CORE_SETTINGS(X) \
X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \
X(int32_t, InitialRows, 30) \
X(int32_t, InitialCols, 80) \
X(bool, SnapOnInput, true) \
X(bool, AltGrAliasing, true) \
X(winrt::hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \
X(bool, CopyOnSelect, false) \
X(bool, InputServiceWarning, true) \
X(bool, FocusFollowMouse, false) \
X(winrt::Windows::Foundation::IReference<winrt::Microsoft::Terminal::Core::Color>, TabColor, nullptr) \
X(winrt::Windows::Foundation::IReference<winrt::Microsoft::Terminal::Core::Color>, StartingTabColor, nullptr) \
X(bool, TrimBlockSelection, false) \
X(bool, DetectURLs, true)
// --------------------------- Control Settings ---------------------------
// All of these settings are defined in IControlSettings.
#define CONTROL_SETTINGS(X) \
X(winrt::hstring, ProfileName) \
X(bool, UseAcrylic, false) \
X(winrt::hstring, Padding, DEFAULT_PADDING) \
X(winrt::hstring, FontFace, L"Consolas") \
X(int32_t, FontSize, DEFAULT_FONT_SIZE) \
X(winrt::Windows::UI::Text::FontWeight, FontWeight) \
X(winrt::Microsoft::Terminal::Control::IKeyBindings, KeyBindings, nullptr) \
X(winrt::hstring, Commandline) \
X(winrt::hstring, StartingDirectory) \
X(winrt::hstring, StartingTitle) \
X(bool, SuppressApplicationTitle) \
X(winrt::hstring, EnvironmentVariables) \
X(winrt::Microsoft::Terminal::Control::ScrollbarState, ScrollState, winrt::Microsoft::Terminal::Control::ScrollbarState::Visible) \
X(winrt::Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, winrt::Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \
X(bool, ForceFullRepaintRendering, false) \
X(bool, SoftwareRendering, false) \
X(bool, ForceVTInput, false)
struct ControlSettings // : public winrt::implements<ControlSettings /*, Microsoft::Terminal::Core::ICoreSettings, Microsoft::Terminal::Control::IControlSettings*/>
{
#define CORE_SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__);
CORE_SETTINGS(CORE_SETTINGS_GEN)
#undef CORE_SETTINGS_GEN
#define CONTROL_SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__);
CONTROL_SETTINGS(CONTROL_SETTINGS_GEN)
#undef CONTROL_SETTINGS_GEN
public:
winrt::com_ptr<ControlAppearance> UnfocusedAppearance()
{
return _unfocusedAppearance;
};
winrt::com_ptr<ControlAppearance> FocusedAppearance()
{
return _focusedAppearance;
};
private:
winrt::com_ptr<ControlAppearance> _unfocusedAppearance{ nullptr };
winrt::com_ptr<ControlAppearance> _focusedAppearance{ nullptr };
// ControlSettings()
// {
// const auto campbellSpan = ::Microsoft::Console::Utils::CampbellColorTable();
// std::transform(campbellSpan.begin(), campbellSpan.end(), _ColorTable.begin(), [](auto&& color) {
// return static_cast<winrt::Microsoft::Terminal::Core::Color>(til::color{ color });
// });
// }
};
}
// namespace winrt::Microsoft::Terminal::Control::factory_implementation
// {
// BASIC_FACTORY(ControlSettings);
// }