From 3236268fd30117e8f84e07fe1037dfa564edd63d Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 4 Oct 2021 15:25:01 -0700 Subject: [PATCH 01/15] first pass --- .../AppearanceConfig.cpp | 34 ++++++----- .../TerminalSettingsModel/AppearanceConfig.h | 13 ++--- .../GlobalAppSettings.cpp | 45 +++++---------- .../TerminalSettingsModel/GlobalAppSettings.h | 16 ++---- ...crosoft.Terminal.Settings.ModelLib.vcxproj | 1 + ...Terminal.Settings.ModelLib.vcxproj.filters | 1 + .../TerminalSettingsModel/Profile.cpp | 43 ++++++-------- src/cascadia/TerminalSettingsModel/Profile.h | 17 ++---- .../TerminalSettingsModel/SettingsUtils.h | 52 +++++++++++++++++ .../TerminalSettings.cpp | 56 ++++++------------- .../TerminalSettingsModel/TerminalSettings.h | 54 +++++++----------- 11 files changed, 158 insertions(+), 174 deletions(-) create mode 100644 src/cascadia/TerminalSettingsModel/SettingsUtils.h diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index 2384de2ff48..e2c63d63412 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -38,20 +38,20 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan { auto appearance{ winrt::make_self(std::move(sourceProfile)) }; appearance->_BackgroundImagePath = source->_BackgroundImagePath; - appearance->_BackgroundImageOpacity = source->_BackgroundImageOpacity; - appearance->_BackgroundImageStretchMode = source->_BackgroundImageStretchMode; appearance->_ColorSchemeName = source->_ColorSchemeName; appearance->_Foreground = source->_Foreground; appearance->_Background = source->_Background; appearance->_SelectionBackground = source->_SelectionBackground; appearance->_CursorColor = source->_CursorColor; - appearance->_CursorShape = source->_CursorShape; - appearance->_CursorHeight = source->_CursorHeight; appearance->_BackgroundImageAlignment = source->_BackgroundImageAlignment; - appearance->_RetroTerminalEffect = source->_RetroTerminalEffect; - appearance->_PixelShaderPath = source->_PixelShaderPath; appearance->_IntenseTextStyle = source->_IntenseTextStyle; appearance->_Opacity = source->_Opacity; + +#define APPEARANCE_SETTINGS_COPY(type, name, ...) \ + appearance->_##name = source->_##name; + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) +#undef APPEARANCE_SETTINGS_COPY + return appearance; } @@ -64,17 +64,16 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor); JsonUtils::SetValueForKey(json, ColorSchemeKey, _ColorSchemeName); - JsonUtils::SetValueForKey(json, CursorHeightKey, _CursorHeight); - JsonUtils::SetValueForKey(json, CursorShapeKey, _CursorShape); JsonUtils::SetValueForKey(json, BackgroundImageKey, _BackgroundImagePath); - JsonUtils::SetValueForKey(json, BackgroundImageOpacityKey, _BackgroundImageOpacity); - JsonUtils::SetValueForKey(json, BackgroundImageStretchModeKey, _BackgroundImageStretchMode); JsonUtils::SetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); - JsonUtils::SetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect); - JsonUtils::SetValueForKey(json, PixelShaderPathKey, _PixelShaderPath); JsonUtils::SetValueForKey(json, IntenseTextStyleKey, _IntenseTextStyle); JsonUtils::SetValueForKey(json, OpacityKey, _Opacity, JsonUtils::OptionalConverter{}); +#define APPEARANCE_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) +#undef APPEARANCE_SETTINGS_TO_JSON + return json; } @@ -95,18 +94,17 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, BackgroundKey, _Background); JsonUtils::GetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::GetValueForKey(json, CursorColorKey, _CursorColor); - JsonUtils::GetValueForKey(json, CursorHeightKey, _CursorHeight); JsonUtils::GetValueForKey(json, ColorSchemeKey, _ColorSchemeName); - JsonUtils::GetValueForKey(json, CursorShapeKey, _CursorShape); JsonUtils::GetValueForKey(json, BackgroundImageKey, _BackgroundImagePath); - JsonUtils::GetValueForKey(json, BackgroundImageOpacityKey, _BackgroundImageOpacity); - JsonUtils::GetValueForKey(json, BackgroundImageStretchModeKey, _BackgroundImageStretchMode); JsonUtils::GetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); - JsonUtils::GetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect); - JsonUtils::GetValueForKey(json, PixelShaderPathKey, _PixelShaderPath); JsonUtils::GetValueForKey(json, IntenseTextStyleKey, _IntenseTextStyle); JsonUtils::GetValueForKey(json, LegacyAcrylicTransparencyKey, _Opacity); JsonUtils::GetValueForKey(json, OpacityKey, _Opacity, JsonUtils::OptionalConverter{}); + +#define APPEARANCE_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) +#undef APPEARANCE_SETTINGS_LAYER_JSON } winrt::Microsoft::Terminal::Settings::Model::Profile AppearanceConfig::SourceProfile() diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index e15f5ef8287..aecf6233c46 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -19,6 +19,7 @@ Author(s): #include "AppearanceConfig.g.h" #include "JsonUtils.h" #include "IInheritable.h" +#include "SettingsUtils.h" #include namespace winrt::Microsoft::Terminal::Settings::Model::implementation @@ -37,23 +38,21 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::IAppearanceConfig, ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center); - INHERITABLE_SETTING(Model::IAppearanceConfig, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, ColorSchemeName, L"Campbell"); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Foreground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Background, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); - INHERITABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::CursorStyle, CursorShape, Microsoft::Terminal::Core::CursorStyle::Bar); INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, BackgroundImagePath); - INHERITABLE_SETTING(Model::IAppearanceConfig, double, BackgroundImageOpacity, 1.0); - INHERITABLE_SETTING(Model::IAppearanceConfig, Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch::UniformToFill); - - INHERITABLE_SETTING(Model::IAppearanceConfig, bool, RetroTerminalEffect, false); - INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, PixelShaderPath, L""); INHERITABLE_SETTING(Model::IAppearanceConfig, Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright); INHERITABLE_SETTING(Model::IAppearanceConfig, double, Opacity, 1.0); + #define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) + #undef APPEARANCE_SETTINGS_INITIALIZE + private: winrt::weak_ref _sourceProfile; }; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 53c0fd90f7a..963bc12d1ca 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -85,8 +85,6 @@ void GlobalAppSettings::_FinalizeInheritance() winrt::com_ptr GlobalAppSettings::Copy() const { auto globals{ winrt::make_self() }; - globals->_InitialRows = _InitialRows; - globals->_InitialCols = _InitialCols; globals->_AlwaysShowTabs = _AlwaysShowTabs; globals->_ShowTitleInTitlebar = _ShowTitleInTitlebar; globals->_ConfirmCloseAllTabs = _ConfirmCloseAllTabs; @@ -95,9 +93,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_TabWidthMode = _TabWidthMode; globals->_UseAcrylicInTabRow = _UseAcrylicInTabRow; globals->_ShowTabsInTitlebar = _ShowTabsInTitlebar; - globals->_WordDelimiters = _WordDelimiters; globals->_InputServiceWarning = _InputServiceWarning; - globals->_CopyOnSelect = _CopyOnSelect; globals->_CopyFormatting = _CopyFormatting; globals->_WarnAboutLargePaste = _WarnAboutLargePaste; globals->_WarnAboutMultiLinePaste = _WarnAboutMultiLinePaste; @@ -105,9 +101,6 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_CenterOnLaunch = _CenterOnLaunch; globals->_LaunchMode = _LaunchMode; globals->_SnapToGridOnResize = _SnapToGridOnResize; - globals->_ForceFullRepaintRendering = _ForceFullRepaintRendering; - globals->_SoftwareRendering = _SoftwareRendering; - globals->_ForceVTInput = _ForceVTInput; globals->_DebugFeaturesEnabled = _DebugFeaturesEnabled; globals->_StartOnUserLogin = _StartOnUserLogin; globals->_FirstWindowPreference = _FirstWindowPreference; @@ -115,10 +108,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_TabSwitcherMode = _TabSwitcherMode; globals->_DisableAnimations = _DisableAnimations; globals->_StartupActions = _StartupActions; - globals->_FocusFollowMouse = _FocusFollowMouse; globals->_WindowingBehavior = _WindowingBehavior; - globals->_TrimBlockSelection = _TrimBlockSelection; - globals->_DetectURLs = _DetectURLs; globals->_MinimizeToNotificationArea = _MinimizeToNotificationArea; globals->_AlwaysShowNotificationIcon = _AlwaysShowNotificationIcon; globals->_DisabledProfileSources = _DisabledProfileSources; @@ -130,6 +120,11 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_actionMap = _actionMap->Copy(); globals->_keybindingsWarnings = _keybindingsWarnings; +#define GLOBAL_SETTINGS_COPY(type, name, ...) \ + globals->_##name = _##name; + GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) +#undef GLOBAL_SETTINGS_COPY + if (_colorSchemes) { for (auto kv : _colorSchemes) @@ -189,14 +184,10 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); JsonUtils::GetValueForKey(json, AlwaysShowTabsKey, _AlwaysShowTabs); JsonUtils::GetValueForKey(json, ConfirmCloseAllKey, _ConfirmCloseAllTabs); - JsonUtils::GetValueForKey(json, InitialRowsKey, _InitialRows); - JsonUtils::GetValueForKey(json, InitialColsKey, _InitialCols); JsonUtils::GetValueForKey(json, InitialPositionKey, _InitialPosition); JsonUtils::GetValueForKey(json, CenterOnLaunchKey, _CenterOnLaunch); JsonUtils::GetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); JsonUtils::GetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); - JsonUtils::GetValueForKey(json, WordDelimitersKey, _WordDelimiters); - JsonUtils::GetValueForKey(json, CopyOnSelectKey, _CopyOnSelect); JsonUtils::GetValueForKey(json, InputServiceWarningKey, _InputServiceWarning); JsonUtils::GetValueForKey(json, CopyFormattingKey, _CopyFormatting); JsonUtils::GetValueForKey(json, WarnAboutLargePasteKey, _WarnAboutLargePaste); @@ -210,9 +201,6 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, SnapToGridOnResizeKey, _SnapToGridOnResize); // GetValueForKey will only override the current value if the key exists JsonUtils::GetValueForKey(json, DebugFeaturesKey, _DebugFeaturesEnabled); - JsonUtils::GetValueForKey(json, ForceFullRepaintRenderingKey, _ForceFullRepaintRendering); - JsonUtils::GetValueForKey(json, SoftwareRenderingKey, _SoftwareRendering); - JsonUtils::GetValueForKey(json, ForceVTInputKey, _ForceVTInput); JsonUtils::GetValueForKey(json, EnableStartupTaskKey, _StartOnUserLogin); JsonUtils::GetValueForKey(json, AlwaysOnTopKey, _AlwaysOnTop); // GH#8076 - when adding enum values to this key, we also changed it from @@ -222,16 +210,18 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, TabSwitcherModeKey, _TabSwitcherMode); JsonUtils::GetValueForKey(json, DisableAnimationsKey, _DisableAnimations); JsonUtils::GetValueForKey(json, StartupActionsKey, _StartupActions); - JsonUtils::GetValueForKey(json, FocusFollowMouseKey, _FocusFollowMouse); JsonUtils::GetValueForKey(json, WindowingBehaviorKey, _WindowingBehavior); - JsonUtils::GetValueForKey(json, TrimBlockSelectionKey, _TrimBlockSelection); - JsonUtils::GetValueForKey(json, DetectURLsKey, _DetectURLs); JsonUtils::GetValueForKey(json, MinimizeToNotificationAreaKey, _MinimizeToNotificationArea); JsonUtils::GetValueForKey(json, AlwaysShowNotificationIconKey, _AlwaysShowNotificationIcon); JsonUtils::GetValueForKey(json, DisabledProfileSourcesKey, _DisabledProfileSources); JsonUtils::GetValueForKey(json, ShowAdminShieldKey, _ShowAdminShield); +#define GLOBAL_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) +#undef GLOBAL_SETTINGS_LAYER_JSON + static constexpr std::array bindingsKeys{ LegacyKeybindingsKey, ActionsKey }; for (const auto& jsonKey : bindingsKeys) { @@ -294,15 +284,11 @@ Json::Value GlobalAppSettings::ToJson() const JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); JsonUtils::SetValueForKey(json, AlwaysShowTabsKey, _AlwaysShowTabs); JsonUtils::SetValueForKey(json, ConfirmCloseAllKey, _ConfirmCloseAllTabs); - JsonUtils::SetValueForKey(json, InitialRowsKey, _InitialRows); - JsonUtils::SetValueForKey(json, InitialColsKey, _InitialCols); JsonUtils::SetValueForKey(json, InitialPositionKey, _InitialPosition); JsonUtils::SetValueForKey(json, CenterOnLaunchKey, _CenterOnLaunch); JsonUtils::SetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); JsonUtils::SetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); - JsonUtils::SetValueForKey(json, WordDelimitersKey, _WordDelimiters); JsonUtils::SetValueForKey(json, InputServiceWarningKey, _InputServiceWarning); - JsonUtils::SetValueForKey(json, CopyOnSelectKey, _CopyOnSelect); JsonUtils::SetValueForKey(json, CopyFormattingKey, _CopyFormatting); JsonUtils::SetValueForKey(json, WarnAboutLargePasteKey, _WarnAboutLargePaste); JsonUtils::SetValueForKey(json, WarnAboutMultiLinePasteKey, _WarnAboutMultiLinePaste); @@ -314,22 +300,21 @@ Json::Value GlobalAppSettings::ToJson() const JsonUtils::SetValueForKey(json, UseAcrylicInTabRowKey, _UseAcrylicInTabRow); JsonUtils::SetValueForKey(json, SnapToGridOnResizeKey, _SnapToGridOnResize); JsonUtils::SetValueForKey(json, DebugFeaturesKey, _DebugFeaturesEnabled); - JsonUtils::SetValueForKey(json, ForceFullRepaintRenderingKey, _ForceFullRepaintRendering); - JsonUtils::SetValueForKey(json, SoftwareRenderingKey, _SoftwareRendering); - JsonUtils::SetValueForKey(json, ForceVTInputKey, _ForceVTInput); JsonUtils::SetValueForKey(json, EnableStartupTaskKey, _StartOnUserLogin); JsonUtils::SetValueForKey(json, AlwaysOnTopKey, _AlwaysOnTop); JsonUtils::SetValueForKey(json, TabSwitcherModeKey, _TabSwitcherMode); JsonUtils::SetValueForKey(json, DisableAnimationsKey, _DisableAnimations); JsonUtils::SetValueForKey(json, StartupActionsKey, _StartupActions); - JsonUtils::SetValueForKey(json, FocusFollowMouseKey, _FocusFollowMouse); JsonUtils::SetValueForKey(json, WindowingBehaviorKey, _WindowingBehavior); - JsonUtils::SetValueForKey(json, TrimBlockSelectionKey, _TrimBlockSelection); - JsonUtils::SetValueForKey(json, DetectURLsKey, _DetectURLs); JsonUtils::SetValueForKey(json, MinimizeToNotificationAreaKey, _MinimizeToNotificationArea); JsonUtils::SetValueForKey(json, AlwaysShowNotificationIconKey, _AlwaysShowNotificationIcon); JsonUtils::SetValueForKey(json, DisabledProfileSourcesKey, _DisabledProfileSources); JsonUtils::SetValueForKey(json, ShowAdminShieldKey, _ShowAdminShield); + +#define GLOBAL_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) +#undef GLOBAL_SETTINGS_TO_JSON // clang-format on json[JsonKey(ActionsKey)] = _actionMap->ToJson(); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 32f73cafec1..7ffe5021522 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -17,6 +17,7 @@ Author(s): #include "GlobalAppSettings.g.h" #include "IInheritable.h" +#include "SettingsUtils.h" #include "ActionMap.h" #include "Command.h" @@ -61,8 +62,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DisableAnimations(!invertedDisableAnimationsValue); } - INHERITABLE_SETTING(Model::GlobalAppSettings, int32_t, InitialRows, DEFAULT_ROWS); - INHERITABLE_SETTING(Model::GlobalAppSettings, int32_t, InitialCols, DEFAULT_COLS); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowTitleInTitlebar, true); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ConfirmCloseAllTabs, true); @@ -71,8 +70,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, UseAcrylicInTabRow, false); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowTabsInTitlebar, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, CopyOnSelect, false); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, InputServiceWarning, true); INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, WarnAboutLargePaste, true); @@ -82,25 +79,24 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::GlobalAppSettings, Model::FirstWindowPreference, FirstWindowPreference, FirstWindowPreference::DefaultProfile); INHERITABLE_SETTING(Model::GlobalAppSettings, Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, SnapToGridOnResize, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ForceFullRepaintRendering, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, SoftwareRendering, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ForceVTInput, false); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, DebugFeaturesEnabled, debugFeaturesDefault); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, StartOnUserLogin, false); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysOnTop, false); INHERITABLE_SETTING(Model::GlobalAppSettings, Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, DisableAnimations, false); INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, StartupActions, L""); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, FocusFollowMouse, false); INHERITABLE_SETTING(Model::GlobalAppSettings, Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, TrimBlockSelection, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, DetectURLs, true); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, MinimizeToNotificationArea, false); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowNotificationIcon, false); INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr); INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, UnparsedDefaultProfile, L""); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowAdminShield, true); + #define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) + GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) + #undef GLOBAL_SETTINGS_INITIALIZE + private: #ifdef NDEBUG static constexpr bool debugFeaturesDefault{ false }; diff --git a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj index a5d82e34d93..a3984865e2c 100644 --- a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj +++ b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj @@ -51,6 +51,7 @@ GlobalAppSettings.idl + diff --git a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters index 873dcb28c07..23fa63283ba 100644 --- a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters +++ b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters @@ -79,6 +79,7 @@ json + diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index 287ce8970a9..c6c9288b1c9 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -36,7 +36,7 @@ static constexpr std::string_view ConnectionTypeKey{ "connectionType" }; static constexpr std::string_view CommandlineKey{ "commandline" }; static constexpr std::string_view FontInfoKey{ "font" }; static constexpr std::string_view UseAcrylicKey{ "useAcrylic" }; -static constexpr std::string_view ScrollbarStateKey{ "scrollbarState" }; +static constexpr std::string_view ScrollStateKey{ "scrollbarState" }; static constexpr std::string_view CloseOnExitKey{ "closeOnExit" }; static constexpr std::string_view PaddingKey{ "padding" }; static constexpr std::string_view StartingDirectoryKey{ "startingDirectory" }; @@ -122,23 +122,20 @@ winrt::com_ptr Profile::CopySettings() const profile->_TabTitle = _TabTitle; profile->_TabColor = _TabColor; profile->_SuppressApplicationTitle = _SuppressApplicationTitle; - profile->_UseAcrylic = _UseAcrylic; - profile->_ScrollState = _ScrollState; - profile->_Padding = _Padding; - profile->_Commandline = _Commandline; profile->_StartingDirectory = _StartingDirectory; - profile->_AntialiasingMode = _AntialiasingMode; profile->_ForceFullRepaintRendering = _ForceFullRepaintRendering; profile->_SoftwareRendering = _SoftwareRendering; - profile->_HistorySize = _HistorySize; - profile->_SnapOnInput = _SnapOnInput; - profile->_AltGrAliasing = _AltGrAliasing; profile->_BellStyle = _BellStyle; profile->_ConnectionType = _ConnectionType; profile->_Origin = _Origin; profile->_FontInfo = *fontInfo; profile->_DefaultAppearance = *defaultAppearance; +#define PROFILE_SETTINGS_COPY(type, name, ...) \ + profile->_##name = _##name; + PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) +#undef PROFILE_SETTINGS_COPY + if (_UnfocusedAppearance) { Model::AppearanceConfig unfocused{ nullptr }; @@ -197,31 +194,26 @@ void Profile::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, SourceKey, _Source); // TODO:MSFT:20642297 - Use a sentinel value (-1) for "Infinite scrollback" - JsonUtils::GetValueForKey(json, HistorySizeKey, _HistorySize); - JsonUtils::GetValueForKey(json, SnapOnInputKey, _SnapOnInput); - JsonUtils::GetValueForKey(json, AltGrAliasingKey, _AltGrAliasing); JsonUtils::GetValueForKey(json, TabTitleKey, _TabTitle); // Control Settings JsonUtils::GetValueForKey(json, ConnectionTypeKey, _ConnectionType); - JsonUtils::GetValueForKey(json, CommandlineKey, _Commandline); - JsonUtils::GetValueForKey(json, UseAcrylicKey, _UseAcrylic); JsonUtils::GetValueForKey(json, SuppressApplicationTitleKey, _SuppressApplicationTitle); JsonUtils::GetValueForKey(json, CloseOnExitKey, _CloseOnExit); // Padding was never specified as an integer, but it was a common working mistake. // Allow it to be permissive. - JsonUtils::GetValueForKey(json, PaddingKey, _Padding, JsonUtils::OptionalConverter>{}); - - JsonUtils::GetValueForKey(json, ScrollbarStateKey, _ScrollState); - JsonUtils::GetValueForKey(json, StartingDirectoryKey, _StartingDirectory); JsonUtils::GetValueForKey(json, IconKey, _Icon); - JsonUtils::GetValueForKey(json, AntialiasingModeKey, _AntialiasingMode); JsonUtils::GetValueForKey(json, TabColorKey, _TabColor); JsonUtils::GetValueForKey(json, BellStyleKey, _BellStyle); +#define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) +#undef PROFILE_SETTINGS_LAYER_JSON + if (json.isMember(JsonKey(UnfocusedAppearanceKey))) { auto unfocusedAppearance{ winrt::make_self(weak_ref(*this)) }; @@ -353,28 +345,25 @@ Json::Value Profile::ToJson() const JsonUtils::SetValueForKey(json, SourceKey, writeBasicSettings ? Source() : _Source); // TODO:MSFT:20642297 - Use a sentinel value (-1) for "Infinite scrollback" - JsonUtils::SetValueForKey(json, HistorySizeKey, _HistorySize); - JsonUtils::SetValueForKey(json, SnapOnInputKey, _SnapOnInput); - JsonUtils::SetValueForKey(json, AltGrAliasingKey, _AltGrAliasing); JsonUtils::SetValueForKey(json, TabTitleKey, _TabTitle); // Control Settings JsonUtils::SetValueForKey(json, ConnectionTypeKey, _ConnectionType); - JsonUtils::SetValueForKey(json, CommandlineKey, _Commandline); - JsonUtils::SetValueForKey(json, UseAcrylicKey, _UseAcrylic); JsonUtils::SetValueForKey(json, SuppressApplicationTitleKey, _SuppressApplicationTitle); JsonUtils::SetValueForKey(json, CloseOnExitKey, _CloseOnExit); // PermissiveStringConverter is unnecessary for serialization - JsonUtils::SetValueForKey(json, PaddingKey, _Padding); - JsonUtils::SetValueForKey(json, ScrollbarStateKey, _ScrollState); JsonUtils::SetValueForKey(json, StartingDirectoryKey, _StartingDirectory); JsonUtils::SetValueForKey(json, IconKey, _Icon); - JsonUtils::SetValueForKey(json, AntialiasingModeKey, _AntialiasingMode); JsonUtils::SetValueForKey(json, TabColorKey, _TabColor); JsonUtils::SetValueForKey(json, BellStyleKey, _BellStyle); +#define PROFILE_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) +#undef PROFILE_SETTINGS_TO_JSON + // Font settings const auto fontInfoImpl = winrt::get_self(_FontInfo); if (fontInfoImpl->HasAnyOptionSet()) diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index 9e54b0e7e73..e406e52429c 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -46,6 +46,7 @@ Author(s): #include "Profile.g.h" #include "IInheritable.h" +#include "SettingsUtils.h" #include "../inc/cppwinrt_utils.h" #include "JsonUtils.h" @@ -120,26 +121,20 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_NULLABLE_SETTING(Model::Profile, Microsoft::Terminal::Core::Color, TabColor, nullptr); INHERITABLE_SETTING(Model::Profile, bool, SuppressApplicationTitle, false); - INHERITABLE_SETTING(Model::Profile, bool, UseAcrylic, false); - INHERITABLE_SETTING(Model::Profile, Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible); - - INHERITABLE_SETTING(Model::Profile, hstring, Padding, DEFAULT_PADDING); - - INHERITABLE_SETTING(Model::Profile, hstring, Commandline, L"cmd.exe"); INHERITABLE_SETTING(Model::Profile, hstring, StartingDirectory); - INHERITABLE_SETTING(Model::Profile, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale); INHERITABLE_SETTING(Model::Profile, bool, ForceFullRepaintRendering, false); INHERITABLE_SETTING(Model::Profile, bool, SoftwareRendering, false); - INHERITABLE_SETTING(Model::Profile, int32_t, HistorySize, DEFAULT_HISTORY_SIZE); - INHERITABLE_SETTING(Model::Profile, bool, SnapOnInput, true); - INHERITABLE_SETTING(Model::Profile, bool, AltGrAliasing, true); - INHERITABLE_SETTING(Model::Profile, Model::BellStyle, BellStyle, BellStyle::Audible); INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); + #define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) + PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) + #undef PROFILE_SETTINGS_INITIALIZE + private: Model::IAppearanceConfig _DefaultAppearance{ winrt::make(weak_ref(*this)) }; Model::FontConfig _FontInfo{ winrt::make(weak_ref(*this)) }; diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h new file mode 100644 index 00000000000..89addd2a92d --- /dev/null +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -0,0 +1,52 @@ +/*++ +Copyright (c) Microsoft Corporation +Licensed under the MIT license. + +Module Name: +- SettingsUtils.h + +Abstract: +- + +Author(s): +- + +--*/ +#pragma once + +#define GLOBAL_SETTINGS(X) \ + X(int32_t, InitialRows, 30) \ + X(int32_t, InitialCols, 80) \ + X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ + X(bool, CopyOnSelect, false) \ + X(bool, FocusFollowMouse, false) \ + X(bool, ForceFullRepaintRendering, false) \ + X(bool, SoftwareRendering, false) \ + X(bool, ForceVTInput, false) \ + X(bool, TrimBlockSelection, false) \ + X(bool, DetectURLs, true) + +#define PROFILE_SETTINGS(X) \ + X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ + X(bool, SnapOnInput, true) \ + X(bool, AltGrAliasing, true) \ + X(bool, UseAcrylic, false) \ + X(hstring, Padding, DEFAULT_PADDING) \ + X(hstring, Commandline, L"cmd.exe") \ + X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ + X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) + +#define FONT_SETTINGS(X) \ + X(hstring, FontFace, DEFAULT_FONT_FACE) \ + X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ + X(winrt::Windows::UI::Text::FontWeight, FontWeight) \ + X(IFontAxesMap, FontAxes) \ + X(IFontFeatureMap, FontFeatures) + +#define APPEARANCE_SETTINGS(X) \ + X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ + X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ + X(double, BackgroundImageOpacity, 1.0) \ + X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ + X(bool, RetroTerminalEffect, false) \ + X(hstring, PixelShaderPath) diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index 187b3cedb3e..0409f738abd 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -162,8 +162,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation void TerminalSettings::_ApplyAppearanceSettings(const IAppearanceConfig& appearance, const Windows::Foundation::Collections::IMapView& schemes) { - _CursorShape = appearance.CursorShape(); - _CursorHeight = appearance.CursorHeight(); if (!appearance.ColorSchemeName().empty()) { if (const auto scheme = schemes.TryLookup(appearance.ColorSchemeName())) @@ -192,15 +190,14 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _BackgroundImage = appearance.ExpandedBackgroundImagePath(); } - _BackgroundImageOpacity = appearance.BackgroundImageOpacity(); - _BackgroundImageStretchMode = appearance.BackgroundImageStretchMode(); - std::tie(_BackgroundImageHorizontalAlignment, _BackgroundImageVerticalAlignment) = ConvertConvergedAlignment(appearance.BackgroundImageAlignment()); - - _RetroTerminalEffect = appearance.RetroTerminalEffect(); - _PixelShaderPath = winrt::hstring{ wil::ExpandEnvironmentStringsW(appearance.PixelShaderPath().c_str()) }; + #define PROFILE_APPEARANCE_SETTINGS_APPLY(type, name, ...) \ + _##name = appearance.name(); + APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_APPLY) + #undef PROFILE_APPEARANCE_SETTINGS_APPLY _IntenseIsBold = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bold); _IntenseIsBright = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bright); + std::tie(_BackgroundImageHorizontalAlignment, _BackgroundImageVerticalAlignment) = ConvertConvergedAlignment(appearance.BackgroundImageAlignment()); _Opacity = appearance.Opacity(); } @@ -267,24 +264,18 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyProfileSettings(const Profile& profile) { - // Fill in the Terminal Setting's CoreSettings from the profile - _HistorySize = profile.HistorySize(); - _SnapOnInput = profile.SnapOnInput(); - _AltGrAliasing = profile.AltGrAliasing(); + #define PROFILE_SETTINGS_APPLY(type, name, ...) \ + _##name = profile.name(); + PROFILE_SETTINGS(PROFILE_SETTINGS_APPLY) + #undef PROFILE_SETTINGS_APPLY + + #define PROFILE_FONT_SETTINGS_APPLY(type, name, ...) \ + _##name = profile.FontInfo().name(); + FONT_SETTINGS(PROFILE_FONT_SETTINGS_APPLY) + #undef PROFILE_FONT_SETTINGS_APPLY // Fill in the remaining properties from the profile _ProfileName = profile.Name(); - _UseAcrylic = profile.UseAcrylic(); - - _FontFace = profile.FontInfo().FontFace(); - _FontSize = profile.FontInfo().FontSize(); - _FontWeight = profile.FontInfo().FontWeight(); - _FontFeatures = profile.FontInfo().FontFeatures(); - _FontAxes = profile.FontInfo().FontAxes(); - _Padding = profile.Padding(); - - _Commandline = profile.Commandline(); - _StartingDirectory = profile.EvaluatedStartingDirectory(); // GH#2373: Use the tabTitle as the starting title if it exists, otherwise @@ -296,10 +287,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _SuppressApplicationTitle = profile.SuppressApplicationTitle(); } - _ScrollState = profile.ScrollState(); - - _AntialiasingMode = profile.AntialiasingMode(); - if (profile.TabColor()) { const til::color colorRef{ profile.TabColor().Value() }; @@ -315,17 +302,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyGlobalSettings(const Model::GlobalAppSettings& globalSettings) noexcept { - _InitialRows = globalSettings.InitialRows(); - _InitialCols = globalSettings.InitialCols(); - - _WordDelimiters = globalSettings.WordDelimiters(); - _CopyOnSelect = globalSettings.CopyOnSelect(); - _FocusFollowMouse = globalSettings.FocusFollowMouse(); - _ForceFullRepaintRendering = globalSettings.ForceFullRepaintRendering(); - _SoftwareRendering = globalSettings.SoftwareRendering(); - _ForceVTInput = globalSettings.ForceVTInput(); - _TrimBlockSelection = globalSettings.TrimBlockSelection(); - _DetectURLs = globalSettings.DetectURLs(); + #define GLOBAL_SETTINGS_APPLY(type, name, ...) \ + _##name = globalSettings.name(); + GLOBAL_SETTINGS(GLOBAL_SETTINGS_APPLY) + #undef GLOBAL_SETTINGS_APPLY } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 1c27f689ea8..da60d9a27da 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -17,6 +17,7 @@ Author(s): #include "TerminalSettings.g.h" #include "TerminalSettingsCreateResult.g.h" #include "IInheritable.h" +#include "SettingsUtils.h" #include "../inc/cppwinrt_utils.h" #include #include @@ -84,21 +85,29 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, til::color, DefaultForeground, DEFAULT_FOREGROUND); INHERITABLE_SETTING(Model::TerminalSettings, til::color, DefaultBackground, DEFAULT_BACKGROUND); INHERITABLE_SETTING(Model::TerminalSettings, til::color, SelectionBackground, DEFAULT_FOREGROUND); - INHERITABLE_SETTING(Model::TerminalSettings, int32_t, HistorySize, DEFAULT_HISTORY_SIZE); - INHERITABLE_SETTING(Model::TerminalSettings, int32_t, InitialRows, 30); - INHERITABLE_SETTING(Model::TerminalSettings, int32_t, InitialCols, 80); - INHERITABLE_SETTING(Model::TerminalSettings, bool, SnapOnInput, true); - INHERITABLE_SETTING(Model::TerminalSettings, bool, AltGrAliasing, true); + #define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) + #undef GLOBAL_SETTINGS_INITIALIZE + + #define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) + #undef PROFILE_SETTINGS_INITIALIZE + + #define PROFILE_FONT_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + FONT_SETTINGS(PROFILE_FONT_SETTINGS_INITIALIZE) + #undef PROFILE_FONT_SETTINGS_INITIALIZE + + #define PROFILE_APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_INITIALIZE) + #undef PROFILE_APPEARANCE_SETTINGS_INITIALIZE + INHERITABLE_SETTING(Model::TerminalSettings, til::color, CursorColor, DEFAULT_CURSOR_COLOR); - INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Core::CursorStyle, CursorShape, Core::CursorStyle::Vintage); - INHERITABLE_SETTING(Model::TerminalSettings, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); - INHERITABLE_SETTING(Model::TerminalSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); - INHERITABLE_SETTING(Model::TerminalSettings, bool, CopyOnSelect, false); INHERITABLE_SETTING(Model::TerminalSettings, bool, InputServiceWarning, true); - INHERITABLE_SETTING(Model::TerminalSettings, bool, FocusFollowMouse, false); - INHERITABLE_SETTING(Model::TerminalSettings, bool, TrimBlockSelection, false); - INHERITABLE_SETTING(Model::TerminalSettings, bool, DetectURLs, true); INHERITABLE_SETTING(Model::TerminalSettings, Windows::Foundation::IReference, TabColor, nullptr); @@ -117,42 +126,21 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // ------------------------ End of Core Settings ----------------------- INHERITABLE_SETTING(Model::TerminalSettings, hstring, ProfileName); - INHERITABLE_SETTING(Model::TerminalSettings, bool, UseAcrylic, false); INHERITABLE_SETTING(Model::TerminalSettings, double, Opacity, UseAcrylic() ? 0.5 : 1.0); - INHERITABLE_SETTING(Model::TerminalSettings, hstring, Padding, DEFAULT_PADDING); - INHERITABLE_SETTING(Model::TerminalSettings, hstring, FontFace, DEFAULT_FONT_FACE); - INHERITABLE_SETTING(Model::TerminalSettings, int32_t, FontSize, DEFAULT_FONT_SIZE); - - INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Text::FontWeight, FontWeight); - INHERITABLE_SETTING(Model::TerminalSettings, IFontAxesMap, FontAxes); - INHERITABLE_SETTING(Model::TerminalSettings, IFontFeatureMap, FontFeatures); INHERITABLE_SETTING(Model::TerminalSettings, Model::ColorScheme, AppliedColorScheme); INHERITABLE_SETTING(Model::TerminalSettings, hstring, BackgroundImage); - INHERITABLE_SETTING(Model::TerminalSettings, double, BackgroundImageOpacity, 1.0); - INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill); INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center); INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center); INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::IKeyBindings, KeyBindings, nullptr); - INHERITABLE_SETTING(Model::TerminalSettings, hstring, Commandline); INHERITABLE_SETTING(Model::TerminalSettings, hstring, StartingDirectory); INHERITABLE_SETTING(Model::TerminalSettings, hstring, StartingTitle); INHERITABLE_SETTING(Model::TerminalSettings, bool, SuppressApplicationTitle); INHERITABLE_SETTING(Model::TerminalSettings, hstring, EnvironmentVariables); - INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible); - - INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale); - - INHERITABLE_SETTING(Model::TerminalSettings, bool, RetroTerminalEffect, false); - INHERITABLE_SETTING(Model::TerminalSettings, bool, ForceFullRepaintRendering, false); - INHERITABLE_SETTING(Model::TerminalSettings, bool, SoftwareRendering, false); - INHERITABLE_SETTING(Model::TerminalSettings, bool, ForceVTInput, false); - - INHERITABLE_SETTING(Model::TerminalSettings, hstring, PixelShaderPath); INHERITABLE_SETTING(Model::TerminalSettings, bool, IntenseIsBold); private: From f8f16f64551d4712e390d672d2cefbcfcc7dd57f Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 4 Oct 2021 15:56:22 -0700 Subject: [PATCH 02/15] format --- .../AppearanceConfig.cpp | 6 +-- .../TerminalSettingsModel/AppearanceConfig.h | 8 ++-- .../GlobalAppSettings.cpp | 4 +- .../TerminalSettingsModel/GlobalAppSettings.h | 8 ++-- .../TerminalSettingsModel/Profile.cpp | 6 +-- src/cascadia/TerminalSettingsModel/Profile.h | 8 ++-- .../TerminalSettings.cpp | 32 ++++++++-------- .../TerminalSettingsModel/TerminalSettings.h | 38 +++++++++---------- 8 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index e2c63d63412..00d4a308acf 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -49,7 +49,7 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan #define APPEARANCE_SETTINGS_COPY(type, name, ...) \ appearance->_##name = source->_##name; - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) #undef APPEARANCE_SETTINGS_COPY return appearance; @@ -71,7 +71,7 @@ Json::Value AppearanceConfig::ToJson() const #define APPEARANCE_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) #undef APPEARANCE_SETTINGS_TO_JSON return json; @@ -103,7 +103,7 @@ void AppearanceConfig::LayerJson(const Json::Value& json) #define APPEARANCE_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) #undef APPEARANCE_SETTINGS_LAYER_JSON } diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index aecf6233c46..da909a6f409 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -48,10 +48,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::IAppearanceConfig, Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright); INHERITABLE_SETTING(Model::IAppearanceConfig, double, Opacity, 1.0); - #define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) - #undef APPEARANCE_SETTINGS_INITIALIZE +#define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) +#undef APPEARANCE_SETTINGS_INITIALIZE private: winrt::weak_ref _sourceProfile; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 963bc12d1ca..85cbc7575ae 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -122,7 +122,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const #define GLOBAL_SETTINGS_COPY(type, name, ...) \ globals->_##name = _##name; - GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) + GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) #undef GLOBAL_SETTINGS_COPY if (_colorSchemes) @@ -219,7 +219,7 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) #define GLOBAL_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) + GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) #undef GLOBAL_SETTINGS_LAYER_JSON static constexpr std::array bindingsKeys{ LegacyKeybindingsKey, ActionsKey }; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 7ffe5021522..5d7104a70e7 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -92,10 +92,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, UnparsedDefaultProfile, L""); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowAdminShield, true); - #define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) - GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) - #undef GLOBAL_SETTINGS_INITIALIZE +#define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) + GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) +#undef GLOBAL_SETTINGS_INITIALIZE private: #ifdef NDEBUG diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index c6c9288b1c9..1ac8735d5d1 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -133,7 +133,7 @@ winrt::com_ptr Profile::CopySettings() const #define PROFILE_SETTINGS_COPY(type, name, ...) \ profile->_##name = _##name; - PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) + PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) #undef PROFILE_SETTINGS_COPY if (_UnfocusedAppearance) @@ -211,7 +211,7 @@ void Profile::LayerJson(const Json::Value& json) #define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) + PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) #undef PROFILE_SETTINGS_LAYER_JSON if (json.isMember(JsonKey(UnfocusedAppearanceKey))) @@ -361,7 +361,7 @@ Json::Value Profile::ToJson() const #define PROFILE_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) + PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) #undef PROFILE_SETTINGS_TO_JSON // Font settings diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index e406e52429c..59a99377f5b 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -130,10 +130,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); - #define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) - #undef PROFILE_SETTINGS_INITIALIZE +#define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) + PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) +#undef PROFILE_SETTINGS_INITIALIZE private: Model::IAppearanceConfig _DefaultAppearance{ winrt::make(weak_ref(*this)) }; diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index 0409f738abd..76195a89e07 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -190,10 +190,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _BackgroundImage = appearance.ExpandedBackgroundImagePath(); } - #define PROFILE_APPEARANCE_SETTINGS_APPLY(type, name, ...) \ - _##name = appearance.name(); - APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_APPLY) - #undef PROFILE_APPEARANCE_SETTINGS_APPLY +#define PROFILE_APPEARANCE_SETTINGS_APPLY(type, name, ...) \ + _##name = appearance.name(); + APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_APPLY) +#undef PROFILE_APPEARANCE_SETTINGS_APPLY _IntenseIsBold = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bold); _IntenseIsBright = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bright); @@ -264,15 +264,15 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyProfileSettings(const Profile& profile) { - #define PROFILE_SETTINGS_APPLY(type, name, ...) \ - _##name = profile.name(); - PROFILE_SETTINGS(PROFILE_SETTINGS_APPLY) - #undef PROFILE_SETTINGS_APPLY +#define PROFILE_SETTINGS_APPLY(type, name, ...) \ + _##name = profile.name(); + PROFILE_SETTINGS(PROFILE_SETTINGS_APPLY) +#undef PROFILE_SETTINGS_APPLY - #define PROFILE_FONT_SETTINGS_APPLY(type, name, ...) \ - _##name = profile.FontInfo().name(); - FONT_SETTINGS(PROFILE_FONT_SETTINGS_APPLY) - #undef PROFILE_FONT_SETTINGS_APPLY +#define PROFILE_FONT_SETTINGS_APPLY(type, name, ...) \ + _##name = profile.FontInfo().name(); + FONT_SETTINGS(PROFILE_FONT_SETTINGS_APPLY) +#undef PROFILE_FONT_SETTINGS_APPLY // Fill in the remaining properties from the profile _ProfileName = profile.Name(); @@ -302,10 +302,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyGlobalSettings(const Model::GlobalAppSettings& globalSettings) noexcept { - #define GLOBAL_SETTINGS_APPLY(type, name, ...) \ - _##name = globalSettings.name(); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_APPLY) - #undef GLOBAL_SETTINGS_APPLY +#define GLOBAL_SETTINGS_APPLY(type, name, ...) \ + _##name = globalSettings.name(); + GLOBAL_SETTINGS(GLOBAL_SETTINGS_APPLY) +#undef GLOBAL_SETTINGS_APPLY } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index da60d9a27da..0cec6f45d6c 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -86,25 +86,25 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, til::color, DefaultBackground, DEFAULT_BACKGROUND); INHERITABLE_SETTING(Model::TerminalSettings, til::color, SelectionBackground, DEFAULT_FOREGROUND); - #define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) - #undef GLOBAL_SETTINGS_INITIALIZE - - #define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) - #undef PROFILE_SETTINGS_INITIALIZE - - #define PROFILE_FONT_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - FONT_SETTINGS(PROFILE_FONT_SETTINGS_INITIALIZE) - #undef PROFILE_FONT_SETTINGS_INITIALIZE - - #define PROFILE_APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_INITIALIZE) - #undef PROFILE_APPEARANCE_SETTINGS_INITIALIZE +#define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) +#undef GLOBAL_SETTINGS_INITIALIZE + +#define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) +#undef PROFILE_SETTINGS_INITIALIZE + +#define PROFILE_FONT_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + FONT_SETTINGS(PROFILE_FONT_SETTINGS_INITIALIZE) +#undef PROFILE_FONT_SETTINGS_INITIALIZE + +#define PROFILE_APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) + APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_INITIALIZE) +#undef PROFILE_APPEARANCE_SETTINGS_INITIALIZE INHERITABLE_SETTING(Model::TerminalSettings, til::color, CursorColor, DEFAULT_CURSOR_COLOR); INHERITABLE_SETTING(Model::TerminalSettings, bool, InputServiceWarning, true); From b1d474c33d19d09b7f7b26c7e2e89d764ceac8ac Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 6 Oct 2021 14:51:40 -0700 Subject: [PATCH 03/15] app settings --- .../AppearanceConfig.cpp | 52 ++++---- .../TerminalSettingsModel/AppearanceConfig.h | 16 +-- .../GlobalAppSettings.cpp | 126 ++++-------------- .../TerminalSettingsModel/GlobalAppSettings.h | 39 ++---- .../TerminalSettingsModel/Profile.cpp | 83 +++++------- src/cascadia/TerminalSettingsModel/Profile.h | 35 +++-- .../TerminalSettingsModel/SettingsUtils.h | 52 +++++++- .../TerminalSettings.cpp | 18 +-- .../TerminalSettingsModel/TerminalSettings.h | 18 +-- 9 files changed, 182 insertions(+), 257 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index 00d4a308acf..03154cff6b6 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -18,8 +18,8 @@ static constexpr std::string_view SelectionBackgroundKey{ "selectionBackground" static constexpr std::string_view CursorColorKey{ "cursorColor" }; static constexpr std::string_view CursorShapeKey{ "cursorShape" }; static constexpr std::string_view CursorHeightKey{ "cursorHeight" }; -static constexpr std::string_view BackgroundImageKey{ "backgroundImage" }; -static constexpr std::string_view ColorSchemeKey{ "colorScheme" }; +static constexpr std::string_view BackgroundImagePathKey{ "backgroundImage" }; +static constexpr std::string_view ColorSchemeNameKey{ "colorScheme" }; static constexpr std::string_view BackgroundImageOpacityKey{ "backgroundImageOpacity" }; static constexpr std::string_view BackgroundImageStretchModeKey{ "backgroundImageStretchMode" }; static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageAlignment" }; @@ -37,20 +37,20 @@ AppearanceConfig::AppearanceConfig(winrt::weak_ref sourceProfile) : winrt::com_ptr AppearanceConfig::CopyAppearance(const AppearanceConfig* source, winrt::weak_ref sourceProfile) { auto appearance{ winrt::make_self(std::move(sourceProfile)) }; - appearance->_BackgroundImagePath = source->_BackgroundImagePath; - appearance->_ColorSchemeName = source->_ColorSchemeName; appearance->_Foreground = source->_Foreground; appearance->_Background = source->_Background; appearance->_SelectionBackground = source->_SelectionBackground; appearance->_CursorColor = source->_CursorColor; - appearance->_BackgroundImageAlignment = source->_BackgroundImageAlignment; - appearance->_IntenseTextStyle = source->_IntenseTextStyle; - appearance->_Opacity = source->_Opacity; -#define APPEARANCE_SETTINGS_COPY(type, name, ...) \ +#define APPEARANCE_APP_SETTINGS_COPY(type, name, ...) \ appearance->_##name = source->_##name; - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) -#undef APPEARANCE_SETTINGS_COPY + APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_COPY) +#undef APPEARANCE_APP_SETTINGS_COPY + +#define APPEARANCE_CONTROL_SETTINGS_COPY(type, name, ...) \ + appearance->_##name = source->_##name; + APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_COPY) +#undef APPEARANCE_CONTROL_SETTINGS_COPY return appearance; } @@ -63,16 +63,16 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, BackgroundKey, _Background); JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor); - JsonUtils::SetValueForKey(json, ColorSchemeKey, _ColorSchemeName); - JsonUtils::SetValueForKey(json, BackgroundImageKey, _BackgroundImagePath); - JsonUtils::SetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); - JsonUtils::SetValueForKey(json, IntenseTextStyleKey, _IntenseTextStyle); - JsonUtils::SetValueForKey(json, OpacityKey, _Opacity, JsonUtils::OptionalConverter{}); -#define APPEARANCE_SETTINGS_TO_JSON(type, name, ...) \ +#define APPEARANCE_APP_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_TO_JSON) +#undef APPEARANCE_APP_SETTINGS_TO_JSON + +#define APPEARANCE_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) -#undef APPEARANCE_SETTINGS_TO_JSON + APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_TO_JSON) +#undef APPEARANCE_CONTROL_SETTINGS_TO_JSON return json; } @@ -94,17 +94,17 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, BackgroundKey, _Background); JsonUtils::GetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::GetValueForKey(json, CursorColorKey, _CursorColor); - JsonUtils::GetValueForKey(json, ColorSchemeKey, _ColorSchemeName); - JsonUtils::GetValueForKey(json, BackgroundImageKey, _BackgroundImagePath); - JsonUtils::GetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); - JsonUtils::GetValueForKey(json, IntenseTextStyleKey, _IntenseTextStyle); JsonUtils::GetValueForKey(json, LegacyAcrylicTransparencyKey, _Opacity); - JsonUtils::GetValueForKey(json, OpacityKey, _Opacity, JsonUtils::OptionalConverter{}); -#define APPEARANCE_SETTINGS_LAYER_JSON(type, name, ...) \ +#define APPEARANCE_APP_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_LAYER_JSON) +#undef APPEARANCE_APP_SETTINGS_LAYER_JSON + +#define APPEARANCE_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) -#undef APPEARANCE_SETTINGS_LAYER_JSON + APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_LAYER_JSON) +#undef APPEARANCE_CONTROL_SETTINGS_LAYER_JSON } winrt::Microsoft::Terminal::Settings::Model::Profile AppearanceConfig::SourceProfile() diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index da909a6f409..78bd049228c 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -36,22 +36,20 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation winrt::hstring ExpandedBackgroundImagePath(); - INHERITABLE_SETTING(Model::IAppearanceConfig, ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center); - - INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, ColorSchemeName, L"Campbell"); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Foreground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Background, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); - INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, BackgroundImagePath); - INHERITABLE_SETTING(Model::IAppearanceConfig, Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright); - INHERITABLE_SETTING(Model::IAppearanceConfig, double, Opacity, 1.0); +#define APPEARANCE_APP_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) + APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_INITIALIZE) +#undef APPEARANCE_APP_SETTINGS_INITIALIZE -#define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) -#undef APPEARANCE_SETTINGS_INITIALIZE + APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_INITIALIZE) +#undef APPEARANCE_CONTROL_SETTINGS_INITIALIZE private: winrt::weak_ref _sourceProfile; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 85cbc7575ae..0fa34a7da39 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -36,9 +36,9 @@ static constexpr std::string_view CopyFormattingKey{ "copyFormatting" }; static constexpr std::string_view WarnAboutLargePasteKey{ "largePasteWarning" }; static constexpr std::string_view WarnAboutMultiLinePasteKey{ "multiLinePasteWarning" }; static constexpr std::string_view LaunchModeKey{ "launchMode" }; -static constexpr std::string_view ConfirmCloseAllKey{ "confirmCloseAllTabs" }; +static constexpr std::string_view ConfirmCloseAllTabsKey{ "confirmCloseAllTabs" }; static constexpr std::string_view SnapToGridOnResizeKey{ "snapToGridOnResize" }; -static constexpr std::string_view EnableStartupTaskKey{ "startOnUserLogin" }; +static constexpr std::string_view StartOnUserLoginKey{ "startOnUserLogin" }; static constexpr std::string_view FirstWindowPreferenceKey{ "firstWindowPreference" }; static constexpr std::string_view AlwaysOnTopKey{ "alwaysOnTop" }; static constexpr std::string_view LegacyUseTabSwitcherModeKey{ "useTabSwitcher" }; @@ -53,7 +53,7 @@ static constexpr std::string_view MinimizeToNotificationAreaKey{ "minimizeToNoti static constexpr std::string_view DisabledProfileSourcesKey{ "disabledProfileSources" }; static constexpr std::string_view ShowAdminShieldKey{ "showAdminShield" }; -static constexpr std::string_view DebugFeaturesKey{ "debugFeatures" }; +static constexpr std::string_view DebugFeaturesEnabledKey{ "debugFeatures" }; static constexpr std::string_view ForceFullRepaintRenderingKey{ "experimental.rendering.forceFullRepaint" }; static constexpr std::string_view SoftwareRenderingKey{ "experimental.rendering.software" }; @@ -85,45 +85,21 @@ void GlobalAppSettings::_FinalizeInheritance() winrt::com_ptr GlobalAppSettings::Copy() const { auto globals{ winrt::make_self() }; - globals->_AlwaysShowTabs = _AlwaysShowTabs; - globals->_ShowTitleInTitlebar = _ShowTitleInTitlebar; - globals->_ConfirmCloseAllTabs = _ConfirmCloseAllTabs; - globals->_Language = _Language; - globals->_Theme = _Theme; - globals->_TabWidthMode = _TabWidthMode; - globals->_UseAcrylicInTabRow = _UseAcrylicInTabRow; - globals->_ShowTabsInTitlebar = _ShowTabsInTitlebar; - globals->_InputServiceWarning = _InputServiceWarning; - globals->_CopyFormatting = _CopyFormatting; - globals->_WarnAboutLargePaste = _WarnAboutLargePaste; - globals->_WarnAboutMultiLinePaste = _WarnAboutMultiLinePaste; - globals->_InitialPosition = _InitialPosition; - globals->_CenterOnLaunch = _CenterOnLaunch; - globals->_LaunchMode = _LaunchMode; - globals->_SnapToGridOnResize = _SnapToGridOnResize; - globals->_DebugFeaturesEnabled = _DebugFeaturesEnabled; - globals->_StartOnUserLogin = _StartOnUserLogin; - globals->_FirstWindowPreference = _FirstWindowPreference; - globals->_AlwaysOnTop = _AlwaysOnTop; - globals->_TabSwitcherMode = _TabSwitcherMode; - globals->_DisableAnimations = _DisableAnimations; - globals->_StartupActions = _StartupActions; - globals->_WindowingBehavior = _WindowingBehavior; - globals->_MinimizeToNotificationArea = _MinimizeToNotificationArea; - globals->_AlwaysShowNotificationIcon = _AlwaysShowNotificationIcon; - globals->_DisabledProfileSources = _DisabledProfileSources; - globals->_ShowAdminShield = _ShowAdminShield; - globals->_UnparsedDefaultProfile = _UnparsedDefaultProfile; globals->_defaultProfile = _defaultProfile; globals->_actionMap = _actionMap->Copy(); globals->_keybindingsWarnings = _keybindingsWarnings; -#define GLOBAL_SETTINGS_COPY(type, name, ...) \ +#define GLOBAL_APP_SETTINGS_COPY(type, name, ...) \ + globals->_##name = _##name; + GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_COPY) +#undef GLOBAL_APP_SETTINGS_COPY + +#define GLOBAL_CONTROL_SETTINGS_COPY(type, name, ...) \ globals->_##name = _##name; - GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) -#undef GLOBAL_SETTINGS_COPY + GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_COPY) +#undef GLOBAL_CONTROL_SETTINGS_COPY if (_colorSchemes) { @@ -182,45 +158,20 @@ winrt::com_ptr GlobalAppSettings::FromJson(const Json::Value& void GlobalAppSettings::LayerJson(const Json::Value& json) { JsonUtils::GetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); - JsonUtils::GetValueForKey(json, AlwaysShowTabsKey, _AlwaysShowTabs); - JsonUtils::GetValueForKey(json, ConfirmCloseAllKey, _ConfirmCloseAllTabs); - JsonUtils::GetValueForKey(json, InitialPositionKey, _InitialPosition); - JsonUtils::GetValueForKey(json, CenterOnLaunchKey, _CenterOnLaunch); - JsonUtils::GetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); - JsonUtils::GetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); - JsonUtils::GetValueForKey(json, InputServiceWarningKey, _InputServiceWarning); - JsonUtils::GetValueForKey(json, CopyFormattingKey, _CopyFormatting); - JsonUtils::GetValueForKey(json, WarnAboutLargePasteKey, _WarnAboutLargePaste); - JsonUtils::GetValueForKey(json, WarnAboutMultiLinePasteKey, _WarnAboutMultiLinePaste); - JsonUtils::GetValueForKey(json, FirstWindowPreferenceKey, _FirstWindowPreference); - JsonUtils::GetValueForKey(json, LaunchModeKey, _LaunchMode); - JsonUtils::GetValueForKey(json, LanguageKey, _Language); - JsonUtils::GetValueForKey(json, ThemeKey, _Theme); - JsonUtils::GetValueForKey(json, TabWidthModeKey, _TabWidthMode); - JsonUtils::GetValueForKey(json, UseAcrylicInTabRowKey, _UseAcrylicInTabRow); - JsonUtils::GetValueForKey(json, SnapToGridOnResizeKey, _SnapToGridOnResize); - // GetValueForKey will only override the current value if the key exists - JsonUtils::GetValueForKey(json, DebugFeaturesKey, _DebugFeaturesEnabled); - JsonUtils::GetValueForKey(json, EnableStartupTaskKey, _StartOnUserLogin); - JsonUtils::GetValueForKey(json, AlwaysOnTopKey, _AlwaysOnTop); // GH#8076 - when adding enum values to this key, we also changed it from // "useTabSwitcher" to "tabSwitcherMode". Continue supporting // "useTabSwitcher", but prefer "tabSwitcherMode" JsonUtils::GetValueForKey(json, LegacyUseTabSwitcherModeKey, _TabSwitcherMode); - JsonUtils::GetValueForKey(json, TabSwitcherModeKey, _TabSwitcherMode); - JsonUtils::GetValueForKey(json, DisableAnimationsKey, _DisableAnimations); - JsonUtils::GetValueForKey(json, StartupActionsKey, _StartupActions); - JsonUtils::GetValueForKey(json, WindowingBehaviorKey, _WindowingBehavior); - JsonUtils::GetValueForKey(json, MinimizeToNotificationAreaKey, _MinimizeToNotificationArea); - JsonUtils::GetValueForKey(json, AlwaysShowNotificationIconKey, _AlwaysShowNotificationIcon); - JsonUtils::GetValueForKey(json, DisabledProfileSourcesKey, _DisabledProfileSources); - JsonUtils::GetValueForKey(json, ShowAdminShieldKey, _ShowAdminShield); +#define GLOBAL_APP_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_LAYER_JSON) +#undef GLOBAL_APP_SETTINGS_LAYER_JSON -#define GLOBAL_SETTINGS_LAYER_JSON(type, name, ...) \ +#define GLOBAL_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) -#undef GLOBAL_SETTINGS_LAYER_JSON + GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_LAYER_JSON) +#undef GLOBAL_CONTROL_SETTINGS_LAYER_JSON static constexpr std::array bindingsKeys{ LegacyKeybindingsKey, ActionsKey }; for (const auto& jsonKey : bindingsKeys) @@ -282,39 +233,16 @@ Json::Value GlobalAppSettings::ToJson() const // clang-format off JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); - JsonUtils::SetValueForKey(json, AlwaysShowTabsKey, _AlwaysShowTabs); - JsonUtils::SetValueForKey(json, ConfirmCloseAllKey, _ConfirmCloseAllTabs); - JsonUtils::SetValueForKey(json, InitialPositionKey, _InitialPosition); - JsonUtils::SetValueForKey(json, CenterOnLaunchKey, _CenterOnLaunch); - JsonUtils::SetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); - JsonUtils::SetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); - JsonUtils::SetValueForKey(json, InputServiceWarningKey, _InputServiceWarning); - JsonUtils::SetValueForKey(json, CopyFormattingKey, _CopyFormatting); - JsonUtils::SetValueForKey(json, WarnAboutLargePasteKey, _WarnAboutLargePaste); - JsonUtils::SetValueForKey(json, WarnAboutMultiLinePasteKey, _WarnAboutMultiLinePaste); - JsonUtils::SetValueForKey(json, FirstWindowPreferenceKey, _FirstWindowPreference); - JsonUtils::SetValueForKey(json, LaunchModeKey, _LaunchMode); - JsonUtils::SetValueForKey(json, LanguageKey, _Language); - JsonUtils::SetValueForKey(json, ThemeKey, _Theme); - JsonUtils::SetValueForKey(json, TabWidthModeKey, _TabWidthMode); - JsonUtils::SetValueForKey(json, UseAcrylicInTabRowKey, _UseAcrylicInTabRow); - JsonUtils::SetValueForKey(json, SnapToGridOnResizeKey, _SnapToGridOnResize); - JsonUtils::SetValueForKey(json, DebugFeaturesKey, _DebugFeaturesEnabled); - JsonUtils::SetValueForKey(json, EnableStartupTaskKey, _StartOnUserLogin); - JsonUtils::SetValueForKey(json, AlwaysOnTopKey, _AlwaysOnTop); - JsonUtils::SetValueForKey(json, TabSwitcherModeKey, _TabSwitcherMode); - JsonUtils::SetValueForKey(json, DisableAnimationsKey, _DisableAnimations); - JsonUtils::SetValueForKey(json, StartupActionsKey, _StartupActions); - JsonUtils::SetValueForKey(json, WindowingBehaviorKey, _WindowingBehavior); - JsonUtils::SetValueForKey(json, MinimizeToNotificationAreaKey, _MinimizeToNotificationArea); - JsonUtils::SetValueForKey(json, AlwaysShowNotificationIconKey, _AlwaysShowNotificationIcon); - JsonUtils::SetValueForKey(json, DisabledProfileSourcesKey, _DisabledProfileSources); - JsonUtils::SetValueForKey(json, ShowAdminShieldKey, _ShowAdminShield); - -#define GLOBAL_SETTINGS_TO_JSON(type, name, ...) \ + +#define GLOBAL_APP_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_TO_JSON) +#undef GLOBAL_APP_SETTINGS_TO_JSON + +#define GLOBAL_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) -#undef GLOBAL_SETTINGS_TO_JSON + GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_TO_JSON) +#undef GLOBAL_CONTROL_SETTINGS_TO_JSON // clang-format on json[JsonKey(ActionsKey)] = _actionMap->ToJson(); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 5d7104a70e7..d7b813537a3 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -62,40 +62,17 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DisableAnimations(!invertedDisableAnimationsValue); } - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowTitleInTitlebar, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ConfirmCloseAllTabs, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, Language); - INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default); - INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, UseAcrylicInTabRow, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowTabsInTitlebar, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, InputServiceWarning, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, WarnAboutLargePaste, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, WarnAboutMultiLinePaste, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, Model::LaunchPosition, InitialPosition, nullptr, nullptr); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, CenterOnLaunch, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, Model::FirstWindowPreference, FirstWindowPreference, FirstWindowPreference::DefaultProfile); - INHERITABLE_SETTING(Model::GlobalAppSettings, Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, SnapToGridOnResize, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, DebugFeaturesEnabled, debugFeaturesDefault); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, StartOnUserLogin, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysOnTop, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, DisableAnimations, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, StartupActions, L""); - INHERITABLE_SETTING(Model::GlobalAppSettings, Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, MinimizeToNotificationArea, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowNotificationIcon, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr); INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, UnparsedDefaultProfile, L""); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, ShowAdminShield, true); -#define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ +#define GLOBAL_APP_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) - GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) -#undef GLOBAL_SETTINGS_INITIALIZE + GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_INITIALIZE) +#undef GLOBAL_APP_SETTINGS_INITIALIZE + +#define GLOBAL_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) + GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_INITIALIZE) +#undef GLOBAL_CONTROL_SETTINGS_INITIALIZE private: #ifdef NDEBUG diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index 1ac8735d5d1..ada33bdc5da 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -111,30 +111,28 @@ winrt::com_ptr Profile::CopySettings() const const auto fontInfo = FontConfig::CopyFontInfo(winrt::get_self(_FontInfo), weakProfile); const auto defaultAppearance = AppearanceConfig::CopyAppearance(winrt::get_self(_DefaultAppearance), weakProfile); - profile->_Deleted = _Deleted; - profile->_Updates = _Updates; - profile->_Guid = _Guid; profile->_Name = _Name; profile->_Source = _Source; profile->_Hidden = _Hidden; - profile->_Icon = _Icon; - profile->_CloseOnExit = _CloseOnExit; - profile->_TabTitle = _TabTitle; + profile->_DefaultAppearance = *defaultAppearance; + profile->_Deleted = _Deleted; + profile->_Updates = _Updates; + profile->_Origin = _Origin; + profile->_Guid = _Guid; profile->_TabColor = _TabColor; - profile->_SuppressApplicationTitle = _SuppressApplicationTitle; - profile->_StartingDirectory = _StartingDirectory; + profile->_FontInfo = *fontInfo; profile->_ForceFullRepaintRendering = _ForceFullRepaintRendering; profile->_SoftwareRendering = _SoftwareRendering; - profile->_BellStyle = _BellStyle; - profile->_ConnectionType = _ConnectionType; - profile->_Origin = _Origin; - profile->_FontInfo = *fontInfo; - profile->_DefaultAppearance = *defaultAppearance; -#define PROFILE_SETTINGS_COPY(type, name, ...) \ +#define PROFILE_APP_SETTINGS_COPY(type, name, ...) \ profile->_##name = _##name; - PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) -#undef PROFILE_SETTINGS_COPY + PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_COPY) +#undef PROFILE_APP_SETTINGS_COPY + +#define PROFILE_CONTROL_SETTINGS_COPY(type, name, ...) \ + profile->_##name = _##name; + PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_COPY) +#undef PROFILE_CONTROL_SETTINGS_COPY if (_UnfocusedAppearance) { @@ -188,31 +186,21 @@ void Profile::LayerJson(const Json::Value& json) // Profile-specific Settings JsonUtils::GetValueForKey(json, NameKey, _Name); + JsonUtils::GetValueForKey(json, SourceKey, _Source); + JsonUtils::GetValueForKey(json, HiddenKey, _Hidden); JsonUtils::GetValueForKey(json, UpdatesKey, _Updates); JsonUtils::GetValueForKey(json, GuidKey, _Guid); - JsonUtils::GetValueForKey(json, HiddenKey, _Hidden); - JsonUtils::GetValueForKey(json, SourceKey, _Source); - - // TODO:MSFT:20642297 - Use a sentinel value (-1) for "Infinite scrollback" - JsonUtils::GetValueForKey(json, TabTitleKey, _TabTitle); - - // Control Settings - JsonUtils::GetValueForKey(json, ConnectionTypeKey, _ConnectionType); - JsonUtils::GetValueForKey(json, SuppressApplicationTitleKey, _SuppressApplicationTitle); - JsonUtils::GetValueForKey(json, CloseOnExitKey, _CloseOnExit); - - // Padding was never specified as an integer, but it was a common working mistake. - // Allow it to be permissive. - JsonUtils::GetValueForKey(json, StartingDirectoryKey, _StartingDirectory); - - JsonUtils::GetValueForKey(json, IconKey, _Icon); JsonUtils::GetValueForKey(json, TabColorKey, _TabColor); - JsonUtils::GetValueForKey(json, BellStyleKey, _BellStyle); -#define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ +#define PROFILE_APP_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) -#undef PROFILE_SETTINGS_LAYER_JSON + PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_LAYER_JSON) +#undef PROFILE_APP_SETTINGS_LAYER_JSON + +#define PROFILE_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_LAYER_JSON) +#undef PROFILE_CONTROL_SETTINGS_LAYER_JSON if (json.isMember(JsonKey(UnfocusedAppearanceKey))) { @@ -344,25 +332,18 @@ Json::Value Profile::ToJson() const JsonUtils::SetValueForKey(json, HiddenKey, writeBasicSettings ? Hidden() : _Hidden); JsonUtils::SetValueForKey(json, SourceKey, writeBasicSettings ? Source() : _Source); - // TODO:MSFT:20642297 - Use a sentinel value (-1) for "Infinite scrollback" - JsonUtils::SetValueForKey(json, TabTitleKey, _TabTitle); - - // Control Settings - JsonUtils::SetValueForKey(json, ConnectionTypeKey, _ConnectionType); - JsonUtils::SetValueForKey(json, SuppressApplicationTitleKey, _SuppressApplicationTitle); - JsonUtils::SetValueForKey(json, CloseOnExitKey, _CloseOnExit); - // PermissiveStringConverter is unnecessary for serialization - - JsonUtils::SetValueForKey(json, StartingDirectoryKey, _StartingDirectory); - JsonUtils::SetValueForKey(json, IconKey, _Icon); JsonUtils::SetValueForKey(json, TabColorKey, _TabColor); - JsonUtils::SetValueForKey(json, BellStyleKey, _BellStyle); -#define PROFILE_SETTINGS_TO_JSON(type, name, ...) \ +#define PROFILE_APP_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_TO_JSON) +#undef PROFILE_APP_SETTINGS_TO_JSON + +#define PROFILE_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) -#undef PROFILE_SETTINGS_TO_JSON + PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_TO_JSON) +#undef PROFILE_CONTROL_SETTINGS_TO_JSON // Font settings const auto fontInfoImpl = winrt::get_self(_FontInfo); diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index 59a99377f5b..8b0dc5a842e 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -103,37 +103,32 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation void _FinalizeInheritance() override; + // Special fields WINRT_PROPERTY(bool, Deleted, false); WINRT_PROPERTY(OriginTag, Origin, OriginTag::None); - WINRT_PROPERTY(guid, Updates); - INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); - INHERITABLE_SETTING(Model::Profile, hstring, Name, L"Default"); - INHERITABLE_SETTING(Model::Profile, hstring, Source); - INHERITABLE_SETTING(Model::Profile, bool, Hidden, false); - INHERITABLE_SETTING(Model::Profile, guid, ConnectionType); - - // Default Icon: Segoe MDL2 CommandPrompt icon - INHERITABLE_SETTING(Model::Profile, hstring, Icon, L"\uE756"); - INHERITABLE_SETTING(Model::Profile, CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful); - INHERITABLE_SETTING(Model::Profile, hstring, TabTitle); + // Nullable settings INHERITABLE_NULLABLE_SETTING(Model::Profile, Microsoft::Terminal::Core::Color, TabColor, nullptr); - INHERITABLE_SETTING(Model::Profile, bool, SuppressApplicationTitle, false); - - INHERITABLE_SETTING(Model::Profile, hstring, StartingDirectory); + // Settings that cannot be put in the macro + INHERITABLE_SETTING(Model::Profile, hstring, Name, L"Default"); + INHERITABLE_SETTING(Model::Profile, hstring, Source); + INHERITABLE_SETTING(Model::Profile, bool, Hidden, false); + INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); + INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); INHERITABLE_SETTING(Model::Profile, bool, ForceFullRepaintRendering, false); INHERITABLE_SETTING(Model::Profile, bool, SoftwareRendering, false); - INHERITABLE_SETTING(Model::Profile, Model::BellStyle, BellStyle, BellStyle::Audible); - - INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); +#define PROFILE_APP_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) + PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_INITIALIZE) +#undef PROFILE_APP_SETTINGS_INITIALIZE -#define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ +#define PROFILE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) -#undef PROFILE_SETTINGS_INITIALIZE + PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_INITIALIZE) +#undef PROFILE_CONTROL_SETTINGS_INITIALIZE private: Model::IAppearanceConfig _DefaultAppearance{ winrt::make(weak_ref(*this)) }; diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index 89addd2a92d..73478ac8e38 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -14,7 +14,7 @@ Author(s): --*/ #pragma once -#define GLOBAL_SETTINGS(X) \ +#define GLOBAL_CONTROL_SETTINGS(X) \ X(int32_t, InitialRows, 30) \ X(int32_t, InitialCols, 80) \ X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ @@ -26,7 +26,37 @@ Author(s): X(bool, TrimBlockSelection, false) \ X(bool, DetectURLs, true) -#define PROFILE_SETTINGS(X) \ +#define GLOBAL_APP_SETTINGS(X) \ + X(bool, AlwaysShowTabs, true) \ + X(bool, ShowTitleInTitlebar, true) \ + X(bool, ConfirmCloseAllTabs, true) \ + X(hstring, Language) \ + X(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default) \ + X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \ + X(bool, UseAcrylicInTabRow, false) \ + X(bool, ShowTabsInTitlebar, true) \ + X(bool, InputServiceWarning, true) \ + X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0) \ + X(bool, WarnAboutLargePaste, true) \ + X(bool, WarnAboutMultiLinePaste, true) \ + X(Model::LaunchPosition, InitialPosition, nullptr, nullptr) \ + X(bool, CenterOnLaunch, false) \ + X(Model::FirstWindowPreference, FirstWindowPreference, FirstWindowPreference::DefaultProfile) \ + X(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode) \ + X(bool, SnapToGridOnResize, true) \ + X(bool, DebugFeaturesEnabled, debugFeaturesDefault) \ + X(bool, StartOnUserLogin, false) \ + X(bool, AlwaysOnTop, false) \ + X(Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder) \ + X(bool, DisableAnimations, false) \ + X(hstring, StartupActions, L"") \ + X(Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew) \ + X(bool, MinimizeToNotificationArea, false) \ + X(bool, AlwaysShowNotificationIcon, false) \ + X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ + X(bool, ShowAdminShield, true) + +#define PROFILE_CONTROL_SETTINGS(X) \ X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ X(bool, SnapOnInput, true) \ X(bool, AltGrAliasing, true) \ @@ -36,6 +66,15 @@ Author(s): X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) +#define PROFILE_APP_SETTINGS(X) \ + X(guid, ConnectionType) \ + X(hstring, Icon, L"\uE756") \ + X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ + X(hstring, TabTitle) \ + X(bool, SuppressApplicationTitle, false) \ + X(hstring, StartingDirectory) \ + X(Model::BellStyle, BellStyle, BellStyle::Audible) + #define FONT_SETTINGS(X) \ X(hstring, FontFace, DEFAULT_FONT_FACE) \ X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ @@ -43,10 +82,17 @@ Author(s): X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) -#define APPEARANCE_SETTINGS(X) \ +#define APPEARANCE_CONTROL_SETTINGS(X) \ X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ X(double, BackgroundImageOpacity, 1.0) \ X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ X(bool, RetroTerminalEffect, false) \ X(hstring, PixelShaderPath) + +#define APPEARANCE_APP_SETTINGS(X) \ + X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ + X(hstring, ColorSchemeName, L"Campbell") \ + X(hstring, BackgroundImagePath) \ + X(Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright) \ + X(double, Opacity, 1.0) diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index 76195a89e07..213f1d2f7cb 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -190,10 +190,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _BackgroundImage = appearance.ExpandedBackgroundImagePath(); } -#define PROFILE_APPEARANCE_SETTINGS_APPLY(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_APPLY(type, name, ...) \ _##name = appearance.name(); - APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_APPLY) -#undef PROFILE_APPEARANCE_SETTINGS_APPLY + APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_APPLY) +#undef APPEARANCE_CONTROL_SETTINGS_APPLY _IntenseIsBold = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bold); _IntenseIsBright = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bright); @@ -264,10 +264,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyProfileSettings(const Profile& profile) { -#define PROFILE_SETTINGS_APPLY(type, name, ...) \ +#define PROFILE_CONTROL_SETTINGS_APPLY(type, name, ...) \ _##name = profile.name(); - PROFILE_SETTINGS(PROFILE_SETTINGS_APPLY) -#undef PROFILE_SETTINGS_APPLY + PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_APPLY) +#undef PROFILE_CONTROL_SETTINGS_APPLY #define PROFILE_FONT_SETTINGS_APPLY(type, name, ...) \ _##name = profile.FontInfo().name(); @@ -302,10 +302,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyGlobalSettings(const Model::GlobalAppSettings& globalSettings) noexcept { -#define GLOBAL_SETTINGS_APPLY(type, name, ...) \ +#define GLOBAL_CONTROL_SETTINGS_APPLY(type, name, ...) \ _##name = globalSettings.name(); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_APPLY) -#undef GLOBAL_SETTINGS_APPLY + GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_APPLY) +#undef GLOBAL_CONTROL_SETTINGS_APPLY } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 0cec6f45d6c..7e12e7f48b2 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -86,25 +86,25 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, til::color, DefaultBackground, DEFAULT_BACKGROUND); INHERITABLE_SETTING(Model::TerminalSettings, til::color, SelectionBackground, DEFAULT_FOREGROUND); -#define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ +#define GLOBAL_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) -#undef GLOBAL_SETTINGS_INITIALIZE + GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_INITIALIZE) +#undef GLOBAL_CONTROL_SETTINGS_INITIALIZE -#define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ +#define PROFILE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) -#undef PROFILE_SETTINGS_INITIALIZE + PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_INITIALIZE) +#undef PROFILE_CONTROL_SETTINGS_INITIALIZE #define PROFILE_FONT_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) FONT_SETTINGS(PROFILE_FONT_SETTINGS_INITIALIZE) #undef PROFILE_FONT_SETTINGS_INITIALIZE -#define PROFILE_APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - APPEARANCE_SETTINGS(PROFILE_APPEARANCE_SETTINGS_INITIALIZE) -#undef PROFILE_APPEARANCE_SETTINGS_INITIALIZE + APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_INITIALIZE) +#undef APPEARANCE_CONTROL_SETTINGS_INITIALIZE INHERITABLE_SETTING(Model::TerminalSettings, til::color, CursorColor, DEFAULT_CURSOR_COLOR); INHERITABLE_SETTING(Model::TerminalSettings, bool, InputServiceWarning, true); From 85f487389d27df763cb71e10a631869e8d1045fa Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 6 Oct 2021 14:56:53 -0700 Subject: [PATCH 04/15] format --- .../TerminalSettingsModel/SettingsUtils.h | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index 73478ac8e38..adaa38ec8a2 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -26,34 +26,34 @@ Author(s): X(bool, TrimBlockSelection, false) \ X(bool, DetectURLs, true) -#define GLOBAL_APP_SETTINGS(X) \ - X(bool, AlwaysShowTabs, true) \ - X(bool, ShowTitleInTitlebar, true) \ - X(bool, ConfirmCloseAllTabs, true) \ - X(hstring, Language) \ - X(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default) \ +#define GLOBAL_APP_SETTINGS(X) \ + X(bool, AlwaysShowTabs, true) \ + X(bool, ShowTitleInTitlebar, true) \ + X(bool, ConfirmCloseAllTabs, true) \ + X(hstring, Language) \ + X(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default) \ X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \ - X(bool, UseAcrylicInTabRow, false) \ - X(bool, ShowTabsInTitlebar, true) \ - X(bool, InputServiceWarning, true) \ - X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0) \ - X(bool, WarnAboutLargePaste, true) \ - X(bool, WarnAboutMultiLinePaste, true) \ - X(Model::LaunchPosition, InitialPosition, nullptr, nullptr) \ - X(bool, CenterOnLaunch, false) \ - X(Model::FirstWindowPreference, FirstWindowPreference, FirstWindowPreference::DefaultProfile) \ - X(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode) \ - X(bool, SnapToGridOnResize, true) \ - X(bool, DebugFeaturesEnabled, debugFeaturesDefault) \ - X(bool, StartOnUserLogin, false) \ - X(bool, AlwaysOnTop, false) \ - X(Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder) \ - X(bool, DisableAnimations, false) \ - X(hstring, StartupActions, L"") \ - X(Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew) \ - X(bool, MinimizeToNotificationArea, false) \ - X(bool, AlwaysShowNotificationIcon, false) \ - X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ + X(bool, UseAcrylicInTabRow, false) \ + X(bool, ShowTabsInTitlebar, true) \ + X(bool, InputServiceWarning, true) \ + X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0) \ + X(bool, WarnAboutLargePaste, true) \ + X(bool, WarnAboutMultiLinePaste, true) \ + X(Model::LaunchPosition, InitialPosition, nullptr, nullptr) \ + X(bool, CenterOnLaunch, false) \ + X(Model::FirstWindowPreference, FirstWindowPreference, FirstWindowPreference::DefaultProfile) \ + X(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode) \ + X(bool, SnapToGridOnResize, true) \ + X(bool, DebugFeaturesEnabled, debugFeaturesDefault) \ + X(bool, StartOnUserLogin, false) \ + X(bool, AlwaysOnTop, false) \ + X(Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder) \ + X(bool, DisableAnimations, false) \ + X(hstring, StartupActions, L"") \ + X(Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew) \ + X(bool, MinimizeToNotificationArea, false) \ + X(bool, AlwaysShowNotificationIcon, false) \ + X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ X(bool, ShowAdminShield, true) #define PROFILE_CONTROL_SETTINGS(X) \ @@ -66,13 +66,13 @@ Author(s): X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) -#define PROFILE_APP_SETTINGS(X) \ - X(guid, ConnectionType) \ - X(hstring, Icon, L"\uE756") \ +#define PROFILE_APP_SETTINGS(X) \ + X(guid, ConnectionType) \ + X(hstring, Icon, L"\uE756") \ X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ - X(hstring, TabTitle) \ - X(bool, SuppressApplicationTitle, false) \ - X(hstring, StartingDirectory) \ + X(hstring, TabTitle) \ + X(bool, SuppressApplicationTitle, false) \ + X(hstring, StartingDirectory) \ X(Model::BellStyle, BellStyle, BellStyle::Audible) #define FONT_SETTINGS(X) \ @@ -90,9 +90,9 @@ Author(s): X(bool, RetroTerminalEffect, false) \ X(hstring, PixelShaderPath) -#define APPEARANCE_APP_SETTINGS(X) \ +#define APPEARANCE_APP_SETTINGS(X) \ X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ - X(hstring, ColorSchemeName, L"Campbell") \ - X(hstring, BackgroundImagePath) \ - X(Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright) \ + X(hstring, ColorSchemeName, L"Campbell") \ + X(hstring, BackgroundImagePath) \ + X(Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright) \ X(double, Opacity, 1.0) From 6941bbabfcc3113725da22b1e737a0060847d2e9 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 6 Oct 2021 15:18:18 -0700 Subject: [PATCH 05/15] macrofy font config --- .../TerminalSettingsModel/FontConfig.cpp | 29 +++++++++---------- .../TerminalSettingsModel/FontConfig.h | 10 +++---- .../TerminalSettingsModel/SettingsUtils.h | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.cpp b/src/cascadia/TerminalSettingsModel/FontConfig.cpp index 5d57eb355c4..0860cf0a3e9 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/FontConfig.cpp @@ -29,11 +29,12 @@ winrt::Microsoft::Terminal::Settings::Model::implementation::FontConfig::FontCon winrt::com_ptr FontConfig::CopyFontInfo(const FontConfig* source, winrt::weak_ref sourceProfile) { auto fontInfo{ winrt::make_self(std::move(sourceProfile)) }; - fontInfo->_FontFace = source->_FontFace; - fontInfo->_FontSize = source->_FontSize; - fontInfo->_FontWeight = source->_FontWeight; - fontInfo->_FontAxes = source->_FontAxes; - fontInfo->_FontFeatures = source->_FontFeatures; + +#define FONT_SETTINGS_COPY(type, name, ...) \ + fontInfo->_##name = source->_##name; + FONT_SETTINGS(FONT_SETTINGS_COPY) +#undef FONT_SETTINGS_COPY + return fontInfo; } @@ -41,11 +42,10 @@ Json::Value FontConfig::ToJson() const { Json::Value json{ Json::ValueType::objectValue }; - JsonUtils::SetValueForKey(json, FontFaceKey, _FontFace); - JsonUtils::SetValueForKey(json, FontSizeKey, _FontSize); - JsonUtils::SetValueForKey(json, FontWeightKey, _FontWeight); - JsonUtils::SetValueForKey(json, FontAxesKey, _FontAxes); - JsonUtils::SetValueForKey(json, FontFeaturesKey, _FontFeatures); +#define FONT_SETTINGS_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + FONT_SETTINGS(FONT_SETTINGS_TO_JSON) +#undef FONT_SETTINGS_TO_JSON return json; } @@ -69,11 +69,10 @@ void FontConfig::LayerJson(const Json::Value& json) { // A font object is defined, use that const auto fontInfoJson = json[JsonKey(FontInfoKey)]; - JsonUtils::GetValueForKey(fontInfoJson, FontFaceKey, _FontFace); - JsonUtils::GetValueForKey(fontInfoJson, FontSizeKey, _FontSize); - JsonUtils::GetValueForKey(fontInfoJson, FontWeightKey, _FontWeight); - JsonUtils::GetValueForKey(fontInfoJson, FontFeaturesKey, _FontFeatures); - JsonUtils::GetValueForKey(fontInfoJson, FontAxesKey, _FontAxes); +#define FONT_SETTINGS_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(fontInfoJson, name##Key, _##name); + FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) +#undef FONT_SETTINGS_LAYER_JSON } else { diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.h b/src/cascadia/TerminalSettingsModel/FontConfig.h index 6c53ed4ea0a..edb589d4c33 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.h +++ b/src/cascadia/TerminalSettingsModel/FontConfig.h @@ -19,6 +19,7 @@ Author(s): #include "pch.h" #include "FontConfig.g.h" #include "JsonUtils.h" +#include "SettingsUtils.h" #include "../inc/cppwinrt_utils.h" #include "IInheritable.h" #include @@ -39,11 +40,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation Model::Profile SourceProfile(); - INHERITABLE_SETTING(Model::FontConfig, hstring, FontFace, DEFAULT_FONT_FACE); - INHERITABLE_SETTING(Model::FontConfig, int32_t, FontSize, DEFAULT_FONT_SIZE); - INHERITABLE_SETTING(Model::FontConfig, Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT); - INHERITABLE_SETTING(Model::FontConfig, IFontAxesMap, FontAxes); - INHERITABLE_SETTING(Model::FontConfig, IFontFeatureMap, FontFeatures); + #define FONT_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__) + FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) + #undef FONT_SETTINGS_INITIALIZE private: winrt::weak_ref _sourceProfile; diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index adaa38ec8a2..b0cae95d79b 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -78,7 +78,7 @@ Author(s): #define FONT_SETTINGS(X) \ X(hstring, FontFace, DEFAULT_FONT_FACE) \ X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ - X(winrt::Windows::UI::Text::FontWeight, FontWeight) \ + X(winrt::Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT) \ X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) From 24b87191b7d4cb768dd54f63e23f6efd0fba8cb7 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 6 Oct 2021 15:21:26 -0700 Subject: [PATCH 06/15] formatt --- src/cascadia/TerminalSettingsModel/FontConfig.cpp | 4 ++-- src/cascadia/TerminalSettingsModel/FontConfig.h | 8 ++++---- src/cascadia/TerminalSettingsModel/SettingsUtils.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.cpp b/src/cascadia/TerminalSettingsModel/FontConfig.cpp index 0860cf0a3e9..74c195a92b4 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/FontConfig.cpp @@ -70,8 +70,8 @@ void FontConfig::LayerJson(const Json::Value& json) // A font object is defined, use that const auto fontInfoJson = json[JsonKey(FontInfoKey)]; #define FONT_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(fontInfoJson, name##Key, _##name); - FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) + JsonUtils::GetValueForKey(fontInfoJson, name##Key, _##name); + FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) #undef FONT_SETTINGS_LAYER_JSON } else diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.h b/src/cascadia/TerminalSettingsModel/FontConfig.h index edb589d4c33..e4b9cf18c7c 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.h +++ b/src/cascadia/TerminalSettingsModel/FontConfig.h @@ -40,10 +40,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation Model::Profile SourceProfile(); - #define FONT_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__) - FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) - #undef FONT_SETTINGS_INITIALIZE +#define FONT_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__) + FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) +#undef FONT_SETTINGS_INITIALIZE private: winrt::weak_ref _sourceProfile; diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index b0cae95d79b..ec3d599ef0b 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -75,11 +75,11 @@ Author(s): X(hstring, StartingDirectory) \ X(Model::BellStyle, BellStyle, BellStyle::Audible) -#define FONT_SETTINGS(X) \ - X(hstring, FontFace, DEFAULT_FONT_FACE) \ - X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ +#define FONT_SETTINGS(X) \ + X(hstring, FontFace, DEFAULT_FONT_FACE) \ + X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ X(winrt::Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT) \ - X(IFontAxesMap, FontAxes) \ + X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) #define APPEARANCE_CONTROL_SETTINGS(X) \ From f41426bc33dbe6518095fb1dee8da3e93bd40582 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 7 Oct 2021 10:25:56 -0700 Subject: [PATCH 07/15] placeholder macros --- .../TerminalSettingsModel/AppearanceConfig.cpp | 18 +++++++++--------- .../TerminalSettingsModel/AppearanceConfig.h | 6 +++--- src/cascadia/TerminalSettingsModel/Profile.cpp | 15 +++++++++++++++ src/cascadia/TerminalSettingsModel/Profile.h | 5 +++++ .../TerminalSettingsModel/SettingsUtils.h | 13 ++++++++++--- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index 03154cff6b6..b66dd7f3a17 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -42,10 +42,10 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan appearance->_SelectionBackground = source->_SelectionBackground; appearance->_CursorColor = source->_CursorColor; -#define APPEARANCE_APP_SETTINGS_COPY(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_2_COPY(type, name, ...) \ appearance->_##name = source->_##name; - APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_COPY) -#undef APPEARANCE_APP_SETTINGS_COPY + APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_COPY) +#undef APPEARANCE_CONTROL_SETTINGS_2_COPY #define APPEARANCE_CONTROL_SETTINGS_COPY(type, name, ...) \ appearance->_##name = source->_##name; @@ -64,10 +64,10 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor); -#define APPEARANCE_APP_SETTINGS_TO_JSON(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_2_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_TO_JSON) -#undef APPEARANCE_APP_SETTINGS_TO_JSON + APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_TO_JSON) +#undef APPEARANCE_CONTROL_SETTINGS_2_TO_JSON #define APPEARANCE_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); @@ -96,10 +96,10 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, CursorColorKey, _CursorColor); JsonUtils::GetValueForKey(json, LegacyAcrylicTransparencyKey, _Opacity); -#define APPEARANCE_APP_SETTINGS_LAYER_JSON(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_2_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_LAYER_JSON) -#undef APPEARANCE_APP_SETTINGS_LAYER_JSON + APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_LAYER_JSON) +#undef APPEARANCE_CONTROL_SETTINGS_2_LAYER_JSON #define APPEARANCE_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index 78bd049228c..afeb8c0dd7b 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -41,10 +41,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); -#define APPEARANCE_APP_SETTINGS_INITIALIZE(type, name, ...) \ +#define APPEARANCE_CONTROL_SETTINGS_2_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) - APPEARANCE_APP_SETTINGS(APPEARANCE_APP_SETTINGS_INITIALIZE) -#undef APPEARANCE_APP_SETTINGS_INITIALIZE + APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_INITIALIZE) +#undef APPEARANCE_CONTROL_SETTINGS_2_INITIALIZE #define APPEARANCE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index ada33bdc5da..e89702d7765 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -134,6 +134,11 @@ winrt::com_ptr Profile::CopySettings() const PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_COPY) #undef PROFILE_CONTROL_SETTINGS_COPY +#define PROFILE_CONTROL_SETTINGS_2_COPY(type, name, ...) \ + profile->_##name = _##name; + PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_COPY) +#undef PROFILE_CONTROL_SETTINGS_2_COPY + if (_UnfocusedAppearance) { Model::AppearanceConfig unfocused{ nullptr }; @@ -202,6 +207,11 @@ void Profile::LayerJson(const Json::Value& json) PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_LAYER_JSON) #undef PROFILE_CONTROL_SETTINGS_LAYER_JSON +#define PROFILE_CONTROL_SETTINGS_2_LAYER_JSON(type, name, ...) \ + JsonUtils::GetValueForKey(json, name##Key, _##name); + PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_LAYER_JSON) +#undef PROFILE_CONTROL_SETTINGS_2_LAYER_JSON + if (json.isMember(JsonKey(UnfocusedAppearanceKey))) { auto unfocusedAppearance{ winrt::make_self(weak_ref(*this)) }; @@ -345,6 +355,11 @@ Json::Value Profile::ToJson() const PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_TO_JSON) #undef PROFILE_CONTROL_SETTINGS_TO_JSON +#define PROFILE_CONTROL_SETTINGS_2_TO_JSON(type, name, ...) \ + JsonUtils::SetValueForKey(json, name##Key, _##name); + PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_TO_JSON) +#undef PROFILE_CONTROL_SETTINGS_2_TO_JSON + // Font settings const auto fontInfoImpl = winrt::get_self(_FontInfo); if (fontInfoImpl->HasAnyOptionSet()) diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index 8b0dc5a842e..f3f39119869 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -130,6 +130,11 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_INITIALIZE) #undef PROFILE_CONTROL_SETTINGS_INITIALIZE +#define PROFILE_CONTROL_SETTINGS_2_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) + PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_INITIALIZE) +#undef PROFILE_CONTROL_SETTINGS_2_INITIALIZE + private: Model::IAppearanceConfig _DefaultAppearance{ winrt::make(weak_ref(*this)) }; Model::FontConfig _FontInfo{ winrt::make(weak_ref(*this)) }; diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index ec3d599ef0b..9cb694b2bde 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -66,13 +66,18 @@ Author(s): X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) +// Placeholder for settings that are defined in the control but TerminalSettings +// needs to define manually for now +#define PROFILE_CONTROL_SETTINGS_2(X) \ + X(hstring, StartingDirectory) \ + X(bool, SuppressApplicationTitle, false) + + #define PROFILE_APP_SETTINGS(X) \ X(guid, ConnectionType) \ X(hstring, Icon, L"\uE756") \ X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ X(hstring, TabTitle) \ - X(bool, SuppressApplicationTitle, false) \ - X(hstring, StartingDirectory) \ X(Model::BellStyle, BellStyle, BellStyle::Audible) #define FONT_SETTINGS(X) \ @@ -90,7 +95,9 @@ Author(s): X(bool, RetroTerminalEffect, false) \ X(hstring, PixelShaderPath) -#define APPEARANCE_APP_SETTINGS(X) \ +// Placeholder for settings that are defined in the control but TerminalSettings +// needs to define manually for now +#define APPEARANCE_CONTROL_SETTINGS_2(X) \ X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ X(hstring, ColorSchemeName, L"Campbell") \ X(hstring, BackgroundImagePath) \ From 1b4a5fad8e92f075d1b43f1ab289f52240124ceb Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 8 Oct 2021 12:07:41 -0700 Subject: [PATCH 08/15] scale it back --- .../AppearanceConfig.cpp | 33 +++-------- .../TerminalSettingsModel/AppearanceConfig.h | 11 +--- .../GlobalAppSettings.cpp | 32 +++-------- .../TerminalSettingsModel/GlobalAppSettings.h | 11 +--- .../TerminalSettingsModel/Profile.cpp | 48 +++------------- src/cascadia/TerminalSettingsModel/Profile.h | 30 ++++------ .../TerminalSettingsModel/SettingsUtils.h | 27 +++------ .../TerminalSettings.cpp | 56 +++++++++++++------ .../TerminalSettingsModel/TerminalSettings.h | 53 +++++++++++------- 9 files changed, 122 insertions(+), 179 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index b66dd7f3a17..6ca4a981f40 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -42,15 +42,10 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan appearance->_SelectionBackground = source->_SelectionBackground; appearance->_CursorColor = source->_CursorColor; -#define APPEARANCE_CONTROL_SETTINGS_2_COPY(type, name, ...) \ +#define APPEARANCE_SETTINGS_COPY(type, name, ...) \ appearance->_##name = source->_##name; - APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_COPY) -#undef APPEARANCE_CONTROL_SETTINGS_2_COPY - -#define APPEARANCE_CONTROL_SETTINGS_COPY(type, name, ...) \ - appearance->_##name = source->_##name; - APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_COPY) -#undef APPEARANCE_CONTROL_SETTINGS_COPY + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) +#undef APPEARANCE_SETTINGS_COPY return appearance; } @@ -64,15 +59,10 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor); -#define APPEARANCE_CONTROL_SETTINGS_2_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); - APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_TO_JSON) -#undef APPEARANCE_CONTROL_SETTINGS_2_TO_JSON - -#define APPEARANCE_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ +#define APPEARANCE_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_TO_JSON) -#undef APPEARANCE_CONTROL_SETTINGS_TO_JSON + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) +#undef APPEARANCE_SETTINGS_TO_JSON return json; } @@ -96,15 +86,10 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, CursorColorKey, _CursorColor); JsonUtils::GetValueForKey(json, LegacyAcrylicTransparencyKey, _Opacity); -#define APPEARANCE_CONTROL_SETTINGS_2_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); - APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_LAYER_JSON) -#undef APPEARANCE_CONTROL_SETTINGS_2_LAYER_JSON - -#define APPEARANCE_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ +#define APPEARANCE_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_LAYER_JSON) -#undef APPEARANCE_CONTROL_SETTINGS_LAYER_JSON + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) +#undef APPEARANCE_SETTINGS_LAYER_JSON } winrt::Microsoft::Terminal::Settings::Model::Profile AppearanceConfig::SourceProfile() diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index afeb8c0dd7b..39325967fb8 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -41,15 +41,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); -#define APPEARANCE_CONTROL_SETTINGS_2_INITIALIZE(type, name, ...) \ +#define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) - APPEARANCE_CONTROL_SETTINGS_2(APPEARANCE_CONTROL_SETTINGS_2_INITIALIZE) -#undef APPEARANCE_CONTROL_SETTINGS_2_INITIALIZE - -#define APPEARANCE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) - APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_INITIALIZE) -#undef APPEARANCE_CONTROL_SETTINGS_INITIALIZE + APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) +#undef APPEARANCE_SETTINGS_INITIALIZE private: winrt::weak_ref _sourceProfile; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 0fa34a7da39..65b71b618f4 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -91,15 +91,10 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_actionMap = _actionMap->Copy(); globals->_keybindingsWarnings = _keybindingsWarnings; -#define GLOBAL_APP_SETTINGS_COPY(type, name, ...) \ +#define GLOBAL_SETTINGS_COPY(type, name, ...) \ globals->_##name = _##name; - GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_COPY) -#undef GLOBAL_APP_SETTINGS_COPY - -#define GLOBAL_CONTROL_SETTINGS_COPY(type, name, ...) \ - globals->_##name = _##name; - GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_COPY) -#undef GLOBAL_CONTROL_SETTINGS_COPY + GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) +#undef GLOBAL_SETTINGS_COPY if (_colorSchemes) { @@ -163,15 +158,10 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) // "useTabSwitcher", but prefer "tabSwitcherMode" JsonUtils::GetValueForKey(json, LegacyUseTabSwitcherModeKey, _TabSwitcherMode); -#define GLOBAL_APP_SETTINGS_LAYER_JSON(type, name, ...) \ +#define GLOBAL_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_LAYER_JSON) -#undef GLOBAL_APP_SETTINGS_LAYER_JSON - -#define GLOBAL_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); - GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_LAYER_JSON) -#undef GLOBAL_CONTROL_SETTINGS_LAYER_JSON + GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) +#undef GLOBAL_SETTINGS_LAYER_JSON static constexpr std::array bindingsKeys{ LegacyKeybindingsKey, ActionsKey }; for (const auto& jsonKey : bindingsKeys) @@ -234,15 +224,11 @@ Json::Value GlobalAppSettings::ToJson() const // clang-format off JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); -#define GLOBAL_APP_SETTINGS_TO_JSON(type, name, ...) \ +#define GLOBAL_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_TO_JSON) -#undef GLOBAL_APP_SETTINGS_TO_JSON + GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) +#undef GLOBAL_SETTINGS_TO_JSON -#define GLOBAL_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); - GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_TO_JSON) -#undef GLOBAL_CONTROL_SETTINGS_TO_JSON // clang-format on json[JsonKey(ActionsKey)] = _actionMap->ToJson(); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index d7b813537a3..71c3ad19623 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -64,15 +64,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, UnparsedDefaultProfile, L""); -#define GLOBAL_APP_SETTINGS_INITIALIZE(type, name, ...) \ +#define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) - GLOBAL_APP_SETTINGS(GLOBAL_APP_SETTINGS_INITIALIZE) -#undef GLOBAL_APP_SETTINGS_INITIALIZE - -#define GLOBAL_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) - GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_INITIALIZE) -#undef GLOBAL_CONTROL_SETTINGS_INITIALIZE + GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) +#undef GLOBAL_SETTINGS_INITIALIZE private: #ifdef NDEBUG diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index e89702d7765..34dda86c6ee 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -124,20 +124,10 @@ winrt::com_ptr Profile::CopySettings() const profile->_ForceFullRepaintRendering = _ForceFullRepaintRendering; profile->_SoftwareRendering = _SoftwareRendering; -#define PROFILE_APP_SETTINGS_COPY(type, name, ...) \ +#define PROFILE_SETTINGS_COPY(type, name, ...) \ profile->_##name = _##name; - PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_COPY) -#undef PROFILE_APP_SETTINGS_COPY - -#define PROFILE_CONTROL_SETTINGS_COPY(type, name, ...) \ - profile->_##name = _##name; - PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_COPY) -#undef PROFILE_CONTROL_SETTINGS_COPY - -#define PROFILE_CONTROL_SETTINGS_2_COPY(type, name, ...) \ - profile->_##name = _##name; - PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_COPY) -#undef PROFILE_CONTROL_SETTINGS_2_COPY + PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) +#undef PROFILE_SETTINGS_COPY if (_UnfocusedAppearance) { @@ -197,20 +187,10 @@ void Profile::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, GuidKey, _Guid); JsonUtils::GetValueForKey(json, TabColorKey, _TabColor); -#define PROFILE_APP_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); - PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_LAYER_JSON) -#undef PROFILE_APP_SETTINGS_LAYER_JSON - -#define PROFILE_CONTROL_SETTINGS_LAYER_JSON(type, name, ...) \ +#define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_LAYER_JSON) -#undef PROFILE_CONTROL_SETTINGS_LAYER_JSON - -#define PROFILE_CONTROL_SETTINGS_2_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); - PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_LAYER_JSON) -#undef PROFILE_CONTROL_SETTINGS_2_LAYER_JSON + PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) +#undef PROFILE_SETTINGS_LAYER_JSON if (json.isMember(JsonKey(UnfocusedAppearanceKey))) { @@ -345,20 +325,10 @@ Json::Value Profile::ToJson() const // PermissiveStringConverter is unnecessary for serialization JsonUtils::SetValueForKey(json, TabColorKey, _TabColor); -#define PROFILE_APP_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); - PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_TO_JSON) -#undef PROFILE_APP_SETTINGS_TO_JSON - -#define PROFILE_CONTROL_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); - PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_TO_JSON) -#undef PROFILE_CONTROL_SETTINGS_TO_JSON - -#define PROFILE_CONTROL_SETTINGS_2_TO_JSON(type, name, ...) \ +#define PROFILE_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_TO_JSON) -#undef PROFILE_CONTROL_SETTINGS_2_TO_JSON + PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) +#undef PROFILE_SETTINGS_TO_JSON // Font settings const auto fontInfoImpl = winrt::get_self(_FontInfo); diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index f3f39119869..59fcab4be07 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -108,32 +108,24 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation WINRT_PROPERTY(OriginTag, Origin, OriginTag::None); WINRT_PROPERTY(guid, Updates); - // Nullable settings + // Nullable/optional settings INHERITABLE_NULLABLE_SETTING(Model::Profile, Microsoft::Terminal::Core::Color, TabColor, nullptr); + INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); - // Settings that cannot be put in the macro + // Global settings + INHERITABLE_SETTING(Model::Profile, bool, ForceFullRepaintRendering, false); + INHERITABLE_SETTING(Model::Profile, bool, SoftwareRendering, false); + + // Settings that cannot be put in the macro because of how they are handled in ToJson INHERITABLE_SETTING(Model::Profile, hstring, Name, L"Default"); INHERITABLE_SETTING(Model::Profile, hstring, Source); INHERITABLE_SETTING(Model::Profile, bool, Hidden, false); INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); - INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); - INHERITABLE_SETTING(Model::Profile, bool, ForceFullRepaintRendering, false); - INHERITABLE_SETTING(Model::Profile, bool, SoftwareRendering, false); - -#define PROFILE_APP_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_APP_SETTINGS(PROFILE_APP_SETTINGS_INITIALIZE) -#undef PROFILE_APP_SETTINGS_INITIALIZE - -#define PROFILE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_INITIALIZE) -#undef PROFILE_CONTROL_SETTINGS_INITIALIZE -#define PROFILE_CONTROL_SETTINGS_2_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_CONTROL_SETTINGS_2(PROFILE_CONTROL_SETTINGS_2_INITIALIZE) -#undef PROFILE_CONTROL_SETTINGS_2_INITIALIZE +#define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ + INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) + PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) +#undef PROFILE_SETTINGS_INITIALIZE private: Model::IAppearanceConfig _DefaultAppearance{ winrt::make(weak_ref(*this)) }; diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index 9cb694b2bde..4d7e05bbcf0 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -14,7 +14,7 @@ Author(s): --*/ #pragma once -#define GLOBAL_CONTROL_SETTINGS(X) \ +#define GLOBAL_SETTINGS(X) \ X(int32_t, InitialRows, 30) \ X(int32_t, InitialCols, 80) \ X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ @@ -24,9 +24,7 @@ Author(s): X(bool, SoftwareRendering, false) \ X(bool, ForceVTInput, false) \ X(bool, TrimBlockSelection, false) \ - X(bool, DetectURLs, true) - -#define GLOBAL_APP_SETTINGS(X) \ + X(bool, DetectURLs, true) \ X(bool, AlwaysShowTabs, true) \ X(bool, ShowTitleInTitlebar, true) \ X(bool, ConfirmCloseAllTabs, true) \ @@ -56,7 +54,7 @@ Author(s): X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ X(bool, ShowAdminShield, true) -#define PROFILE_CONTROL_SETTINGS(X) \ +#define PROFILE_SETTINGS(X) \ X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ X(bool, SnapOnInput, true) \ X(bool, AltGrAliasing, true) \ @@ -64,16 +62,9 @@ Author(s): X(hstring, Padding, DEFAULT_PADDING) \ X(hstring, Commandline, L"cmd.exe") \ X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ - X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) - -// Placeholder for settings that are defined in the control but TerminalSettings -// needs to define manually for now -#define PROFILE_CONTROL_SETTINGS_2(X) \ + X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \ X(hstring, StartingDirectory) \ - X(bool, SuppressApplicationTitle, false) - - -#define PROFILE_APP_SETTINGS(X) \ + X(bool, SuppressApplicationTitle, false) \ X(guid, ConnectionType) \ X(hstring, Icon, L"\uE756") \ X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ @@ -87,17 +78,13 @@ Author(s): X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) -#define APPEARANCE_CONTROL_SETTINGS(X) \ +#define APPEARANCE_SETTINGS(X) \ X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ X(double, BackgroundImageOpacity, 1.0) \ X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ X(bool, RetroTerminalEffect, false) \ - X(hstring, PixelShaderPath) - -// Placeholder for settings that are defined in the control but TerminalSettings -// needs to define manually for now -#define APPEARANCE_CONTROL_SETTINGS_2(X) \ + X(hstring, PixelShaderPath) \ X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ X(hstring, ColorSchemeName, L"Campbell") \ X(hstring, BackgroundImagePath) \ diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index 213f1d2f7cb..187b3cedb3e 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -162,6 +162,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation void TerminalSettings::_ApplyAppearanceSettings(const IAppearanceConfig& appearance, const Windows::Foundation::Collections::IMapView& schemes) { + _CursorShape = appearance.CursorShape(); + _CursorHeight = appearance.CursorHeight(); if (!appearance.ColorSchemeName().empty()) { if (const auto scheme = schemes.TryLookup(appearance.ColorSchemeName())) @@ -190,14 +192,15 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _BackgroundImage = appearance.ExpandedBackgroundImagePath(); } -#define APPEARANCE_CONTROL_SETTINGS_APPLY(type, name, ...) \ - _##name = appearance.name(); - APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_APPLY) -#undef APPEARANCE_CONTROL_SETTINGS_APPLY + _BackgroundImageOpacity = appearance.BackgroundImageOpacity(); + _BackgroundImageStretchMode = appearance.BackgroundImageStretchMode(); + std::tie(_BackgroundImageHorizontalAlignment, _BackgroundImageVerticalAlignment) = ConvertConvergedAlignment(appearance.BackgroundImageAlignment()); + + _RetroTerminalEffect = appearance.RetroTerminalEffect(); + _PixelShaderPath = winrt::hstring{ wil::ExpandEnvironmentStringsW(appearance.PixelShaderPath().c_str()) }; _IntenseIsBold = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bold); _IntenseIsBright = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bright); - std::tie(_BackgroundImageHorizontalAlignment, _BackgroundImageVerticalAlignment) = ConvertConvergedAlignment(appearance.BackgroundImageAlignment()); _Opacity = appearance.Opacity(); } @@ -264,18 +267,24 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyProfileSettings(const Profile& profile) { -#define PROFILE_CONTROL_SETTINGS_APPLY(type, name, ...) \ - _##name = profile.name(); - PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_APPLY) -#undef PROFILE_CONTROL_SETTINGS_APPLY - -#define PROFILE_FONT_SETTINGS_APPLY(type, name, ...) \ - _##name = profile.FontInfo().name(); - FONT_SETTINGS(PROFILE_FONT_SETTINGS_APPLY) -#undef PROFILE_FONT_SETTINGS_APPLY + // Fill in the Terminal Setting's CoreSettings from the profile + _HistorySize = profile.HistorySize(); + _SnapOnInput = profile.SnapOnInput(); + _AltGrAliasing = profile.AltGrAliasing(); // Fill in the remaining properties from the profile _ProfileName = profile.Name(); + _UseAcrylic = profile.UseAcrylic(); + + _FontFace = profile.FontInfo().FontFace(); + _FontSize = profile.FontInfo().FontSize(); + _FontWeight = profile.FontInfo().FontWeight(); + _FontFeatures = profile.FontInfo().FontFeatures(); + _FontAxes = profile.FontInfo().FontAxes(); + _Padding = profile.Padding(); + + _Commandline = profile.Commandline(); + _StartingDirectory = profile.EvaluatedStartingDirectory(); // GH#2373: Use the tabTitle as the starting title if it exists, otherwise @@ -287,6 +296,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _SuppressApplicationTitle = profile.SuppressApplicationTitle(); } + _ScrollState = profile.ScrollState(); + + _AntialiasingMode = profile.AntialiasingMode(); + if (profile.TabColor()) { const til::color colorRef{ profile.TabColor().Value() }; @@ -302,10 +315,17 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // - void TerminalSettings::_ApplyGlobalSettings(const Model::GlobalAppSettings& globalSettings) noexcept { -#define GLOBAL_CONTROL_SETTINGS_APPLY(type, name, ...) \ - _##name = globalSettings.name(); - GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_APPLY) -#undef GLOBAL_CONTROL_SETTINGS_APPLY + _InitialRows = globalSettings.InitialRows(); + _InitialCols = globalSettings.InitialCols(); + + _WordDelimiters = globalSettings.WordDelimiters(); + _CopyOnSelect = globalSettings.CopyOnSelect(); + _FocusFollowMouse = globalSettings.FocusFollowMouse(); + _ForceFullRepaintRendering = globalSettings.ForceFullRepaintRendering(); + _SoftwareRendering = globalSettings.SoftwareRendering(); + _ForceVTInput = globalSettings.ForceVTInput(); + _TrimBlockSelection = globalSettings.TrimBlockSelection(); + _DetectURLs = globalSettings.DetectURLs(); } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 7e12e7f48b2..05046f27f92 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -85,29 +85,21 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, til::color, DefaultForeground, DEFAULT_FOREGROUND); INHERITABLE_SETTING(Model::TerminalSettings, til::color, DefaultBackground, DEFAULT_BACKGROUND); INHERITABLE_SETTING(Model::TerminalSettings, til::color, SelectionBackground, DEFAULT_FOREGROUND); + INHERITABLE_SETTING(Model::TerminalSettings, int32_t, HistorySize, DEFAULT_HISTORY_SIZE); + INHERITABLE_SETTING(Model::TerminalSettings, int32_t, InitialRows, 30); + INHERITABLE_SETTING(Model::TerminalSettings, int32_t, InitialCols, 80); -#define GLOBAL_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - GLOBAL_CONTROL_SETTINGS(GLOBAL_CONTROL_SETTINGS_INITIALIZE) -#undef GLOBAL_CONTROL_SETTINGS_INITIALIZE - -#define PROFILE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - PROFILE_CONTROL_SETTINGS(PROFILE_CONTROL_SETTINGS_INITIALIZE) -#undef PROFILE_CONTROL_SETTINGS_INITIALIZE - -#define PROFILE_FONT_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - FONT_SETTINGS(PROFILE_FONT_SETTINGS_INITIALIZE) -#undef PROFILE_FONT_SETTINGS_INITIALIZE - -#define APPEARANCE_CONTROL_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::TerminalSettings, type, name, ##__VA_ARGS__) - APPEARANCE_CONTROL_SETTINGS(APPEARANCE_CONTROL_SETTINGS_INITIALIZE) -#undef APPEARANCE_CONTROL_SETTINGS_INITIALIZE - + INHERITABLE_SETTING(Model::TerminalSettings, bool, SnapOnInput, true); + INHERITABLE_SETTING(Model::TerminalSettings, bool, AltGrAliasing, true); INHERITABLE_SETTING(Model::TerminalSettings, til::color, CursorColor, DEFAULT_CURSOR_COLOR); + INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Core::CursorStyle, CursorShape, Core::CursorStyle::Vintage); + INHERITABLE_SETTING(Model::TerminalSettings, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); + INHERITABLE_SETTING(Model::TerminalSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); + INHERITABLE_SETTING(Model::TerminalSettings, bool, CopyOnSelect, false); INHERITABLE_SETTING(Model::TerminalSettings, bool, InputServiceWarning, true); + INHERITABLE_SETTING(Model::TerminalSettings, bool, FocusFollowMouse, false); + INHERITABLE_SETTING(Model::TerminalSettings, bool, TrimBlockSelection, false); + INHERITABLE_SETTING(Model::TerminalSettings, bool, DetectURLs, true); INHERITABLE_SETTING(Model::TerminalSettings, Windows::Foundation::IReference, TabColor, nullptr); @@ -126,21 +118,42 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // ------------------------ End of Core Settings ----------------------- INHERITABLE_SETTING(Model::TerminalSettings, hstring, ProfileName); + INHERITABLE_SETTING(Model::TerminalSettings, bool, UseAcrylic, false); INHERITABLE_SETTING(Model::TerminalSettings, double, Opacity, UseAcrylic() ? 0.5 : 1.0); + INHERITABLE_SETTING(Model::TerminalSettings, hstring, Padding, DEFAULT_PADDING); + INHERITABLE_SETTING(Model::TerminalSettings, hstring, FontFace, DEFAULT_FONT_FACE); + INHERITABLE_SETTING(Model::TerminalSettings, int32_t, FontSize, DEFAULT_FONT_SIZE); + + INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Text::FontWeight, FontWeight); + INHERITABLE_SETTING(Model::TerminalSettings, IFontAxesMap, FontAxes); + INHERITABLE_SETTING(Model::TerminalSettings, IFontFeatureMap, FontFeatures); INHERITABLE_SETTING(Model::TerminalSettings, Model::ColorScheme, AppliedColorScheme); INHERITABLE_SETTING(Model::TerminalSettings, hstring, BackgroundImage); + INHERITABLE_SETTING(Model::TerminalSettings, double, BackgroundImageOpacity, 1.0); + INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill); INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center); INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center); INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::IKeyBindings, KeyBindings, nullptr); + INHERITABLE_SETTING(Model::TerminalSettings, hstring, Commandline); INHERITABLE_SETTING(Model::TerminalSettings, hstring, StartingDirectory); INHERITABLE_SETTING(Model::TerminalSettings, hstring, StartingTitle); INHERITABLE_SETTING(Model::TerminalSettings, bool, SuppressApplicationTitle); INHERITABLE_SETTING(Model::TerminalSettings, hstring, EnvironmentVariables); + INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible); + + INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale); + + INHERITABLE_SETTING(Model::TerminalSettings, bool, RetroTerminalEffect, false); + INHERITABLE_SETTING(Model::TerminalSettings, bool, ForceFullRepaintRendering, false); + INHERITABLE_SETTING(Model::TerminalSettings, bool, SoftwareRendering, false); + INHERITABLE_SETTING(Model::TerminalSettings, bool, ForceVTInput, false); + + INHERITABLE_SETTING(Model::TerminalSettings, hstring, PixelShaderPath); INHERITABLE_SETTING(Model::TerminalSettings, bool, IntenseIsBold); private: From 294c980b977c3f5bc1210c0cb774549391c3ef60 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 8 Oct 2021 12:14:11 -0700 Subject: [PATCH 09/15] reduce diff --- .../TerminalSettingsModel/Profile.cpp | 16 ++--- src/cascadia/TerminalSettingsModel/Profile.h | 4 +- .../TerminalSettingsModel/SettingsUtils.h | 60 +++++++++---------- .../TerminalSettingsModel/TerminalSettings.h | 1 - 4 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index 34dda86c6ee..fa28136f312 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -111,18 +111,18 @@ winrt::com_ptr Profile::CopySettings() const const auto fontInfo = FontConfig::CopyFontInfo(winrt::get_self(_FontInfo), weakProfile); const auto defaultAppearance = AppearanceConfig::CopyAppearance(winrt::get_self(_DefaultAppearance), weakProfile); - profile->_Name = _Name; - profile->_Source = _Source; - profile->_Hidden = _Hidden; - profile->_DefaultAppearance = *defaultAppearance; profile->_Deleted = _Deleted; profile->_Updates = _Updates; - profile->_Origin = _Origin; profile->_Guid = _Guid; + profile->_Name = _Name; + profile->_Source = _Source; + profile->_Hidden = _Hidden; profile->_TabColor = _TabColor; - profile->_FontInfo = *fontInfo; profile->_ForceFullRepaintRendering = _ForceFullRepaintRendering; profile->_SoftwareRendering = _SoftwareRendering; + profile->_Origin = _Origin; + profile->_FontInfo = *fontInfo; + profile->_DefaultAppearance = *defaultAppearance; #define PROFILE_SETTINGS_COPY(type, name, ...) \ profile->_##name = _##name; @@ -181,10 +181,10 @@ void Profile::LayerJson(const Json::Value& json) // Profile-specific Settings JsonUtils::GetValueForKey(json, NameKey, _Name); - JsonUtils::GetValueForKey(json, SourceKey, _Source); - JsonUtils::GetValueForKey(json, HiddenKey, _Hidden); JsonUtils::GetValueForKey(json, UpdatesKey, _Updates); JsonUtils::GetValueForKey(json, GuidKey, _Guid); + JsonUtils::GetValueForKey(json, HiddenKey, _Hidden); + JsonUtils::GetValueForKey(json, SourceKey, _Source); JsonUtils::GetValueForKey(json, TabColorKey, _TabColor); #define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index 59fcab4be07..24ea7295434 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -123,8 +123,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); #define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ - INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) + INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) + PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) #undef PROFILE_SETTINGS_INITIALIZE private: diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/SettingsUtils.h index 4d7e05bbcf0..b822c10c65c 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/SettingsUtils.h @@ -14,17 +14,17 @@ Author(s): --*/ #pragma once -#define GLOBAL_SETTINGS(X) \ - X(int32_t, InitialRows, 30) \ - X(int32_t, InitialCols, 80) \ - X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ - X(bool, CopyOnSelect, false) \ - X(bool, FocusFollowMouse, false) \ - X(bool, ForceFullRepaintRendering, false) \ - X(bool, SoftwareRendering, false) \ - X(bool, ForceVTInput, false) \ - X(bool, TrimBlockSelection, false) \ - X(bool, DetectURLs, true) \ +#define GLOBAL_SETTINGS(X) \ + X(int32_t, InitialRows, 30) \ + X(int32_t, InitialCols, 80) \ + X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ + X(bool, CopyOnSelect, false) \ + X(bool, FocusFollowMouse, false) \ + X(bool, ForceFullRepaintRendering, false) \ + X(bool, SoftwareRendering, false) \ + X(bool, ForceVTInput, false) \ + X(bool, TrimBlockSelection, false) \ + X(bool, DetectURLs, true) \ X(bool, AlwaysShowTabs, true) \ X(bool, ShowTitleInTitlebar, true) \ X(bool, ConfirmCloseAllTabs, true) \ @@ -54,21 +54,21 @@ Author(s): X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ X(bool, ShowAdminShield, true) -#define PROFILE_SETTINGS(X) \ - X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ - X(bool, SnapOnInput, true) \ - X(bool, AltGrAliasing, true) \ - X(bool, UseAcrylic, false) \ - X(hstring, Padding, DEFAULT_PADDING) \ - X(hstring, Commandline, L"cmd.exe") \ - X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ +#define PROFILE_SETTINGS(X) \ + X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ + X(bool, SnapOnInput, true) \ + X(bool, AltGrAliasing, true) \ + X(bool, UseAcrylic, false) \ + X(hstring, Padding, DEFAULT_PADDING) \ + X(hstring, Commandline, L"cmd.exe") \ + X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \ - X(hstring, StartingDirectory) \ - X(bool, SuppressApplicationTitle, false) \ - X(guid, ConnectionType) \ - X(hstring, Icon, L"\uE756") \ - X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ - X(hstring, TabTitle) \ + X(hstring, StartingDirectory) \ + X(bool, SuppressApplicationTitle, false) \ + X(guid, ConnectionType) \ + X(hstring, Icon, L"\uE756") \ + X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ + X(hstring, TabTitle) \ X(Model::BellStyle, BellStyle, BellStyle::Audible) #define FONT_SETTINGS(X) \ @@ -78,15 +78,15 @@ Author(s): X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) -#define APPEARANCE_SETTINGS(X) \ +#define APPEARANCE_SETTINGS(X) \ X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ X(double, BackgroundImageOpacity, 1.0) \ X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ X(bool, RetroTerminalEffect, false) \ X(hstring, PixelShaderPath) \ - X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ - X(hstring, ColorSchemeName, L"Campbell") \ - X(hstring, BackgroundImagePath) \ - X(Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright) \ + X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ + X(hstring, ColorSchemeName, L"Campbell") \ + X(hstring, BackgroundImagePath) \ + X(Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright) \ X(double, Opacity, 1.0) diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 05046f27f92..1c27f689ea8 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -17,7 +17,6 @@ Author(s): #include "TerminalSettings.g.h" #include "TerminalSettingsCreateResult.g.h" #include "IInheritable.h" -#include "SettingsUtils.h" #include "../inc/cppwinrt_utils.h" #include #include From 596ff265657e7c30a5c50c756ba4c2ebca486623 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 8 Oct 2021 12:25:34 -0700 Subject: [PATCH 10/15] rename --- .../TerminalSettingsModel/AppearanceConfig.cpp | 6 +++--- src/cascadia/TerminalSettingsModel/AppearanceConfig.h | 4 ++-- src/cascadia/TerminalSettingsModel/FontConfig.cpp | 6 +++--- src/cascadia/TerminalSettingsModel/FontConfig.h | 4 ++-- .../TerminalSettingsModel/GlobalAppSettings.cpp | 6 +++--- src/cascadia/TerminalSettingsModel/GlobalAppSettings.h | 4 ++-- .../{SettingsUtils.h => MTSMSettings.h} | 10 +++++----- .../Microsoft.Terminal.Settings.ModelLib.vcxproj | 2 +- ...icrosoft.Terminal.Settings.ModelLib.vcxproj.filters | 2 +- src/cascadia/TerminalSettingsModel/Profile.cpp | 6 +++--- src/cascadia/TerminalSettingsModel/Profile.h | 4 ++-- 11 files changed, 27 insertions(+), 27 deletions(-) rename src/cascadia/TerminalSettingsModel/{SettingsUtils.h => MTSMSettings.h} (95%) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index 6ca4a981f40..b04a1905a29 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -44,7 +44,7 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan #define APPEARANCE_SETTINGS_COPY(type, name, ...) \ appearance->_##name = source->_##name; - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) + MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) #undef APPEARANCE_SETTINGS_COPY return appearance; @@ -61,7 +61,7 @@ Json::Value AppearanceConfig::ToJson() const #define APPEARANCE_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) + MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) #undef APPEARANCE_SETTINGS_TO_JSON return json; @@ -88,7 +88,7 @@ void AppearanceConfig::LayerJson(const Json::Value& json) #define APPEARANCE_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) + MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) #undef APPEARANCE_SETTINGS_LAYER_JSON } diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index 39325967fb8..1dc8204455c 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -19,7 +19,7 @@ Author(s): #include "AppearanceConfig.g.h" #include "JsonUtils.h" #include "IInheritable.h" -#include "SettingsUtils.h" +#include "MTSMSettings.h" #include namespace winrt::Microsoft::Terminal::Settings::Model::implementation @@ -43,7 +43,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation #define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) - APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) + MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) #undef APPEARANCE_SETTINGS_INITIALIZE private: diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.cpp b/src/cascadia/TerminalSettingsModel/FontConfig.cpp index 74c195a92b4..faf857cb68a 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/FontConfig.cpp @@ -32,7 +32,7 @@ winrt::com_ptr FontConfig::CopyFontInfo(const FontConfig* source, wi #define FONT_SETTINGS_COPY(type, name, ...) \ fontInfo->_##name = source->_##name; - FONT_SETTINGS(FONT_SETTINGS_COPY) + MTSM_FONT_SETTINGS(FONT_SETTINGS_COPY) #undef FONT_SETTINGS_COPY return fontInfo; @@ -44,7 +44,7 @@ Json::Value FontConfig::ToJson() const #define FONT_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - FONT_SETTINGS(FONT_SETTINGS_TO_JSON) + MTSM_FONT_SETTINGS(FONT_SETTINGS_TO_JSON) #undef FONT_SETTINGS_TO_JSON return json; @@ -71,7 +71,7 @@ void FontConfig::LayerJson(const Json::Value& json) const auto fontInfoJson = json[JsonKey(FontInfoKey)]; #define FONT_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(fontInfoJson, name##Key, _##name); - FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) + MTSM_FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) #undef FONT_SETTINGS_LAYER_JSON } else diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.h b/src/cascadia/TerminalSettingsModel/FontConfig.h index e4b9cf18c7c..fcac66d48eb 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.h +++ b/src/cascadia/TerminalSettingsModel/FontConfig.h @@ -19,7 +19,7 @@ Author(s): #include "pch.h" #include "FontConfig.g.h" #include "JsonUtils.h" -#include "SettingsUtils.h" +#include "MTSMSettings.h" #include "../inc/cppwinrt_utils.h" #include "IInheritable.h" #include @@ -42,7 +42,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation #define FONT_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__) - FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) + MTSM_FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) #undef FONT_SETTINGS_INITIALIZE private: diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 65b71b618f4..4ea04b5794c 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -93,7 +93,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const #define GLOBAL_SETTINGS_COPY(type, name, ...) \ globals->_##name = _##name; - GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) + MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) #undef GLOBAL_SETTINGS_COPY if (_colorSchemes) @@ -160,7 +160,7 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) #define GLOBAL_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) + MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) #undef GLOBAL_SETTINGS_LAYER_JSON static constexpr std::array bindingsKeys{ LegacyKeybindingsKey, ActionsKey }; @@ -226,7 +226,7 @@ Json::Value GlobalAppSettings::ToJson() const #define GLOBAL_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) + MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) #undef GLOBAL_SETTINGS_TO_JSON // clang-format on diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 71c3ad19623..81754e5f5b5 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -17,7 +17,7 @@ Author(s): #include "GlobalAppSettings.g.h" #include "IInheritable.h" -#include "SettingsUtils.h" +#include "MTSMSettings.h" #include "ActionMap.h" #include "Command.h" @@ -66,7 +66,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation #define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) - GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) + MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) #undef GLOBAL_SETTINGS_INITIALIZE private: diff --git a/src/cascadia/TerminalSettingsModel/SettingsUtils.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h similarity index 95% rename from src/cascadia/TerminalSettingsModel/SettingsUtils.h rename to src/cascadia/TerminalSettingsModel/MTSMSettings.h index b822c10c65c..10404ac72f0 100644 --- a/src/cascadia/TerminalSettingsModel/SettingsUtils.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -3,7 +3,7 @@ Copyright (c) Microsoft Corporation Licensed under the MIT license. Module Name: -- SettingsUtils.h +- MTSMSettings.h Abstract: - @@ -14,7 +14,7 @@ Author(s): --*/ #pragma once -#define GLOBAL_SETTINGS(X) \ +#define MTSM_GLOBAL_SETTINGS(X) \ X(int32_t, InitialRows, 30) \ X(int32_t, InitialCols, 80) \ X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ @@ -54,7 +54,7 @@ Author(s): X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ X(bool, ShowAdminShield, true) -#define PROFILE_SETTINGS(X) \ +#define MTSM_PROFILE_SETTINGS(X) \ X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ X(bool, SnapOnInput, true) \ X(bool, AltGrAliasing, true) \ @@ -71,14 +71,14 @@ Author(s): X(hstring, TabTitle) \ X(Model::BellStyle, BellStyle, BellStyle::Audible) -#define FONT_SETTINGS(X) \ +#define MTSM_FONT_SETTINGS(X) \ X(hstring, FontFace, DEFAULT_FONT_FACE) \ X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ X(winrt::Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT) \ X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) -#define APPEARANCE_SETTINGS(X) \ +#define MTSM_APPEARANCE_SETTINGS(X) \ X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ X(double, BackgroundImageOpacity, 1.0) \ diff --git a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj index a3984865e2c..0bad267ce3d 100644 --- a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj +++ b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj @@ -51,7 +51,7 @@ GlobalAppSettings.idl - + diff --git a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters index 23fa63283ba..842f620b9db 100644 --- a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters +++ b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj.filters @@ -79,7 +79,7 @@ json - + diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index fa28136f312..cd7405d762b 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -126,7 +126,7 @@ winrt::com_ptr Profile::CopySettings() const #define PROFILE_SETTINGS_COPY(type, name, ...) \ profile->_##name = _##name; - PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) + MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) #undef PROFILE_SETTINGS_COPY if (_UnfocusedAppearance) @@ -189,7 +189,7 @@ void Profile::LayerJson(const Json::Value& json) #define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ JsonUtils::GetValueForKey(json, name##Key, _##name); - PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) + MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) #undef PROFILE_SETTINGS_LAYER_JSON if (json.isMember(JsonKey(UnfocusedAppearanceKey))) @@ -327,7 +327,7 @@ Json::Value Profile::ToJson() const #define PROFILE_SETTINGS_TO_JSON(type, name, ...) \ JsonUtils::SetValueForKey(json, name##Key, _##name); - PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) + MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) #undef PROFILE_SETTINGS_TO_JSON // Font settings diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index 24ea7295434..c4afee0af19 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -46,7 +46,7 @@ Author(s): #include "Profile.g.h" #include "IInheritable.h" -#include "SettingsUtils.h" +#include "MTSMSettings.h" #include "../inc/cppwinrt_utils.h" #include "JsonUtils.h" @@ -124,7 +124,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation #define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) - PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) + MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) #undef PROFILE_SETTINGS_INITIALIZE private: From cdaf18caca6821dbc7ff7798b025cd4926fe5a4c Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 8 Oct 2021 12:51:14 -0700 Subject: [PATCH 11/15] format --- src/cascadia/TerminalSettingsModel/MTSMSettings.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index 072d75ac1bd..d6441675d49 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -14,7 +14,7 @@ Author(s): --*/ #pragma once -#define MTSM_GLOBAL_SETTINGS(X) \ +#define MTSM_GLOBAL_SETTINGS(X) \ X(int32_t, InitialRows, 30) \ X(int32_t, InitialCols, 80) \ X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ @@ -54,13 +54,13 @@ Author(s): X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ X(bool, ShowAdminShield, true) -#define MTSM_PROFILE_SETTINGS(X) \ +#define MTSM_PROFILE_SETTINGS(X) \ X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ X(bool, SnapOnInput, true) \ X(bool, AltGrAliasing, true) \ X(bool, UseAcrylic, false) \ X(hstring, Padding, DEFAULT_PADDING) \ - X(hstring, Commandline, L"%SystemRoot%\\System32\\cmd.exe") \ + X(hstring, Commandline, L"%SystemRoot%\\System32\\cmd.exe") \ X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \ X(hstring, StartingDirectory) \ @@ -71,14 +71,14 @@ Author(s): X(hstring, TabTitle) \ X(Model::BellStyle, BellStyle, BellStyle::Audible) -#define MTSM_FONT_SETTINGS(X) \ +#define MTSM_FONT_SETTINGS(X) \ X(hstring, FontFace, DEFAULT_FONT_FACE) \ X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ X(winrt::Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT) \ X(IFontAxesMap, FontAxes) \ X(IFontFeatureMap, FontFeatures) -#define MTSM_APPEARANCE_SETTINGS(X) \ +#define MTSM_APPEARANCE_SETTINGS(X) \ X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ X(double, BackgroundImageOpacity, 1.0) \ From 9d3e0f37153e43237743437de7247b0a583f74a8 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 20 Oct 2021 13:12:27 -0700 Subject: [PATCH 12/15] json key in macro, padding fix --- .../AppearanceConfig.cpp | 22 +-- .../TerminalSettingsModel/AppearanceConfig.h | 2 +- .../TerminalSettingsModel/FontConfig.cpp | 15 +- .../TerminalSettingsModel/FontConfig.h | 2 +- .../GlobalAppSettings.cpp | 50 +----- .../TerminalSettingsModel/GlobalAppSettings.h | 2 +- .../TerminalSettingsModel/MTSMSettings.h | 147 +++++++++--------- .../TerminalSettingsModel/Profile.cpp | 33 ++-- src/cascadia/TerminalSettingsModel/Profile.h | 3 +- 9 files changed, 108 insertions(+), 168 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index 07e233fc025..999845d1e93 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -16,19 +16,7 @@ static constexpr std::string_view ForegroundKey{ "foreground" }; static constexpr std::string_view BackgroundKey{ "background" }; static constexpr std::string_view SelectionBackgroundKey{ "selectionBackground" }; static constexpr std::string_view CursorColorKey{ "cursorColor" }; -static constexpr std::string_view CursorShapeKey{ "cursorShape" }; -static constexpr std::string_view CursorHeightKey{ "cursorHeight" }; -static constexpr std::string_view BackgroundImagePathKey{ "backgroundImage" }; -static constexpr std::string_view ColorSchemeNameKey{ "colorScheme" }; -static constexpr std::string_view BackgroundImageOpacityKey{ "backgroundImageOpacity" }; -static constexpr std::string_view BackgroundImageStretchModeKey{ "backgroundImageStretchMode" }; -static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageAlignment" }; -static constexpr std::string_view RetroTerminalEffectKey{ "experimental.retroTerminalEffect" }; -static constexpr std::string_view PixelShaderPathKey{ "experimental.pixelShaderPath" }; -static constexpr std::string_view IntenseTextStyleKey{ "intenseTextStyle" }; -static constexpr std::string_view AdjustIndistinguishableColorsKey{ "adjustIndistinguishableColors" }; static constexpr std::string_view LegacyAcrylicTransparencyKey{ "acrylicOpacity" }; -static constexpr std::string_view OpacityKey{ "opacity" }; AppearanceConfig::AppearanceConfig(winrt::weak_ref sourceProfile) : _sourceProfile(std::move(sourceProfile)) @@ -43,7 +31,7 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan appearance->_SelectionBackground = source->_SelectionBackground; appearance->_CursorColor = source->_CursorColor; -#define APPEARANCE_SETTINGS_COPY(type, name, ...) \ +#define APPEARANCE_SETTINGS_COPY(type, name, jsonKey, ...) \ appearance->_##name = source->_##name; MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_COPY) #undef APPEARANCE_SETTINGS_COPY @@ -60,8 +48,8 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor); -#define APPEARANCE_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); +#define APPEARANCE_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ + JsonUtils::SetValueForKey(json, jsonKey, _##name); MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_TO_JSON) #undef APPEARANCE_SETTINGS_TO_JSON @@ -88,8 +76,8 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, LegacyAcrylicTransparencyKey, _Opacity); -#define APPEARANCE_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); +#define APPEARANCE_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ + JsonUtils::GetValueForKey(json, jsonKey, _##name); MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_LAYER_JSON) #undef APPEARANCE_SETTINGS_LAYER_JSON } diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index 1dc8204455c..41e29497437 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -41,7 +41,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); -#define APPEARANCE_SETTINGS_INITIALIZE(type, name, ...) \ +#define APPEARANCE_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) #undef APPEARANCE_SETTINGS_INITIALIZE diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.cpp b/src/cascadia/TerminalSettingsModel/FontConfig.cpp index faf857cb68a..62ebc5aacec 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/FontConfig.cpp @@ -12,11 +12,6 @@ using namespace Microsoft::Terminal::Settings::Model; using namespace winrt::Microsoft::Terminal::Settings::Model::implementation; static constexpr std::string_view FontInfoKey{ "font" }; -static constexpr std::string_view FontFaceKey{ "face" }; -static constexpr std::string_view FontSizeKey{ "size" }; -static constexpr std::string_view FontWeightKey{ "weight" }; -static constexpr std::string_view FontFeaturesKey{ "features" }; -static constexpr std::string_view FontAxesKey{ "axes" }; static constexpr std::string_view LegacyFontFaceKey{ "fontFace" }; static constexpr std::string_view LegacyFontSizeKey{ "fontSize" }; static constexpr std::string_view LegacyFontWeightKey{ "fontWeight" }; @@ -30,7 +25,7 @@ winrt::com_ptr FontConfig::CopyFontInfo(const FontConfig* source, wi { auto fontInfo{ winrt::make_self(std::move(sourceProfile)) }; -#define FONT_SETTINGS_COPY(type, name, ...) \ +#define FONT_SETTINGS_COPY(type, name, jsonKey, ...) \ fontInfo->_##name = source->_##name; MTSM_FONT_SETTINGS(FONT_SETTINGS_COPY) #undef FONT_SETTINGS_COPY @@ -42,8 +37,8 @@ Json::Value FontConfig::ToJson() const { Json::Value json{ Json::ValueType::objectValue }; -#define FONT_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); +#define FONT_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ + JsonUtils::SetValueForKey(json, jsonKey, _##name); MTSM_FONT_SETTINGS(FONT_SETTINGS_TO_JSON) #undef FONT_SETTINGS_TO_JSON @@ -69,8 +64,8 @@ void FontConfig::LayerJson(const Json::Value& json) { // A font object is defined, use that const auto fontInfoJson = json[JsonKey(FontInfoKey)]; -#define FONT_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(fontInfoJson, name##Key, _##name); +#define FONT_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ + JsonUtils::GetValueForKey(fontInfoJson, jsonKey, _##name); MTSM_FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) #undef FONT_SETTINGS_LAYER_JSON } diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.h b/src/cascadia/TerminalSettingsModel/FontConfig.h index fcac66d48eb..db69fd08ffb 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.h +++ b/src/cascadia/TerminalSettingsModel/FontConfig.h @@ -40,7 +40,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation Model::Profile SourceProfile(); -#define FONT_SETTINGS_INITIALIZE(type, name, ...) \ +#define FONT_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__) MTSM_FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) #undef FONT_SETTINGS_INITIALIZE diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 4ea04b5794c..a9de4072277 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -18,47 +18,7 @@ using namespace winrt::Microsoft::UI::Xaml::Controls; static constexpr std::string_view LegacyKeybindingsKey{ "keybindings" }; static constexpr std::string_view ActionsKey{ "actions" }; static constexpr std::string_view DefaultProfileKey{ "defaultProfile" }; -static constexpr std::string_view AlwaysShowTabsKey{ "alwaysShowTabs" }; -static constexpr std::string_view InitialRowsKey{ "initialRows" }; -static constexpr std::string_view InitialColsKey{ "initialCols" }; -static constexpr std::string_view InitialPositionKey{ "initialPosition" }; -static constexpr std::string_view CenterOnLaunchKey{ "centerOnLaunch" }; -static constexpr std::string_view ShowTitleInTitlebarKey{ "showTerminalTitleInTitlebar" }; -static constexpr std::string_view LanguageKey{ "language" }; -static constexpr std::string_view ThemeKey{ "theme" }; -static constexpr std::string_view TabWidthModeKey{ "tabWidthMode" }; -static constexpr std::string_view UseAcrylicInTabRowKey{ "useAcrylicInTabRow" }; -static constexpr std::string_view ShowTabsInTitlebarKey{ "showTabsInTitlebar" }; -static constexpr std::string_view WordDelimitersKey{ "wordDelimiters" }; -static constexpr std::string_view InputServiceWarningKey{ "inputServiceWarning" }; -static constexpr std::string_view CopyOnSelectKey{ "copyOnSelect" }; -static constexpr std::string_view CopyFormattingKey{ "copyFormatting" }; -static constexpr std::string_view WarnAboutLargePasteKey{ "largePasteWarning" }; -static constexpr std::string_view WarnAboutMultiLinePasteKey{ "multiLinePasteWarning" }; -static constexpr std::string_view LaunchModeKey{ "launchMode" }; -static constexpr std::string_view ConfirmCloseAllTabsKey{ "confirmCloseAllTabs" }; -static constexpr std::string_view SnapToGridOnResizeKey{ "snapToGridOnResize" }; -static constexpr std::string_view StartOnUserLoginKey{ "startOnUserLogin" }; -static constexpr std::string_view FirstWindowPreferenceKey{ "firstWindowPreference" }; -static constexpr std::string_view AlwaysOnTopKey{ "alwaysOnTop" }; static constexpr std::string_view LegacyUseTabSwitcherModeKey{ "useTabSwitcher" }; -static constexpr std::string_view TabSwitcherModeKey{ "tabSwitcherMode" }; -static constexpr std::string_view DisableAnimationsKey{ "disableAnimations" }; -static constexpr std::string_view StartupActionsKey{ "startupActions" }; -static constexpr std::string_view FocusFollowMouseKey{ "focusFollowMouse" }; -static constexpr std::string_view WindowingBehaviorKey{ "windowingBehavior" }; -static constexpr std::string_view TrimBlockSelectionKey{ "trimBlockSelection" }; -static constexpr std::string_view AlwaysShowNotificationIconKey{ "alwaysShowNotificationIcon" }; -static constexpr std::string_view MinimizeToNotificationAreaKey{ "minimizeToNotificationArea" }; -static constexpr std::string_view DisabledProfileSourcesKey{ "disabledProfileSources" }; -static constexpr std::string_view ShowAdminShieldKey{ "showAdminShield" }; - -static constexpr std::string_view DebugFeaturesEnabledKey{ "debugFeatures" }; - -static constexpr std::string_view ForceFullRepaintRenderingKey{ "experimental.rendering.forceFullRepaint" }; -static constexpr std::string_view SoftwareRenderingKey{ "experimental.rendering.software" }; -static constexpr std::string_view ForceVTInputKey{ "experimental.input.forceVT" }; -static constexpr std::string_view DetectURLsKey{ "experimental.detectURLs" }; // Method Description: // - Copies any extraneous data from the parent before completing a CreateChild call @@ -91,7 +51,7 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_actionMap = _actionMap->Copy(); globals->_keybindingsWarnings = _keybindingsWarnings; -#define GLOBAL_SETTINGS_COPY(type, name, ...) \ +#define GLOBAL_SETTINGS_COPY(type, name, jsonKey, ...) \ globals->_##name = _##name; MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_COPY) #undef GLOBAL_SETTINGS_COPY @@ -158,8 +118,8 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) // "useTabSwitcher", but prefer "tabSwitcherMode" JsonUtils::GetValueForKey(json, LegacyUseTabSwitcherModeKey, _TabSwitcherMode); -#define GLOBAL_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); +#define GLOBAL_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ + JsonUtils::GetValueForKey(json, jsonKey, _##name); MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_LAYER_JSON) #undef GLOBAL_SETTINGS_LAYER_JSON @@ -224,8 +184,8 @@ Json::Value GlobalAppSettings::ToJson() const // clang-format off JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); -#define GLOBAL_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); +#define GLOBAL_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ + JsonUtils::SetValueForKey(json, jsonKey, _##name); MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) #undef GLOBAL_SETTINGS_TO_JSON diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 81754e5f5b5..14584b26a72 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -64,7 +64,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, UnparsedDefaultProfile, L""); -#define GLOBAL_SETTINGS_INITIALIZE(type, name, ...) \ +#define GLOBAL_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) #undef GLOBAL_SETTINGS_INITIALIZE diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index d6441675d49..e69f26ac32a 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -6,88 +6,91 @@ Module Name: - MTSMSettings.h Abstract: -- +- Contains most of the settings within Terminal Settings Model (global, profile, font, appearance) +- To add a new setting to any one of those classes, simply add it to the respective list below, following the macro format Author(s): -- +- Pankaj Bhojwani - October 2021 --*/ #pragma once +// Macro format (defaultArgs are optional): +// (type, name, jsonKey, defaultArgs) + #define MTSM_GLOBAL_SETTINGS(X) \ - X(int32_t, InitialRows, 30) \ - X(int32_t, InitialCols, 80) \ - X(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS) \ - X(bool, CopyOnSelect, false) \ - X(bool, FocusFollowMouse, false) \ - X(bool, ForceFullRepaintRendering, false) \ - X(bool, SoftwareRendering, false) \ - X(bool, ForceVTInput, false) \ - X(bool, TrimBlockSelection, false) \ - X(bool, DetectURLs, true) \ - X(bool, AlwaysShowTabs, true) \ - X(bool, ShowTitleInTitlebar, true) \ - X(bool, ConfirmCloseAllTabs, true) \ - X(hstring, Language) \ - X(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default) \ - X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \ - X(bool, UseAcrylicInTabRow, false) \ - X(bool, ShowTabsInTitlebar, true) \ - X(bool, InputServiceWarning, true) \ - X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0) \ - X(bool, WarnAboutLargePaste, true) \ - X(bool, WarnAboutMultiLinePaste, true) \ - X(Model::LaunchPosition, InitialPosition, nullptr, nullptr) \ - X(bool, CenterOnLaunch, false) \ - X(Model::FirstWindowPreference, FirstWindowPreference, FirstWindowPreference::DefaultProfile) \ - X(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode) \ - X(bool, SnapToGridOnResize, true) \ - X(bool, DebugFeaturesEnabled, debugFeaturesDefault) \ - X(bool, StartOnUserLogin, false) \ - X(bool, AlwaysOnTop, false) \ - X(Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder) \ - X(bool, DisableAnimations, false) \ - X(hstring, StartupActions, L"") \ - X(Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew) \ - X(bool, MinimizeToNotificationArea, false) \ - X(bool, AlwaysShowNotificationIcon, false) \ - X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, nullptr) \ - X(bool, ShowAdminShield, true) + X(int32_t, InitialRows, "initialRows", 30) \ + X(int32_t, InitialCols, "initialCols", 80) \ + X(hstring, WordDelimiters, "wordDelimiters", DEFAULT_WORD_DELIMITERS) \ + X(bool, CopyOnSelect, "copyOnSelect", false) \ + X(bool, FocusFollowMouse, "focusFollowMouse", false) \ + X(bool, ForceFullRepaintRendering, "experimental.rendering.forceFullRepaint", false) \ + X(bool, SoftwareRendering, "experimental.rendering.software", false) \ + X(bool, ForceVTInput, "experimental.input.forceVT", false) \ + X(bool, TrimBlockSelection, "trimBlockSelection", false) \ + X(bool, DetectURLs, "experimental.detectURLs", true) \ + X(bool, AlwaysShowTabs, "alwaysShowTabs", true) \ + X(bool, ShowTitleInTitlebar, "showTerminalTitleInTitlebar", true) \ + X(bool, ConfirmCloseAllTabs, "confirmCloseAllTabs", true) \ + X(hstring, Language, "language") \ + X(winrt::Windows::UI::Xaml::ElementTheme, Theme, "theme", winrt::Windows::UI::Xaml::ElementTheme::Default) \ + X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, "tabWidthMode", winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \ + X(bool, UseAcrylicInTabRow, "useAcrylicInTabRow", false) \ + X(bool, ShowTabsInTitlebar, "showTabsInTitlebar", true) \ + X(bool, InputServiceWarning, "inputServiceWarning", true) \ + X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, "copyFormatting", 0) \ + X(bool, WarnAboutLargePaste, "largePasteWarning", true) \ + X(bool, WarnAboutMultiLinePaste, "multiLinePasteWarning", true) \ + X(Model::LaunchPosition, InitialPosition, "initialPosition", nullptr, nullptr) \ + X(bool, CenterOnLaunch, "centerOnLaunch", false) \ + X(Model::FirstWindowPreference, FirstWindowPreference, "firstWindowPreference", FirstWindowPreference::DefaultProfile) \ + X(Model::LaunchMode, LaunchMode, "launchMode", LaunchMode::DefaultMode) \ + X(bool, SnapToGridOnResize, "snapToGridOnResize", true) \ + X(bool, DebugFeaturesEnabled, "debugFeatures", debugFeaturesDefault) \ + X(bool, StartOnUserLogin, "startOnUserLogin", false) \ + X(bool, AlwaysOnTop, "alwaysOnTop", false) \ + X(Model::TabSwitcherMode, TabSwitcherMode, "tabSwitcherMode", Model::TabSwitcherMode::InOrder) \ + X(bool, DisableAnimations, "disableAnimations", false) \ + X(hstring, StartupActions, "startupActions", L"") \ + X(Model::WindowingMode, WindowingBehavior, "windowingBehavior", Model::WindowingMode::UseNew) \ + X(bool, MinimizeToNotificationArea, "minimizeToNotificationArea", false) \ + X(bool, AlwaysShowNotificationIcon, "alwaysShowNotificationIcon", false) \ + X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, "disabledProfileSources", nullptr) \ + X(bool, ShowAdminShield, "showAdminShield", true) #define MTSM_PROFILE_SETTINGS(X) \ - X(int32_t, HistorySize, DEFAULT_HISTORY_SIZE) \ - X(bool, SnapOnInput, true) \ - X(bool, AltGrAliasing, true) \ - X(bool, UseAcrylic, false) \ - X(hstring, Padding, DEFAULT_PADDING) \ - X(hstring, Commandline, L"%SystemRoot%\\System32\\cmd.exe") \ - X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, Microsoft::Terminal::Control::ScrollbarState::Visible) \ - X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \ - X(hstring, StartingDirectory) \ - X(bool, SuppressApplicationTitle, false) \ - X(guid, ConnectionType) \ - X(hstring, Icon, L"\uE756") \ - X(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful) \ - X(hstring, TabTitle) \ - X(Model::BellStyle, BellStyle, BellStyle::Audible) + X(int32_t, HistorySize, "historySize", DEFAULT_HISTORY_SIZE) \ + X(bool, SnapOnInput, "snapOnInput", true) \ + X(bool, AltGrAliasing, "altGrAliasing", true) \ + X(bool, UseAcrylic, "useAcrylic", false) \ + X(hstring, Commandline, "commandline", L"%SystemRoot%\\System32\\cmd.exe") \ + X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, "scrollbarState", Microsoft::Terminal::Control::ScrollbarState::Visible) \ + X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, "antialiasingMode", Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \ + X(hstring, StartingDirectory, "startingDirectory") \ + X(bool, SuppressApplicationTitle, "suppressApplicationTitle", false) \ + X(guid, ConnectionType, "connectionType") \ + X(hstring, Icon, "icon", L"\uE756") \ + X(CloseOnExitMode, CloseOnExit, "closeOnExit", CloseOnExitMode::Graceful) \ + X(hstring, TabTitle, "tabTitle") \ + X(Model::BellStyle, BellStyle, "bellStyle", BellStyle::Audible) #define MTSM_FONT_SETTINGS(X) \ - X(hstring, FontFace, DEFAULT_FONT_FACE) \ - X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ - X(winrt::Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT) \ - X(IFontAxesMap, FontAxes) \ - X(IFontFeatureMap, FontFeatures) + X(hstring, FontFace, "face", DEFAULT_FONT_FACE) \ + X(int32_t, FontSize, "size", DEFAULT_FONT_SIZE) \ + X(winrt::Windows::UI::Text::FontWeight, FontWeight, "weight", DEFAULT_FONT_WEIGHT) \ + X(IFontAxesMap, FontAxes, "axes") \ + X(IFontFeatureMap, FontFeatures, "features") #define MTSM_APPEARANCE_SETTINGS(X) \ - X(Core::CursorStyle, CursorShape, Core::CursorStyle::Bar) \ - X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \ - X(double, BackgroundImageOpacity, 1.0) \ - X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ - X(bool, RetroTerminalEffect, false) \ - X(hstring, PixelShaderPath) \ - X(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ - X(hstring, ColorSchemeName, L"Campbell") \ - X(hstring, BackgroundImagePath) \ - X(Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::Bright) \ - X(double, Opacity, 1.0) \ - X(bool, AdjustIndistinguishableColors, true) + X(Core::CursorStyle, CursorShape, "cursorShape", Core::CursorStyle::Bar) \ + X(uint32_t, CursorHeight, "cursorHeight", DEFAULT_CURSOR_HEIGHT) \ + X(double, BackgroundImageOpacity, "backgroundImageOpacity", 1.0) \ + X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, "backgroundImageStretchMode", winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ + X(bool, RetroTerminalEffect, "experimental.retroTerminalEffect", false) \ + X(hstring, PixelShaderPath, "experimental.pixelShaderPath") \ + X(ConvergedAlignment, BackgroundImageAlignment, "backgroundImageAlignment", ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ + X(hstring, ColorSchemeName, "colorScheme", L"Campbell") \ + X(hstring, BackgroundImagePath, "backgroundImage") \ + X(Model::IntenseStyle, IntenseTextStyle, "intenseTextStyle", Model::IntenseStyle::Bright) \ + X(double, Opacity, "opacity", 1.0) \ + X(bool, AdjustIndistinguishableColors, "adjustIndistinguishableColors", true) diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index cd7405d762b..c7b104e9a04 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -26,24 +26,9 @@ static constexpr std::string_view GuidKey{ "guid" }; static constexpr std::string_view SourceKey{ "source" }; static constexpr std::string_view HiddenKey{ "hidden" }; -static constexpr std::string_view TabTitleKey{ "tabTitle" }; -static constexpr std::string_view SuppressApplicationTitleKey{ "suppressApplicationTitle" }; -static constexpr std::string_view HistorySizeKey{ "historySize" }; -static constexpr std::string_view SnapOnInputKey{ "snapOnInput" }; -static constexpr std::string_view AltGrAliasingKey{ "altGrAliasing" }; - -static constexpr std::string_view ConnectionTypeKey{ "connectionType" }; -static constexpr std::string_view CommandlineKey{ "commandline" }; static constexpr std::string_view FontInfoKey{ "font" }; -static constexpr std::string_view UseAcrylicKey{ "useAcrylic" }; -static constexpr std::string_view ScrollStateKey{ "scrollbarState" }; -static constexpr std::string_view CloseOnExitKey{ "closeOnExit" }; static constexpr std::string_view PaddingKey{ "padding" }; -static constexpr std::string_view StartingDirectoryKey{ "startingDirectory" }; -static constexpr std::string_view IconKey{ "icon" }; -static constexpr std::string_view AntialiasingModeKey{ "antialiasingMode" }; static constexpr std::string_view TabColorKey{ "tabColor" }; -static constexpr std::string_view BellStyleKey{ "bellStyle" }; static constexpr std::string_view UnfocusedAppearanceKey{ "unfocusedAppearance" }; Profile::Profile(guid guid) noexcept : @@ -118,13 +103,14 @@ winrt::com_ptr Profile::CopySettings() const profile->_Source = _Source; profile->_Hidden = _Hidden; profile->_TabColor = _TabColor; + profile->_Padding = _Padding; profile->_ForceFullRepaintRendering = _ForceFullRepaintRendering; profile->_SoftwareRendering = _SoftwareRendering; profile->_Origin = _Origin; profile->_FontInfo = *fontInfo; profile->_DefaultAppearance = *defaultAppearance; -#define PROFILE_SETTINGS_COPY(type, name, ...) \ +#define PROFILE_SETTINGS_COPY(type, name, jsonKey, ...) \ profile->_##name = _##name; MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_COPY) #undef PROFILE_SETTINGS_COPY @@ -185,10 +171,15 @@ void Profile::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, GuidKey, _Guid); JsonUtils::GetValueForKey(json, HiddenKey, _Hidden); JsonUtils::GetValueForKey(json, SourceKey, _Source); + + // Padding was never specified as an integer, but it was a common working mistake. + // Allow it to be permissive. + JsonUtils::GetValueForKey(json, PaddingKey, _Padding, JsonUtils::OptionalConverter>{}); + JsonUtils::GetValueForKey(json, TabColorKey, _TabColor); -#define PROFILE_SETTINGS_LAYER_JSON(type, name, ...) \ - JsonUtils::GetValueForKey(json, name##Key, _##name); +#define PROFILE_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ + JsonUtils::GetValueForKey(json, jsonKey, _##name); MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_LAYER_JSON) #undef PROFILE_SETTINGS_LAYER_JSON @@ -323,10 +314,12 @@ Json::Value Profile::ToJson() const JsonUtils::SetValueForKey(json, SourceKey, writeBasicSettings ? Source() : _Source); // PermissiveStringConverter is unnecessary for serialization + JsonUtils::SetValueForKey(json, PaddingKey, _Padding); + JsonUtils::SetValueForKey(json, TabColorKey, _TabColor); -#define PROFILE_SETTINGS_TO_JSON(type, name, ...) \ - JsonUtils::SetValueForKey(json, name##Key, _##name); +#define PROFILE_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ + JsonUtils::SetValueForKey(json, jsonKey, _##name); MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_TO_JSON) #undef PROFILE_SETTINGS_TO_JSON diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index c4afee0af19..dc58c769eb1 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -110,6 +110,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // Nullable/optional settings INHERITABLE_NULLABLE_SETTING(Model::Profile, Microsoft::Terminal::Core::Color, TabColor, nullptr); + INHERITABLE_SETTING(Model::Profile, hstring, Padding, DEFAULT_PADDING); INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); // Global settings @@ -122,7 +123,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::Profile, bool, Hidden, false); INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); -#define PROFILE_SETTINGS_INITIALIZE(type, name, ...) \ +#define PROFILE_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) MTSM_PROFILE_SETTINGS(PROFILE_SETTINGS_INITIALIZE) #undef PROFILE_SETTINGS_INITIALIZE From 4473770eca3e0713c6b107f13114bba977702977 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 20 Oct 2021 13:17:53 -0700 Subject: [PATCH 13/15] format --- .../TerminalSettingsModel/MTSMSettings.h | 128 +++++++++--------- src/cascadia/TerminalSettingsModel/Profile.h | 4 +- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index e69f26ac32a..1e61bbef213 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -18,79 +18,79 @@ Author(s): // Macro format (defaultArgs are optional): // (type, name, jsonKey, defaultArgs) -#define MTSM_GLOBAL_SETTINGS(X) \ - X(int32_t, InitialRows, "initialRows", 30) \ - X(int32_t, InitialCols, "initialCols", 80) \ - X(hstring, WordDelimiters, "wordDelimiters", DEFAULT_WORD_DELIMITERS) \ +#define MTSM_GLOBAL_SETTINGS(X) \ + X(int32_t, InitialRows, "initialRows", 30) \ + X(int32_t, InitialCols, "initialCols", 80) \ + X(hstring, WordDelimiters, "wordDelimiters", DEFAULT_WORD_DELIMITERS) \ X(bool, CopyOnSelect, "copyOnSelect", false) \ - X(bool, FocusFollowMouse, "focusFollowMouse", false) \ - X(bool, ForceFullRepaintRendering, "experimental.rendering.forceFullRepaint", false) \ - X(bool, SoftwareRendering, "experimental.rendering.software", false) \ - X(bool, ForceVTInput, "experimental.input.forceVT", false) \ - X(bool, TrimBlockSelection, "trimBlockSelection", false) \ - X(bool, DetectURLs, "experimental.detectURLs", true) \ - X(bool, AlwaysShowTabs, "alwaysShowTabs", true) \ - X(bool, ShowTitleInTitlebar, "showTerminalTitleInTitlebar", true) \ - X(bool, ConfirmCloseAllTabs, "confirmCloseAllTabs", true) \ - X(hstring, Language, "language") \ - X(winrt::Windows::UI::Xaml::ElementTheme, Theme, "theme", winrt::Windows::UI::Xaml::ElementTheme::Default) \ + X(bool, FocusFollowMouse, "focusFollowMouse", false) \ + X(bool, ForceFullRepaintRendering, "experimental.rendering.forceFullRepaint", false) \ + X(bool, SoftwareRendering, "experimental.rendering.software", false) \ + X(bool, ForceVTInput, "experimental.input.forceVT", false) \ + X(bool, TrimBlockSelection, "trimBlockSelection", false) \ + X(bool, DetectURLs, "experimental.detectURLs", true) \ + X(bool, AlwaysShowTabs, "alwaysShowTabs", true) \ + X(bool, ShowTitleInTitlebar, "showTerminalTitleInTitlebar", true) \ + X(bool, ConfirmCloseAllTabs, "confirmCloseAllTabs", true) \ + X(hstring, Language, "language") \ + X(winrt::Windows::UI::Xaml::ElementTheme, Theme, "theme", winrt::Windows::UI::Xaml::ElementTheme::Default) \ X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, "tabWidthMode", winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \ - X(bool, UseAcrylicInTabRow, "useAcrylicInTabRow", false) \ - X(bool, ShowTabsInTitlebar, "showTabsInTitlebar", true) \ - X(bool, InputServiceWarning, "inputServiceWarning", true) \ - X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, "copyFormatting", 0) \ - X(bool, WarnAboutLargePaste, "largePasteWarning", true) \ - X(bool, WarnAboutMultiLinePaste, "multiLinePasteWarning", true) \ - X(Model::LaunchPosition, InitialPosition, "initialPosition", nullptr, nullptr) \ - X(bool, CenterOnLaunch, "centerOnLaunch", false) \ - X(Model::FirstWindowPreference, FirstWindowPreference, "firstWindowPreference", FirstWindowPreference::DefaultProfile) \ - X(Model::LaunchMode, LaunchMode, "launchMode", LaunchMode::DefaultMode) \ - X(bool, SnapToGridOnResize, "snapToGridOnResize", true) \ - X(bool, DebugFeaturesEnabled, "debugFeatures", debugFeaturesDefault) \ - X(bool, StartOnUserLogin, "startOnUserLogin", false) \ - X(bool, AlwaysOnTop, "alwaysOnTop", false) \ - X(Model::TabSwitcherMode, TabSwitcherMode, "tabSwitcherMode", Model::TabSwitcherMode::InOrder) \ - X(bool, DisableAnimations, "disableAnimations", false) \ - X(hstring, StartupActions, "startupActions", L"") \ - X(Model::WindowingMode, WindowingBehavior, "windowingBehavior", Model::WindowingMode::UseNew) \ - X(bool, MinimizeToNotificationArea, "minimizeToNotificationArea", false) \ - X(bool, AlwaysShowNotificationIcon, "alwaysShowNotificationIcon", false) \ - X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, "disabledProfileSources", nullptr) \ + X(bool, UseAcrylicInTabRow, "useAcrylicInTabRow", false) \ + X(bool, ShowTabsInTitlebar, "showTabsInTitlebar", true) \ + X(bool, InputServiceWarning, "inputServiceWarning", true) \ + X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, "copyFormatting", 0) \ + X(bool, WarnAboutLargePaste, "largePasteWarning", true) \ + X(bool, WarnAboutMultiLinePaste, "multiLinePasteWarning", true) \ + X(Model::LaunchPosition, InitialPosition, "initialPosition", nullptr, nullptr) \ + X(bool, CenterOnLaunch, "centerOnLaunch", false) \ + X(Model::FirstWindowPreference, FirstWindowPreference, "firstWindowPreference", FirstWindowPreference::DefaultProfile) \ + X(Model::LaunchMode, LaunchMode, "launchMode", LaunchMode::DefaultMode) \ + X(bool, SnapToGridOnResize, "snapToGridOnResize", true) \ + X(bool, DebugFeaturesEnabled, "debugFeatures", debugFeaturesDefault) \ + X(bool, StartOnUserLogin, "startOnUserLogin", false) \ + X(bool, AlwaysOnTop, "alwaysOnTop", false) \ + X(Model::TabSwitcherMode, TabSwitcherMode, "tabSwitcherMode", Model::TabSwitcherMode::InOrder) \ + X(bool, DisableAnimations, "disableAnimations", false) \ + X(hstring, StartupActions, "startupActions", L"") \ + X(Model::WindowingMode, WindowingBehavior, "windowingBehavior", Model::WindowingMode::UseNew) \ + X(bool, MinimizeToNotificationArea, "minimizeToNotificationArea", false) \ + X(bool, AlwaysShowNotificationIcon, "alwaysShowNotificationIcon", false) \ + X(winrt::Windows::Foundation::Collections::IVector, DisabledProfileSources, "disabledProfileSources", nullptr) \ X(bool, ShowAdminShield, "showAdminShield", true) -#define MTSM_PROFILE_SETTINGS(X) \ - X(int32_t, HistorySize, "historySize", DEFAULT_HISTORY_SIZE) \ - X(bool, SnapOnInput, "snapOnInput", true) \ - X(bool, AltGrAliasing, "altGrAliasing", true) \ - X(bool, UseAcrylic, "useAcrylic", false) \ - X(hstring, Commandline, "commandline", L"%SystemRoot%\\System32\\cmd.exe") \ - X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, "scrollbarState", Microsoft::Terminal::Control::ScrollbarState::Visible) \ +#define MTSM_PROFILE_SETTINGS(X) \ + X(int32_t, HistorySize, "historySize", DEFAULT_HISTORY_SIZE) \ + X(bool, SnapOnInput, "snapOnInput", true) \ + X(bool, AltGrAliasing, "altGrAliasing", true) \ + X(bool, UseAcrylic, "useAcrylic", false) \ + X(hstring, Commandline, "commandline", L"%SystemRoot%\\System32\\cmd.exe") \ + X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, "scrollbarState", Microsoft::Terminal::Control::ScrollbarState::Visible) \ X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, "antialiasingMode", Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \ - X(hstring, StartingDirectory, "startingDirectory") \ - X(bool, SuppressApplicationTitle, "suppressApplicationTitle", false) \ - X(guid, ConnectionType, "connectionType") \ - X(hstring, Icon, "icon", L"\uE756") \ - X(CloseOnExitMode, CloseOnExit, "closeOnExit", CloseOnExitMode::Graceful) \ - X(hstring, TabTitle, "tabTitle") \ + X(hstring, StartingDirectory, "startingDirectory") \ + X(bool, SuppressApplicationTitle, "suppressApplicationTitle", false) \ + X(guid, ConnectionType, "connectionType") \ + X(hstring, Icon, "icon", L"\uE756") \ + X(CloseOnExitMode, CloseOnExit, "closeOnExit", CloseOnExitMode::Graceful) \ + X(hstring, TabTitle, "tabTitle") \ X(Model::BellStyle, BellStyle, "bellStyle", BellStyle::Audible) -#define MTSM_FONT_SETTINGS(X) \ - X(hstring, FontFace, "face", DEFAULT_FONT_FACE) \ - X(int32_t, FontSize, "size", DEFAULT_FONT_SIZE) \ +#define MTSM_FONT_SETTINGS(X) \ + X(hstring, FontFace, "face", DEFAULT_FONT_FACE) \ + X(int32_t, FontSize, "size", DEFAULT_FONT_SIZE) \ X(winrt::Windows::UI::Text::FontWeight, FontWeight, "weight", DEFAULT_FONT_WEIGHT) \ - X(IFontAxesMap, FontAxes, "axes") \ + X(IFontAxesMap, FontAxes, "axes") \ X(IFontFeatureMap, FontFeatures, "features") -#define MTSM_APPEARANCE_SETTINGS(X) \ - X(Core::CursorStyle, CursorShape, "cursorShape", Core::CursorStyle::Bar) \ - X(uint32_t, CursorHeight, "cursorHeight", DEFAULT_CURSOR_HEIGHT) \ - X(double, BackgroundImageOpacity, "backgroundImageOpacity", 1.0) \ +#define MTSM_APPEARANCE_SETTINGS(X) \ + X(Core::CursorStyle, CursorShape, "cursorShape", Core::CursorStyle::Bar) \ + X(uint32_t, CursorHeight, "cursorHeight", DEFAULT_CURSOR_HEIGHT) \ + X(double, BackgroundImageOpacity, "backgroundImageOpacity", 1.0) \ X(winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, "backgroundImageStretchMode", winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill) \ - X(bool, RetroTerminalEffect, "experimental.retroTerminalEffect", false) \ - X(hstring, PixelShaderPath, "experimental.pixelShaderPath") \ - X(ConvergedAlignment, BackgroundImageAlignment, "backgroundImageAlignment", ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ - X(hstring, ColorSchemeName, "colorScheme", L"Campbell") \ - X(hstring, BackgroundImagePath, "backgroundImage") \ - X(Model::IntenseStyle, IntenseTextStyle, "intenseTextStyle", Model::IntenseStyle::Bright) \ - X(double, Opacity, "opacity", 1.0) \ + X(bool, RetroTerminalEffect, "experimental.retroTerminalEffect", false) \ + X(hstring, PixelShaderPath, "experimental.pixelShaderPath") \ + X(ConvergedAlignment, BackgroundImageAlignment, "backgroundImageAlignment", ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center) \ + X(hstring, ColorSchemeName, "colorScheme", L"Campbell") \ + X(hstring, BackgroundImagePath, "backgroundImage") \ + X(Model::IntenseStyle, IntenseTextStyle, "intenseTextStyle", Model::IntenseStyle::Bright) \ + X(double, Opacity, "opacity", 1.0) \ X(bool, AdjustIndistinguishableColors, "adjustIndistinguishableColors", true) diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index dc58c769eb1..b828165a2ec 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -110,18 +110,18 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // Nullable/optional settings INHERITABLE_NULLABLE_SETTING(Model::Profile, Microsoft::Terminal::Core::Color, TabColor, nullptr); - INHERITABLE_SETTING(Model::Profile, hstring, Padding, DEFAULT_PADDING); INHERITABLE_SETTING(Model::Profile, Model::IAppearanceConfig, UnfocusedAppearance, nullptr); // Global settings INHERITABLE_SETTING(Model::Profile, bool, ForceFullRepaintRendering, false); INHERITABLE_SETTING(Model::Profile, bool, SoftwareRendering, false); - // Settings that cannot be put in the macro because of how they are handled in ToJson + // Settings that cannot be put in the macro because of how they are handled in ToJson/LayerJson INHERITABLE_SETTING(Model::Profile, hstring, Name, L"Default"); INHERITABLE_SETTING(Model::Profile, hstring, Source); INHERITABLE_SETTING(Model::Profile, bool, Hidden, false); INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); + INHERITABLE_SETTING(Model::Profile, hstring, Padding, DEFAULT_PADDING); #define PROFILE_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ INHERITABLE_SETTING(Model::Profile, type, name, ##__VA_ARGS__) From 661fe84811a66f9c2e59f67a3235e4ee1f146262 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 26 Oct 2021 14:27:36 -0700 Subject: [PATCH 14/15] opacity out of macro, remove clang guards --- src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp | 4 ++++ src/cascadia/TerminalSettingsModel/AppearanceConfig.h | 1 + src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp | 3 --- src/cascadia/TerminalSettingsModel/MTSMSettings.h | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index 999845d1e93..d48763eca1c 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -17,6 +17,7 @@ static constexpr std::string_view BackgroundKey{ "background" }; static constexpr std::string_view SelectionBackgroundKey{ "selectionBackground" }; static constexpr std::string_view CursorColorKey{ "cursorColor" }; static constexpr std::string_view LegacyAcrylicTransparencyKey{ "acrylicOpacity" }; +static constexpr std::string_view OpacityKey{ "opacity" }; AppearanceConfig::AppearanceConfig(winrt::weak_ref sourceProfile) : _sourceProfile(std::move(sourceProfile)) @@ -30,6 +31,7 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const Appearan appearance->_Background = source->_Background; appearance->_SelectionBackground = source->_SelectionBackground; appearance->_CursorColor = source->_CursorColor; + appearance->_Opacity = source->_Opacity; #define APPEARANCE_SETTINGS_COPY(type, name, jsonKey, ...) \ appearance->_##name = source->_##name; @@ -47,6 +49,7 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, BackgroundKey, _Background); JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground); JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor); + JsonUtils::SetValueForKey(json, OpacityKey, _Opacity, JsonUtils::OptionalConverter{}); #define APPEARANCE_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ JsonUtils::SetValueForKey(json, jsonKey, _##name); @@ -75,6 +78,7 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, CursorColorKey, _CursorColor); JsonUtils::GetValueForKey(json, LegacyAcrylicTransparencyKey, _Opacity); + JsonUtils::GetValueForKey(json, OpacityKey, _Opacity, JsonUtils::OptionalConverter{}); #define APPEARANCE_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ JsonUtils::GetValueForKey(json, jsonKey, _##name); diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index 41e29497437..bbc30927eb7 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -40,6 +40,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Background, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); + INHERITABLE_SETTING(Model::IAppearanceConfig, double, Opacity, 1.0); #define APPEARANCE_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index a9de4072277..cd5ef863a31 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -181,7 +181,6 @@ Json::Value GlobalAppSettings::ToJson() const { Json::Value json{ Json::ValueType::objectValue }; - // clang-format off JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); #define GLOBAL_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ @@ -189,8 +188,6 @@ Json::Value GlobalAppSettings::ToJson() const MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) #undef GLOBAL_SETTINGS_TO_JSON - // clang-format on - json[JsonKey(ActionsKey)] = _actionMap->ToJson(); return json; } diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index 1e61bbef213..74b5b1bc021 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -92,5 +92,4 @@ Author(s): X(hstring, ColorSchemeName, "colorScheme", L"Campbell") \ X(hstring, BackgroundImagePath, "backgroundImage") \ X(Model::IntenseStyle, IntenseTextStyle, "intenseTextStyle", Model::IntenseStyle::Bright) \ - X(double, Opacity, "opacity", 1.0) \ X(bool, AdjustIndistinguishableColors, "adjustIndistinguishableColors", true) From 64c667623324dfb234c4db76b78a1378b290c10a Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 26 Oct 2021 14:30:55 -0700 Subject: [PATCH 15/15] format --- src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index cd5ef863a31..63d4f688fff 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -181,11 +181,11 @@ Json::Value GlobalAppSettings::ToJson() const { Json::Value json{ Json::ValueType::objectValue }; - JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); + JsonUtils::SetValueForKey(json, DefaultProfileKey, _UnparsedDefaultProfile); #define GLOBAL_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ JsonUtils::SetValueForKey(json, jsonKey, _##name); - MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) + MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_TO_JSON) #undef GLOBAL_SETTINGS_TO_JSON json[JsonKey(ActionsKey)] = _actionMap->ToJson();