From 7fc2f10bbdc5a42bf174e42aaa892d493fa2968a Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 23 Sep 2021 17:08:40 -0500 Subject: [PATCH] move to a common header --- .../TerminalControl/ControlAppearance.h | 44 ++---------- .../TerminalControl/ControlSettings.h | 63 +++-------------- src/cascadia/inc/ControlProperties.h | 67 +++++++++++++++++++ 3 files changed, 80 insertions(+), 94 deletions(-) create mode 100644 src/cascadia/inc/ControlProperties.h diff --git a/src/cascadia/TerminalControl/ControlAppearance.h b/src/cascadia/TerminalControl/ControlAppearance.h index 877055c53..b83e50d1b 100644 --- a/src/cascadia/TerminalControl/ControlAppearance.h +++ b/src/cascadia/TerminalControl/ControlAppearance.h @@ -4,48 +4,19 @@ Licensed under the MIT license. --*/ #pragma once #include "../../inc/cppwinrt_utils.h" +#include "../../inc/ControlProperties.h" #include #include -// using IFontFeatureMap = winrt::Windows::Foundation::Collections::IMap; -// using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap; - 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, 1.0) \ - 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 { -#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 +#define SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__); + CORE_APPEARANCE_SETTINGS(SETTINGS_GEN) + CONTROL_APPEARANCE_SETTINGS(SETTINGS_GEN) +#undef SETTINGS_GEN private: std::array _ColorTable; @@ -64,8 +35,3 @@ namespace winrt::Microsoft::Terminal::Control::implementation } }; } - -// namespace winrt::Microsoft::Terminal::Control::factory_implementation -// { -// BASIC_FACTORY(ControlSettings); -// } diff --git a/src/cascadia/TerminalControl/ControlSettings.h b/src/cascadia/TerminalControl/ControlSettings.h index af440bdec..9a7d94cb7 100644 --- a/src/cascadia/TerminalControl/ControlSettings.h +++ b/src/cascadia/TerminalControl/ControlSettings.h @@ -4,6 +4,7 @@ Licensed under the MIT license. --*/ #pragma once #include "../../inc/cppwinrt_utils.h" +#include "../../inc/ControlProperties.h" #include #include @@ -14,54 +15,12 @@ using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap, TabColor, nullptr) \ - X(winrt::Windows::Foundation::IReference, 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(IFontFeatureMap, FontFeatures) \ - X(IFontAxesMap, FontAxes) \ - 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 + struct ControlSettings { -#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 +#define SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__); + CORE_SETTINGS(SETTINGS_GEN) + CONTROL_SETTINGS(SETTINGS_GEN) +#undef SETTINGS_GEN private: winrt::com_ptr _unfocusedAppearance{ nullptr }; @@ -81,13 +40,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation #undef COPY_SETTING } - winrt::com_ptr UnfocusedAppearance() - { - return _unfocusedAppearance; - }; - winrt::com_ptr FocusedAppearance() - { - return _focusedAppearance; - }; + winrt::com_ptr UnfocusedAppearance() { return _unfocusedAppearance; } + winrt::com_ptr FocusedAppearance() { return _focusedAppearance; } }; } diff --git a/src/cascadia/inc/ControlProperties.h b/src/cascadia/inc/ControlProperties.h new file mode 100644 index 000000000..fe39d92fe --- /dev/null +++ b/src/cascadia/inc/ControlProperties.h @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +// --------------------------- Core Appearance --------------------------- +// All of these settings are defined in ICoreAppearance. +#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, 1.0) \ + 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) + +// --------------------------- 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, FocusFollowMouse, false) \ + X(winrt::Windows::Foundation::IReference, TabColor, nullptr) \ + X(winrt::Windows::Foundation::IReference, 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(IFontFeatureMap, FontFeatures) \ + X(IFontAxesMap, FontAxes) \ + 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)