From dd764a8f2729930567f3cf594e601aed383a05fc Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 8 Feb 2021 11:29:23 -0800 Subject: [PATCH 01/16] TSM: add getter for source object --- .../TerminalSettingsModel/GlobalAppSettings.h | 50 ++++++------ .../TerminalSettingsModel/IInheritable.h | 49 +++++++++++- src/cascadia/TerminalSettingsModel/Profile.h | 78 +++++++++---------- 3 files changed, 111 insertions(+), 66 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index 8e1e65942b4..a52b9e72dea 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -62,31 +62,31 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation void UnparsedDefaultProfile(const hstring& value); void ClearUnparsedDefaultProfile(); - GETSET_SETTING(int32_t, InitialRows, DEFAULT_ROWS); - GETSET_SETTING(int32_t, InitialCols, DEFAULT_COLS); - GETSET_SETTING(bool, AlwaysShowTabs, true); - GETSET_SETTING(bool, ShowTitleInTitlebar, true); - GETSET_SETTING(bool, ConfirmCloseAllTabs, true); - GETSET_SETTING(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default); - GETSET_SETTING(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal); - GETSET_SETTING(bool, ShowTabsInTitlebar, true); - GETSET_SETTING(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); - GETSET_SETTING(bool, CopyOnSelect, false); - GETSET_SETTING(winrt::Microsoft::Terminal::TerminalControl::CopyFormat, CopyFormatting, 0); - GETSET_SETTING(bool, WarnAboutLargePaste, true); - GETSET_SETTING(bool, WarnAboutMultiLinePaste, true); - GETSET_SETTING(Model::LaunchPosition, InitialPosition, nullptr, nullptr); - GETSET_SETTING(Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode); - GETSET_SETTING(bool, SnapToGridOnResize, true); - GETSET_SETTING(bool, ForceFullRepaintRendering, false); - GETSET_SETTING(bool, SoftwareRendering, false); - GETSET_SETTING(bool, ForceVTInput, false); - GETSET_SETTING(bool, DebugFeaturesEnabled, _getDefaultDebugFeaturesValue()); - GETSET_SETTING(bool, StartOnUserLogin, false); - GETSET_SETTING(bool, AlwaysOnTop, false); - GETSET_SETTING(Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder); - GETSET_SETTING(bool, DisableAnimations, false); - GETSET_SETTING(hstring, StartupActions, L""); + GETSET_SETTING(Model::GlobalAppSettings, int32_t, InitialRows, DEFAULT_ROWS); + GETSET_SETTING(Model::GlobalAppSettings, int32_t, InitialCols, DEFAULT_COLS); + GETSET_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true); + GETSET_SETTING(Model::GlobalAppSettings, bool, ShowTitleInTitlebar, true); + GETSET_SETTING(Model::GlobalAppSettings, bool, ConfirmCloseAllTabs, true); + GETSET_SETTING(Model::GlobalAppSettings, winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default); + GETSET_SETTING(Model::GlobalAppSettings, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal); + GETSET_SETTING(Model::GlobalAppSettings, bool, ShowTabsInTitlebar, true); + GETSET_SETTING(Model::GlobalAppSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); + GETSET_SETTING(Model::GlobalAppSettings, bool, CopyOnSelect, false); + GETSET_SETTING(Model::GlobalAppSettings, winrt::Microsoft::Terminal::TerminalControl::CopyFormat, CopyFormatting, 0); + GETSET_SETTING(Model::GlobalAppSettings, bool, WarnAboutLargePaste, true); + GETSET_SETTING(Model::GlobalAppSettings, bool, WarnAboutMultiLinePaste, true); + GETSET_SETTING(Model::GlobalAppSettings, Model::LaunchPosition, InitialPosition, nullptr, nullptr); + GETSET_SETTING(Model::GlobalAppSettings, Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode); + GETSET_SETTING(Model::GlobalAppSettings, bool, SnapToGridOnResize, true); + GETSET_SETTING(Model::GlobalAppSettings, bool, ForceFullRepaintRendering, false); + GETSET_SETTING(Model::GlobalAppSettings, bool, SoftwareRendering, false); + GETSET_SETTING(Model::GlobalAppSettings, bool, ForceVTInput, false); + GETSET_SETTING(Model::GlobalAppSettings, bool, DebugFeaturesEnabled, _getDefaultDebugFeaturesValue()); + GETSET_SETTING(Model::GlobalAppSettings, bool, StartOnUserLogin, false); + GETSET_SETTING(Model::GlobalAppSettings, bool, AlwaysOnTop, false); + GETSET_SETTING(Model::GlobalAppSettings, Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder); + GETSET_SETTING(Model::GlobalAppSettings, bool, DisableAnimations, false); + GETSET_SETTING(Model::GlobalAppSettings, hstring, StartupActions, L""); private: guid _defaultProfile; diff --git a/src/cascadia/TerminalSettingsModel/IInheritable.h b/src/cascadia/TerminalSettingsModel/IInheritable.h index 539b21a54f6..1c2b7f76964 100644 --- a/src/cascadia/TerminalSettingsModel/IInheritable.h +++ b/src/cascadia/TerminalSettingsModel/IInheritable.h @@ -78,12 +78,13 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // Use this macro to quickly implement both getters and the setter for an // inheritable setting property. This is similar to the GETSET_PROPERTY macro, except... // - Has(): checks if the user explicitly set a value for this setting +// - SourceGetter(): return the object that provides the resolved value // - Getter(): return the resolved value // - Setter(): set the value directly // - Clear(): clear the user set value // - the setting is saved as an optional, where nullopt means // that we must inherit the value from our parent -#define GETSET_SETTING(type, name, ...) \ +#define GETSET_SETTING(projectedType, type, name, ...) \ public: \ /* Returns true if the user explicitly set the value, false otherwise*/ \ bool Has##name() const \ @@ -91,6 +92,28 @@ public: \ return _##name.has_value(); \ } \ \ + projectedType name##Source() \ + { \ + /*we have a value*/ \ + if (_##name) \ + { \ + return *this; \ + } \ + \ + /*user set value was not set*/ \ + /*iterate through parents to find one with a value*/ \ + for (auto& parent : _parents) \ + { \ + if (auto source{ parent->name##Source() }) \ + { \ + return source; \ + } \ + } \ + \ + /*no value was found*/ \ + return nullptr; \ + } \ + \ /* Returns the resolved value for this setting */ \ /* fallback: user set value --> inherited value --> system set value */ \ type name() const \ @@ -139,7 +162,7 @@ private: \ // like Profile.Foreground (where null is interpreted // as an acceptable value, rather than "inherit") // "type" is exposed as an IReference -#define GETSET_NULLABLE_SETTING(type, name, ...) \ +#define GETSET_NULLABLE_SETTING(projectedType, type, name, ...) \ public: \ /* Returns true if the user explicitly set the value, false otherwise*/ \ bool Has##name() const \ @@ -147,6 +170,28 @@ public: \ return _##name.has_value(); \ } \ \ + projectedType name##Source() \ + { \ + /*we have a value*/ \ + if (_##name) \ + { \ + return *this; \ + } \ + \ + /*user set value was not set*/ \ + /*iterate through parents to find one with a value*/ \ + for (auto parent : _parents) \ + { \ + if (auto source{ parent->name##Source() }) \ + { \ + return source; \ + } \ + } \ + \ + /*no source was found*/ \ + return nullptr; \ + } \ + \ /* Returns the resolved value for this setting */ \ /* fallback: user set value --> inherited value --> system set value */ \ winrt::Windows::Foundation::IReference name() const \ diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index b7964abe516..c146fdc075a 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -61,58 +61,58 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation hstring ExpandedBackgroundImagePath() const; static guid GetGuidOrGenerateForJson(const Json::Value& json) noexcept; - GETSET_SETTING(guid, Guid, _GenerateGuidForProfile(Name(), Source())); - GETSET_SETTING(hstring, Name, L"Default"); - GETSET_SETTING(hstring, Source); - GETSET_SETTING(bool, Hidden, false); - GETSET_SETTING(guid, ConnectionType); + GETSET_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); + GETSET_SETTING(Model::Profile, hstring, Name, L"Default"); + GETSET_SETTING(Model::Profile, hstring, Source); + GETSET_SETTING(Model::Profile, bool, Hidden, false); + GETSET_SETTING(Model::Profile, guid, ConnectionType); // Default Icon: Segoe MDL2 CommandPrompt icon - GETSET_SETTING(hstring, Icon, L"\uE756"); + GETSET_SETTING(Model::Profile, hstring, Icon, L"\uE756"); - GETSET_SETTING(CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful); - GETSET_SETTING(hstring, TabTitle); - GETSET_NULLABLE_SETTING(Windows::UI::Color, TabColor, nullptr); - GETSET_SETTING(bool, SuppressApplicationTitle, false); + GETSET_SETTING(Model::Profile, CloseOnExitMode, CloseOnExit, CloseOnExitMode::Graceful); + GETSET_SETTING(Model::Profile, hstring, TabTitle); + GETSET_NULLABLE_SETTING(Model::Profile, Windows::UI::Color, TabColor, nullptr); + GETSET_SETTING(Model::Profile, bool, SuppressApplicationTitle, false); - GETSET_SETTING(bool, UseAcrylic, false); - GETSET_SETTING(double, AcrylicOpacity, 0.5); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::ScrollbarState, ScrollState, Microsoft::Terminal::TerminalControl::ScrollbarState::Visible); + GETSET_SETTING(Model::Profile, bool, UseAcrylic, false); + GETSET_SETTING(Model::Profile, double, AcrylicOpacity, 0.5); + GETSET_SETTING(Model::Profile, Microsoft::Terminal::TerminalControl::ScrollbarState, ScrollState, Microsoft::Terminal::TerminalControl::ScrollbarState::Visible); - GETSET_SETTING(hstring, FontFace, DEFAULT_FONT_FACE); - GETSET_SETTING(int32_t, FontSize, DEFAULT_FONT_SIZE); - GETSET_SETTING(Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT); - GETSET_SETTING(hstring, Padding, DEFAULT_PADDING); + GETSET_SETTING(Model::Profile, hstring, FontFace, DEFAULT_FONT_FACE); + GETSET_SETTING(Model::Profile, int32_t, FontSize, DEFAULT_FONT_SIZE); + GETSET_SETTING(Model::Profile, Windows::UI::Text::FontWeight, FontWeight, DEFAULT_FONT_WEIGHT); + GETSET_SETTING(Model::Profile, hstring, Padding, DEFAULT_PADDING); - GETSET_SETTING(hstring, Commandline, L"cmd.exe"); - GETSET_SETTING(hstring, StartingDirectory); + GETSET_SETTING(Model::Profile, hstring, Commandline, L"cmd.exe"); + GETSET_SETTING(Model::Profile, hstring, StartingDirectory); - GETSET_SETTING(hstring, BackgroundImagePath); - GETSET_SETTING(double, BackgroundImageOpacity, 1.0); - GETSET_SETTING(Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch::UniformToFill); - GETSET_SETTING(ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center); + GETSET_SETTING(Model::Profile, hstring, BackgroundImagePath); + GETSET_SETTING(Model::Profile, double, BackgroundImageOpacity, 1.0); + GETSET_SETTING(Model::Profile, Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch::UniformToFill); + GETSET_SETTING(Model::Profile, ConvergedAlignment, BackgroundImageAlignment, ConvergedAlignment::Horizontal_Center | ConvergedAlignment::Vertical_Center); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::TerminalControl::TextAntialiasingMode::Grayscale); - GETSET_SETTING(bool, RetroTerminalEffect, false); - GETSET_SETTING(hstring, PixelShaderPath, L""); - GETSET_SETTING(bool, ForceFullRepaintRendering, false); - GETSET_SETTING(bool, SoftwareRendering, false); + GETSET_SETTING(Model::Profile, Microsoft::Terminal::TerminalControl::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::TerminalControl::TextAntialiasingMode::Grayscale); + GETSET_SETTING(Model::Profile, bool, RetroTerminalEffect, false); + GETSET_SETTING(Model::Profile, hstring, PixelShaderPath, L""); + GETSET_SETTING(Model::Profile, bool, ForceFullRepaintRendering, false); + GETSET_SETTING(Model::Profile, bool, SoftwareRendering, false); - GETSET_SETTING(hstring, ColorSchemeName, L"Campbell"); + GETSET_SETTING(Model::Profile, hstring, ColorSchemeName, L"Campbell"); - GETSET_NULLABLE_SETTING(Windows::UI::Color, Foreground, nullptr); - GETSET_NULLABLE_SETTING(Windows::UI::Color, Background, nullptr); - GETSET_NULLABLE_SETTING(Windows::UI::Color, SelectionBackground, nullptr); - GETSET_NULLABLE_SETTING(Windows::UI::Color, CursorColor, nullptr); + GETSET_NULLABLE_SETTING(Model::Profile, Windows::UI::Color, Foreground, nullptr); + GETSET_NULLABLE_SETTING(Model::Profile, Windows::UI::Color, Background, nullptr); + GETSET_NULLABLE_SETTING(Model::Profile, Windows::UI::Color, SelectionBackground, nullptr); + GETSET_NULLABLE_SETTING(Model::Profile, Windows::UI::Color, CursorColor, nullptr); - GETSET_SETTING(int32_t, HistorySize, DEFAULT_HISTORY_SIZE); - GETSET_SETTING(bool, SnapOnInput, true); - GETSET_SETTING(bool, AltGrAliasing, true); + GETSET_SETTING(Model::Profile, int32_t, HistorySize, DEFAULT_HISTORY_SIZE); + GETSET_SETTING(Model::Profile, bool, SnapOnInput, true); + GETSET_SETTING(Model::Profile, bool, AltGrAliasing, true); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::CursorStyle, CursorShape, Microsoft::Terminal::TerminalControl::CursorStyle::Bar); - GETSET_SETTING(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); + GETSET_SETTING(Model::Profile, Microsoft::Terminal::TerminalControl::CursorStyle, CursorShape, Microsoft::Terminal::TerminalControl::CursorStyle::Bar); + GETSET_SETTING(Model::Profile, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); - GETSET_SETTING(Model::BellStyle, BellStyle, BellStyle::Audible); + GETSET_SETTING(Model::Profile, Model::BellStyle, BellStyle, BellStyle::Audible); private: static std::wstring EvaluateStartingDirectory(const std::wstring& directory); From 4c2f59a0126f7794cec8ddcd2b68a764da735ca7 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 8 Feb 2021 11:30:01 -0800 Subject: [PATCH 02/16] TSM: implement tagging mechanism for profiles --- .../CascadiaSettingsSerialization.cpp | 7 +++++++ .../TerminalSettingsModel/DefaultProfileUtils.cpp | 9 +++++---- src/cascadia/TerminalSettingsModel/Profile.h | 2 ++ src/cascadia/TerminalSettingsModel/Profile.idl | 10 ++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp index 3cbb4419066..6093be20326 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp @@ -332,6 +332,13 @@ winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings CascadiaSettings:: resultPtr->_ResolveDefaultProfile(); resultPtr->_UpdateActiveProfiles(); + // tag these profiles as in-box + for (const auto& profile : resultPtr->AllProfiles()) + { + const auto& profileImpl{ winrt::get_self(profile) }; + profileImpl->Origin(OriginTag::InBox); + } + return *resultPtr; } diff --git a/src/cascadia/TerminalSettingsModel/DefaultProfileUtils.cpp b/src/cascadia/TerminalSettingsModel/DefaultProfileUtils.cpp index 08c2c67cfbd..46b16e7025d 100644 --- a/src/cascadia/TerminalSettingsModel/DefaultProfileUtils.cpp +++ b/src/cascadia/TerminalSettingsModel/DefaultProfileUtils.cpp @@ -20,14 +20,15 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CreateDefaultProfile(const const winrt::guid profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, gsl::as_bytes(gsl::make_span(name))) }; - auto newProfile = winrt::make(profileGuid); - newProfile.Name(name); + auto newProfile = winrt::make_self(profileGuid); + newProfile->Name(winrt::hstring{ name }); std::wstring iconPath{ PACKAGED_PROFILE_ICON_PATH }; iconPath.append(Microsoft::Console::Utils::GuidToString(profileGuid)); iconPath.append(PACKAGED_PROFILE_ICON_EXTENSION); - newProfile.Icon(iconPath); + newProfile->Icon(winrt::hstring{ iconPath }); + newProfile->Origin(winrt::Microsoft::Terminal::Settings::Model::OriginTag::Generated); - return newProfile; + return *newProfile; } diff --git a/src/cascadia/TerminalSettingsModel/Profile.h b/src/cascadia/TerminalSettingsModel/Profile.h index c146fdc075a..83d75433746 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.h +++ b/src/cascadia/TerminalSettingsModel/Profile.h @@ -61,6 +61,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation hstring ExpandedBackgroundImagePath() const; static guid GetGuidOrGenerateForJson(const Json::Value& json) noexcept; + GETSET_PROPERTY(OriginTag, Origin, OriginTag::Custom); + GETSET_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source())); GETSET_SETTING(Model::Profile, hstring, Name, L"Default"); GETSET_SETTING(Model::Profile, hstring, Source); diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index f65b34e5c5a..a48bff813c6 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -3,6 +3,14 @@ namespace Microsoft.Terminal.Settings.Model { + // This tag is used to identify the context in which the Profile was created + enum OriginTag + { + Custom = 0, + InBox, + Generated + }; + enum CloseOnExitMode { Never = 0, @@ -35,6 +43,8 @@ namespace Microsoft.Terminal.Settings.Model Profile(); Profile(Guid guid); + OriginTag Origin { get; }; + Boolean HasName(); void ClearName(); String Name; From 309746b8d1d661b92887abae144b4a5694c5d573 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 8 Feb 2021 17:37:40 -0800 Subject: [PATCH 03/16] fix TSM --- .../TerminalSettingsModel/IInheritable.h | 62 ++++-- .../TerminalSettingsModel/Profile.idl | 183 ++++-------------- 2 files changed, 86 insertions(+), 159 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/IInheritable.h b/src/cascadia/TerminalSettingsModel/IInheritable.h index 1c2b7f76964..6d4d4a793f1 100644 --- a/src/cascadia/TerminalSettingsModel/IInheritable.h +++ b/src/cascadia/TerminalSettingsModel/IInheritable.h @@ -92,19 +92,13 @@ public: \ return _##name.has_value(); \ } \ \ - projectedType name##Source() \ + projectedType name##OverrideSource() \ { \ - /*we have a value*/ \ - if (_##name) \ - { \ - return *this; \ - } \ - \ /*user set value was not set*/ \ /*iterate through parents to find one with a value*/ \ for (auto& parent : _parents) \ { \ - if (auto source{ parent->name##Source() }) \ + if (auto source{ parent->_get##name##OverrideSourceImpl() }) \ { \ return source; \ } \ @@ -156,6 +150,27 @@ private: \ \ /*no value was found*/ \ return std::nullopt; \ + } \ + projectedType _get##name##OverrideSourceImpl() const \ + { \ + /*we have a value*/ \ + if (_##name) \ + { \ + return *this; \ + } \ + \ + /*user set value was not set*/ \ + /*iterate through parents to find one with a value*/ \ + for (auto& parent : _parents) \ + { \ + if (auto source{ parent->name##OverrideSource() }) \ + { \ + return source; \ + } \ + } \ + \ + /*no value was found*/ \ + return nullptr; \ } // This macro is similar to the one above, but is reserved for optional settings @@ -170,19 +185,13 @@ public: \ return _##name.has_value(); \ } \ \ - projectedType name##Source() \ + projectedType name##OverrideSource() \ { \ - /*we have a value*/ \ - if (_##name) \ - { \ - return *this; \ - } \ - \ /*user set value was not set*/ \ /*iterate through parents to find one with a value*/ \ for (auto parent : _parents) \ { \ - if (auto source{ parent->name##Source() }) \ + if (auto source{ parent->_get##name##OverrideSourceImpl() }) \ { \ return source; \ } \ @@ -250,4 +259,25 @@ private: \ \ /*no value was found*/ \ return std::nullopt; \ + } \ + projectedType _get##name##OverrideSourceImpl() const \ + { \ + /*we have a value*/ \ + if (_##name) \ + { \ + return *this; \ + } \ + \ + /*user set value was not set*/ \ + /*iterate through parents to find one with a value*/ \ + for (auto& parent : _parents) \ + { \ + if (auto source{ parent->name##OverrideSource() }) \ + { \ + return source; \ + } \ + } \ + \ + /*no value was found*/ \ + return nullptr; \ } diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index a48bff813c6..aacc72f6298 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +#include "IInheritable.idl.h" + namespace Microsoft.Terminal.Settings.Model { // This tag is used to identify the context in which the Profile was created @@ -45,160 +47,55 @@ namespace Microsoft.Terminal.Settings.Model OriginTag Origin { get; }; - Boolean HasName(); - void ClearName(); - String Name; + PROJECTED_SETTING(String, Name); Boolean HasGuid(); Guid Guid; - Boolean HasSource(); - void ClearSource(); - String Source; + PROJECTED_SETTING(String, Source); Boolean HasConnectionType(); Guid ConnectionType; - Boolean HasHidden(); - void ClearHidden(); - Boolean Hidden; - - Boolean HasIcon(); - void ClearIcon(); - String Icon; - - Boolean HasCloseOnExit(); - void ClearCloseOnExit(); - CloseOnExitMode CloseOnExit; - - Boolean HasTabTitle(); - void ClearTabTitle(); - String TabTitle; - - Boolean HasTabColor(); - void ClearTabColor(); - Windows.Foundation.IReference TabColor; - - Boolean HasSuppressApplicationTitle(); - void ClearSuppressApplicationTitle(); - Boolean SuppressApplicationTitle; - - Boolean HasUseAcrylic(); - void ClearUseAcrylic(); - Boolean UseAcrylic; - - Boolean HasAcrylicOpacity(); - void ClearAcrylicOpacity(); - Double AcrylicOpacity; - - Boolean HasScrollState(); - void ClearScrollState(); - Microsoft.Terminal.TerminalControl.ScrollbarState ScrollState; - - Boolean HasFontFace(); - void ClearFontFace(); - String FontFace; - - Boolean HasFontSize(); - void ClearFontSize(); - Int32 FontSize; - - Boolean HasFontWeight(); - void ClearFontWeight(); - Windows.UI.Text.FontWeight FontWeight; - - Boolean HasPadding(); - void ClearPadding(); - String Padding; - - Boolean HasCommandline(); - void ClearCommandline(); - String Commandline; - - Boolean HasStartingDirectory(); - void ClearStartingDirectory(); - String StartingDirectory; + PROJECTED_SETTING(Boolean, Hidden); + PROJECTED_SETTING(String, Icon); + PROJECTED_SETTING(CloseOnExitMode, CloseOnExit); + PROJECTED_SETTING(String, TabTitle); + PROJECTED_SETTING(Windows.Foundation.IReference, TabColor); + PROJECTED_SETTING(Boolean, SuppressApplicationTitle); + PROJECTED_SETTING(Boolean, UseAcrylic); + PROJECTED_SETTING(Double, AcrylicOpacity); + PROJECTED_SETTING(Microsoft.Terminal.TerminalControl.ScrollbarState, ScrollState); + PROJECTED_SETTING(String, FontFace); + PROJECTED_SETTING(Int32, FontSize); + PROJECTED_SETTING(Windows.UI.Text.FontWeight, FontWeight); + PROJECTED_SETTING(String, Padding); + PROJECTED_SETTING(String, Commandline); + + PROJECTED_SETTING(String, StartingDirectory); String EvaluatedStartingDirectory { get; }; - Boolean HasBackgroundImagePath(); - void ClearBackgroundImagePath(); - String BackgroundImagePath; + PROJECTED_SETTING(String, BackgroundImagePath); String ExpandedBackgroundImagePath { get; }; - Boolean HasBackgroundImageOpacity(); - void ClearBackgroundImageOpacity(); - Double BackgroundImageOpacity; - - Boolean HasBackgroundImageStretchMode(); - void ClearBackgroundImageStretchMode(); - Windows.UI.Xaml.Media.Stretch BackgroundImageStretchMode; - - Boolean HasBackgroundImageAlignment(); - void ClearBackgroundImageAlignment(); - ConvergedAlignment BackgroundImageAlignment; - - Boolean HasAntialiasingMode(); - void ClearAntialiasingMode(); - Microsoft.Terminal.TerminalControl.TextAntialiasingMode AntialiasingMode; - - Boolean HasRetroTerminalEffect(); - void ClearRetroTerminalEffect(); - Boolean RetroTerminalEffect; - - Boolean HasPixelShaderPath(); - void ClearPixelShaderPath(); - String PixelShaderPath; - - Boolean HasForceFullRepaintRendering(); - void ClearForceFullRepaintRendering(); - Boolean ForceFullRepaintRendering; - - Boolean HasSoftwareRendering(); - void ClearSoftwareRendering(); - Boolean SoftwareRendering; - - Boolean HasColorSchemeName(); - void ClearColorSchemeName(); - String ColorSchemeName; - - Boolean HasForeground(); - void ClearForeground(); - Windows.Foundation.IReference Foreground; - - Boolean HasBackground(); - void ClearBackground(); - Windows.Foundation.IReference Background; - - Boolean HasSelectionBackground(); - void ClearSelectionBackground(); - Windows.Foundation.IReference SelectionBackground; - - Boolean HasCursorColor(); - void ClearCursorColor(); - Windows.Foundation.IReference CursorColor; - - Boolean HasHistorySize(); - void ClearHistorySize(); - Int32 HistorySize; - - Boolean HasSnapOnInput(); - void ClearSnapOnInput(); - Boolean SnapOnInput; - - Boolean HasAltGrAliasing(); - void ClearAltGrAliasing(); - Boolean AltGrAliasing; - - Boolean HasCursorShape(); - void ClearCursorShape(); - Microsoft.Terminal.TerminalControl.CursorStyle CursorShape; - - Boolean HasCursorHeight(); - void ClearCursorHeight(); - UInt32 CursorHeight; - - Boolean HasBellStyle(); - void ClearBellStyle(); - BellStyle BellStyle; + PROJECTED_SETTING(Double, BackgroundImageOpacity); + PROJECTED_SETTING(Windows.UI.Xaml.Media.Stretch, BackgroundImageStretchMode); + PROJECTED_SETTING(ConvergedAlignment, BackgroundImageAlignment); + PROJECTED_SETTING(Microsoft.Terminal.TerminalControl.TextAntialiasingMode, AntialiasingMode); + PROJECTED_SETTING(Boolean, RetroTerminalEffect); + PROJECTED_SETTING(String, PixelShaderPath); + PROJECTED_SETTING(Boolean, ForceFullRepaintRendering); + PROJECTED_SETTING(Boolean, SoftwareRendering); + PROJECTED_SETTING(String, ColorSchemeName); + PROJECTED_SETTING(Windows.Foundation.IReference, Foreground); + PROJECTED_SETTING(Windows.Foundation.IReference, Background); + PROJECTED_SETTING(Windows.Foundation.IReference, SelectionBackground); + PROJECTED_SETTING(Windows.Foundation.IReference, CursorColor); + PROJECTED_SETTING(Int32, HistorySize); + PROJECTED_SETTING(Boolean, SnapOnInput); + PROJECTED_SETTING(Boolean, AltGrAliasing); + PROJECTED_SETTING(Microsoft.Terminal.TerminalControl.CursorStyle, CursorShape); + PROJECTED_SETTING(UInt32, CursorHeight); + PROJECTED_SETTING(BellStyle, BellStyle); } } From 576a3f0900db857680475bd855440a74d1afaf35 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 8 Feb 2021 17:38:45 -0800 Subject: [PATCH 04/16] TSE: implement message generation --- .../TerminalSettingsEditor/Profiles.idl | 4 +- .../TerminalSettingsEditor/Profiles.xaml | 52 ++++-- .../Resources/en-US/Resources.resw | 68 ++++---- .../SettingContainer.cpp | 150 ++++++++++++++---- .../TerminalSettingsEditor/SettingContainer.h | 3 +- .../SettingContainer.idl | 3 + .../TerminalSettingsEditor/ViewModelHelpers.h | 6 +- .../ViewModelHelpers.idl.h | 11 +- src/cascadia/TerminalSettingsEditor/pch.h | 1 + .../TerminalSettingsModel/IInheritable.idl.h | 14 ++ 10 files changed, 236 insertions(+), 76 deletions(-) create mode 100644 src/cascadia/TerminalSettingsModel/IInheritable.idl.h diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index 906259f6e90..d12d7f0fa85 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -18,9 +18,9 @@ namespace Microsoft.Terminal.Settings.Editor Boolean BackgroundImageSettingsVisible { get; }; OBSERVABLE_PROJECTED_SETTING(String, Name); - OBSERVABLE_PROJECTED_SETTING(Guid, Guid); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Guid, Guid); OBSERVABLE_PROJECTED_SETTING(String, Source); - OBSERVABLE_PROJECTED_SETTING(Guid, ConnectionType); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Guid, ConnectionType); OBSERVABLE_PROJECTED_SETTING(Boolean, Hidden); OBSERVABLE_PROJECTED_SETTING(String, Icon); OBSERVABLE_PROJECTED_SETTING(Microsoft.Terminal.Settings.Model.CloseOnExitMode, CloseOnExit); diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index dca5feec799..0a32eb21d23 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -76,6 +76,7 @@ the MIT License. See LICENSE in the project root for license information. --> x:Name="CommandlineContainer" HasSettingValue="{x:Bind State.Profile.HasCommandline, Mode=OneWay}" ClearSettingValue="{x:Bind State.Profile.ClearCommandline}" + SettingOverrideSource="{x:Bind State.Profile.CommandlineOverrideSource, Mode=OneWay}" Visibility="{x:Bind State.Profile.IsBaseLayer, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}" Margin="0,0,0,24"> @@ -92,6 +93,7 @@ the MIT License. See LICENSE in the project root for license information. --> x:Name="StartingDirectoryContainer" HasSettingValue="{x:Bind State.Profile.HasStartingDirectory, Mode=OneWay}" ClearSettingValue="{x:Bind State.Profile.ClearStartingDirectory}" + SettingOverrideSource="{x:Bind State.Profile.StartingDirectoryOverrideSource, Mode=OneWay}" Margin="0"> @@ -113,7 +115,8 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearIcon}" + SettingOverrideSource="{x:Bind State.Profile.IconOverrideSource, Mode=OneWay}"> + ClearSettingValue="{x:Bind State.Profile.ClearTabTitle}" + SettingOverrideSource="{x:Bind State.Profile.TabTitleOverrideSource, Mode=OneWay}"> @@ -212,6 +216,7 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearFontFace}" + SettingOverrideSource="{x:Bind State.Profile.FontFaceOverrideSource, Mode=OneWay}"> @@ -235,7 +241,8 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearFontSize}" + SettingOverrideSource="{x:Bind State.Profile.FontSizeOverrideSource, Mode=OneWay}"> + ClearSettingValue="{x:Bind State.Profile.ClearFontWeight}" + SettingOverrideSource="{x:Bind State.Profile.FontWeightOverrideSource, Mode=OneWay}"> + ClearSettingValue="{x:Bind State.Profile.ClearRetroTerminalEffect}" + SettingOverrideSource="{x:Bind State.Profile.RetroTerminalEffectOverrideSource, Mode=OneWay}"> @@ -296,6 +305,7 @@ the MIT License. See LICENSE in the project root for license information. --> x:Name="BackgroundImageContainer" HasSettingValue="{x:Bind State.Profile.HasBackgroundImagePath, Mode=OneWay}" ClearSettingValue="{x:Bind State.Profile.ClearBackgroundImagePath}" + SettingOverrideSource="{x:Bind State.Profile.BackgroundImagePathOverrideSource, Mode=OneWay}" Margin="0"> @@ -344,6 +356,7 @@ the MIT License. See LICENSE in the project root for license information. --> @@ -509,6 +523,7 @@ the MIT License. See LICENSE in the project root for license information. --> x:Name="BackgroundImageOpacityContainer" HasSettingValue="{x:Bind State.Profile.HasBackgroundImageOpacity, Mode=OneWay}" ClearSettingValue="{x:Bind State.Profile.ClearBackgroundImageOpacity}" + SettingOverrideSource="{x:Bind State.Profile.BackgroundImageOpacityOverrideSource, Mode=OneWay}" Visibility="{x:Bind State.Profile.BackgroundImageSettingsVisible, Mode=OneWay}"> @@ -533,6 +548,7 @@ the MIT License. See LICENSE in the project root for license information. --> @@ -543,6 +559,7 @@ the MIT License. See LICENSE in the project root for license information. --> x:Name="AcrylicOpacityContainer" HasSettingValue="{x:Bind State.Profile.HasAcrylicOpacity, Mode=OneWay}" ClearSettingValue="{x:Bind State.Profile.ClearAcrylicOpacity}" + SettingOverrideSource="{x:Bind State.Profile.AcrylicOpacityOverrideSource, Mode=OneWay}" Visibility="{Binding ElementName=UseAcrylicToggleSwitch, Path=IsOn, Mode=OneWay}"> @@ -569,6 +586,7 @@ the MIT License. See LICENSE in the project root for license information. --> @@ -587,7 +605,8 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearScrollState}" + SettingOverrideSource="{x:Bind State.Profile.ScrollStateOverrideSource, Mode=OneWay}"> @@ -605,6 +624,7 @@ the MIT License. See LICENSE in the project root for license information. --> @@ -612,7 +632,8 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearAntialiasingMode}" + SettingOverrideSource="{x:Bind State.Profile.AntialiasingModeOverrideSource, Mode=OneWay}"> @@ -621,21 +642,24 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearAltGrAliasing}" + SettingOverrideSource="{x:Bind State.Profile.AltGrAliasingOverrideSource, Mode=OneWay}"> + ClearSettingValue="{x:Bind State.Profile.ClearSnapOnInput}" + SettingOverrideSource="{x:Bind State.Profile.SnapOnInputOverrideSource, Mode=OneWay}"> + ClearSettingValue="{x:Bind State.Profile.ClearHistorySize}" + SettingOverrideSource="{x:Bind State.Profile.HistorySizeOverrideSource, Mode=OneWay}"> + ClearSettingValue="{x:Bind State.Profile.ClearCloseOnExit}" + SettingOverrideSource="{x:Bind State.Profile.CloseOnExitOverrideSource, Mode=OneWay}"> @@ -654,7 +679,8 @@ the MIT License. See LICENSE in the project root for license information. --> + ClearSettingValue="{x:Bind State.Profile.ClearBellStyle}" + SettingOverrideSource="{x:Bind State.Profile.BellStyleOverrideSource, Mode=OneWay}"> diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 9ae096c02a1..4843ca5a7c6 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -1,17 +1,17 @@  - @@ -825,4 +825,16 @@ a lower layer This is the object of "SettingContainer_OverrideIntro". - + + Azure Cloud Shell profile generator + + + PowerShell profile generator + + + system default values + + + WSL profile generator + + \ No newline at end of file diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp index d27c7741aff..bd89cae319f 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp @@ -5,6 +5,7 @@ #include "SettingContainer.h" #include "SettingContainer.g.cpp" #include "LibraryResources.h" +#include "../TerminalSettingsModel/LegacyProfileGeneratorNamespaces.h" using namespace winrt::Windows::UI::Xaml; @@ -13,6 +14,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation DependencyProperty SettingContainer::_HeaderProperty{ nullptr }; DependencyProperty SettingContainer::_HelpTextProperty{ nullptr }; DependencyProperty SettingContainer::_HasSettingValueProperty{ nullptr }; + DependencyProperty SettingContainer::_SettingOverrideSourceProperty{ nullptr }; SettingContainer::SettingContainer() { @@ -51,6 +53,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation xaml_typename(), PropertyMetadata{ box_value(false), PropertyChangedCallback{ &SettingContainer::_OnHasSettingValueChanged } }); } + if (!_SettingOverrideSourceProperty) + { + _SettingOverrideSourceProperty = + DependencyProperty::Register( + L"SettingOverrideSource", + xaml_typename(), + xaml_typename(), + PropertyMetadata{ nullptr }); + } } void SettingContainer::_OnHasSettingValueChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& args) @@ -79,9 +90,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SettingContainer::OnApplyTemplate() { - // This message is only populated if `HasSettingValue` is true. - const auto& overrideMsg{ _GenerateOverrideMessageText() }; - if (const auto& child{ GetTemplateChild(L"ResetButton") }) { if (const auto& button{ child.try_as() }) @@ -115,10 +123,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } }); - // apply tooltip and name (automation property) + // apply tooltip const auto& name{ RS_(L"SettingContainer_ResetButtonHelpText") }; Controls::ToolTipService::SetToolTip(child, box_value(name)); Automation::AutomationProperties::SetName(child, name); + + // apply name (automation property) + // NOTE: this can only be set _once_. Automation clients do not detect any changes. + // As a result, we're using the more generic version of the override message. + hstring overrideMsg{ fmt::format(std::wstring_view{ RS_(L"SettingContainer_OverrideIntro") }, RS_(L"SettingContainer_OverrideTarget")) }; Automation::AutomationProperties::SetHelpText(child, overrideMsg); // initialize visibility for reset button @@ -126,26 +139,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } - if (const auto& child{ GetTemplateChild(L"OverrideMessage") }) - { - if (const auto& tb{ child.try_as() }) - { - if (!overrideMsg.empty()) - { - // Create the override message - // TODO GH#6800: the override target will be replaced with hyperlink/text directing the user to another profile. - tb.Text(overrideMsg); - - // initialize visibility for reset button - tb.Visibility(Visibility::Visible); - } - else - { - // we have no message to render - tb.Visibility(Visibility::Collapsed); - } - } - } + _UpdateOverrideMessage(); if (const auto& content{ Content() }) { @@ -172,12 +166,112 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } - hstring SettingContainer::_GenerateOverrideMessageText() + void SettingContainer::_UpdateOverrideMessage() { - if (HasSettingValue()) + if (const auto& overrideMsg{ GetTemplateChild(L"OverrideMessage") }) { - return hstring{ fmt::format(std::wstring_view{ RS_(L"SettingContainer_OverrideIntro") }, RS_(L"SettingContainer_OverrideTarget")) }; + if (const auto& tb{ overrideMsg.try_as() }) + { + if (HasSettingValue()) + { + const std::wstring templateText{ RS_(L"SettingContainer_OverrideIntro") }; + const auto pos{ templateText.find(L"{}") }; + if (pos != std::wstring::npos) + { + // Append Message Prefix + { + Documents::Run msgPrefix{}; + msgPrefix.Text(templateText.substr(0, pos)); + tb.Inlines().Append(msgPrefix); + } + + // Append Message Target + { + Documents::Run msgTarget{}; + const auto& settingSrc{ SettingOverrideSource() }; + if (!settingSrc) + { + // no source; provide system-default view + msgTarget.Text(RS_(L"SettingContainer_OverrideTargetSystemDefaults")); + } + else if (const auto& profile{ settingSrc.try_as() }) + { + const auto originTag{ profile.Origin() }; + if (originTag == Model::OriginTag::InBox) + { + // in-box profile + msgTarget.Text(profile.Name()); + tb.Inlines().Append(msgTarget); + } + else if (originTag == Model::OriginTag::Generated) + { + // from a dynamic profile generator + const auto& profileSource{ profile.Source() }; + if (profileSource == WslGeneratorNamespace) + { + msgTarget.Text(RS_(L"SettingContainer_OverrideTargetWSLGenerator")); + } + else if (profileSource == AzureGeneratorNamespace) + { + msgTarget.Text(RS_(L"SettingContainer_OverrideTargetPowershellGenerator")); + } + else if (profileSource == PowershellCoreGeneratorNamespace) + { + msgTarget.Text(RS_(L"SettingContainer_OverrideTargetAzureCloudShellGenerator")); + } + else + { + // TODO CARLOS: we should probably have some special handling for proto-extensions here + // unknown generator; use fallback message instead + msgTarget.Text(RS_(L"SettingContainer_OverrideTarget")); + } + tb.Inlines().Append(msgTarget); + } + else + { + // base layer + // TODO GH#3818: When we add profile inheritance as a setting, + // we'll need an extra conditional check to see if this + // is the base layer or some other profile + msgTarget.Text(RS_(L"Nav_ProfileDefaults/Content")); + + Documents::Hyperlink hyperlink{}; + hyperlink.Click([=](auto&, auto&) { + // TODO CARLOS: navigate + }); + hyperlink.Inlines().Append(msgTarget); + tb.Inlines().Append(hyperlink); + } + } + else + { + // unknown source; use fallback message instead + msgTarget.Text(RS_(L"SettingContainer_OverrideTarget")); + tb.Inlines().Append(msgTarget); + } + } + + // Append Message Suffix + { + Documents::Run msgSuffix{}; + msgSuffix.Text(templateText.substr(pos + 2, templateText.npos)); + tb.Inlines().Append(msgSuffix); + } + } + else + { + // '{}' was not found + // fallback to more ambiguous version + hstring overrideMsg{ fmt::format(std::wstring_view{ RS_(L"SettingContainer_OverrideIntro") }, RS_(L"SettingContainer_OverrideTarget")) }; + tb.Text(overrideMsg); + } + tb.Visibility(Visibility::Visible); + } + else + { + tb.Visibility(Visibility::Collapsed); + } + } } - return {}; } } diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.h b/src/cascadia/TerminalSettingsEditor/SettingContainer.h index 5b35b9effcf..7c18162e37c 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.h +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.h @@ -53,12 +53,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation DEPENDENCY_PROPERTY(Windows::Foundation::IInspectable, Header); DEPENDENCY_PROPERTY(hstring, HelpText); DEPENDENCY_PROPERTY(bool, HasSettingValue); + DEPENDENCY_PROPERTY(IInspectable, SettingOverrideSource); TYPED_EVENT(ClearSettingValue, Editor::SettingContainer, Windows::Foundation::IInspectable); private: static void _InitializeProperties(); static void _OnHasSettingValueChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e); - hstring _GenerateOverrideMessageText(); + void _UpdateOverrideMessage(); }; } diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.idl b/src/cascadia/TerminalSettingsEditor/SettingContainer.idl index 11e33717932..3c75cd2dc33 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.idl +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.idl @@ -16,6 +16,9 @@ namespace Microsoft.Terminal.Settings.Editor Boolean HasSettingValue; static Windows.UI.Xaml.DependencyProperty HasSettingValueProperty { get; }; + IInspectable SettingOverrideSource; + static Windows.UI.Xaml.DependencyProperty SettingOverrideSourceProperty { get; }; + event Windows.Foundation.TypedEventHandler ClearSettingValue; }; } diff --git a/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.h b/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.h index fdaaeaff9c7..48b9ff2bd10 100644 --- a/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.h +++ b/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.h @@ -65,10 +65,10 @@ public: \ { \ _NotifyChanges(L"Has" #name, L#name); \ } \ - } + } \ + auto name##OverrideSource() { return target.name##OverrideSource(); } // Defines a setting that reflects another object's same-named // setting, but which cannot be erased. #define PERMANENT_OBSERVABLE_PROJECTED_SETTING(target, name) \ - _BASE_OBSERVABLE_PROJECTED_SETTING(target, name) \ - void Clear##name() {} + _BASE_OBSERVABLE_PROJECTED_SETTING(target, name) diff --git a/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.idl.h b/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.idl.h index 3b4d8fd4f7c..7d0fc205662 100644 --- a/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.idl.h +++ b/src/cascadia/TerminalSettingsEditor/ViewModelHelpers.idl.h @@ -10,4 +10,13 @@ set; \ }; \ Boolean Has##Name { get; }; \ - void Clear##Name() + void Clear##Name(); \ + Microsoft.Terminal.Settings.Model.Profile Name##OverrideSource { get; } + +#define PERMANENT_OBSERVABLE_PROJECTED_SETTING(Type, Name) \ + Type Name \ + { \ + get; \ + set; \ + }; \ + Boolean Has##Name { get; } diff --git a/src/cascadia/TerminalSettingsEditor/pch.h b/src/cascadia/TerminalSettingsEditor/pch.h index 076354f856f..0ba5f629ff2 100644 --- a/src/cascadia/TerminalSettingsEditor/pch.h +++ b/src/cascadia/TerminalSettingsEditor/pch.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/src/cascadia/TerminalSettingsModel/IInheritable.idl.h b/src/cascadia/TerminalSettingsModel/IInheritable.idl.h new file mode 100644 index 00000000000..e8ea3a18ed5 --- /dev/null +++ b/src/cascadia/TerminalSettingsModel/IInheritable.idl.h @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#define PROJECTED_SETTING(Type, Name) \ + Type Name \ + { \ + get; \ + set; \ + }; \ + Boolean Has##Name { get; }; \ + void Clear##Name(); \ + Microsoft.Terminal.Settings.Model.Profile Name##OverrideSource { get; } From 64c776ee61e97b22570a672763ebf60e31bda07b Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 8 Feb 2021 19:18:52 -0800 Subject: [PATCH 05/16] working prototype --- .../TerminalSettingsEditor/MainPage.cpp | 52 +++++++++++++++++++ .../TerminalSettingsEditor/MainPage.h | 2 + .../TerminalSettingsEditor/MainPage.xaml | 1 + .../TerminalSettingsEditor/Profiles.cpp | 34 ++++++++++++ .../TerminalSettingsEditor/Profiles.h | 3 ++ .../TerminalSettingsEditor/Profiles.idl | 1 + .../TerminalSettingsEditor/Profiles.xaml | 8 +-- .../SettingContainer.cpp | 3 +- .../TerminalSettingsEditor/SettingContainer.h | 1 + .../SettingContainer.idl | 1 + .../CascadiaSettingsSerialization.cpp | 1 + 11 files changed, 103 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index e09398146aa..00b190b20cc 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -273,6 +273,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } + // Method Description: + // - updates the content frame to present a view of the profile page + // - NOTE: this does not update the selected item. If that functionality is desired, use the public version (Navigate()) instead + // Arguments: + // - profile - the profile object we are getting a view of void MainPage::_Navigate(const Editor::ProfileViewModel& profile) { _lastProfilesNavState = winrt::make(profile, @@ -283,9 +288,56 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // Add an event handler for when the user wants to delete a profile. _lastProfilesNavState.DeleteProfile({ this, &MainPage::_DeleteProfile }); + // Add an event handler for when the user wants to navigate to another page + _lastProfilesNavState.Navigate([=](const auto&, const auto& args) { + if (const auto& profile{ args.try_as() }) + { + if (profile == _settingsClone.ProfileDefaults()) + { + // navigate to base layer + SettingsNav().SelectedItem(BaseLayerMenuItem()); + _Navigate(hstring{ globalProfileTag }); + } + else + { + // navigate to another profile + Navigate(_viewModelForProfile(profile)); + } + } + }); + contentFrame().Navigate(xaml_typename(), _lastProfilesNavState); } + // Method Description: + // - updates the selected item, and updates the content frame to present a view of the profile page + // - NOTE: this does not update the selected item. If that functionality is desired, use the public version (Navigate()) instead + // Arguments: + // - profile - the profile object we are getting a view of + void MainPage::Navigate(const Editor::ProfileViewModel& profile) + { + for (const auto& item : SettingsNav().MenuItems()) + { + if (const auto& navItem{ item.try_as() }) + { + if (const auto& tag{ navItem.Tag() }) + { + if (const auto& profileTag{ tag.try_as() }) + { + if (profileTag == profile) + { + SettingsNav().SelectedItem(item); + } + } + } + } + } + + // TODO GH#6800: The profile page we're navigating to is not a menu item. + // This page should be exposed as a read-only page. + _Navigate(profile); + } + void MainPage::OpenJsonTapped(IInspectable const& /*sender*/, Windows::UI::Xaml::Input::TappedRoutedEventArgs const& /*args*/) { const CoreWindow window = CoreWindow::GetForCurrentThread(); diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.h b/src/cascadia/TerminalSettingsEditor/MainPage.h index fdc48752a7e..4e2a916a26f 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.h +++ b/src/cascadia/TerminalSettingsEditor/MainPage.h @@ -25,6 +25,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SetHostingWindow(uint64_t hostingWindow) noexcept; bool TryPropagateHostingWindow(IInspectable object) noexcept; + void Navigate(const Editor::ProfileViewModel& profile); + TYPED_EVENT(OpenJson, Windows::Foundation::IInspectable, Model::SettingsTarget); private: diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.xaml b/src/cascadia/TerminalSettingsEditor/MainPage.xaml index 239380c834e..e5c48a6e151 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.xaml +++ b/src/cascadia/TerminalSettingsEditor/MainPage.xaml @@ -77,6 +77,7 @@ the MIT License. See LICENSE in the project root for license information. --> diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index bfe876eff62..e86fc766ce2 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -180,6 +180,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _DeleteProfileHandlers(*this, *deleteProfileArgs); } + void ProfilePageNavigationState::Navigate(const IInspectable& target) + { + _NavigateHandlers(*this, target); + } + Profiles::Profiles() : _ColorSchemeList{ single_threaded_observable_vector() } { @@ -306,6 +311,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } }); + // Hook up the hyperlinks from SettingContainer + _RegisterNavigationHandlers(GeneralStack()); + _RegisterNavigationHandlers(AppearanceStack()); + _RegisterNavigationHandlers(AdvancedStack()); + // Navigate to the pivot in the provided navigation state ProfilesPivot().SelectedIndex(static_cast(_State.LastActivePivot())); } @@ -315,6 +325,30 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _ViewModelChangedRevoker.revoke(); } + void Profiles::_RegisterNavigationHandlers(const DependencyObject& root) + { + const auto childCount{ Media::VisualTreeHelper::GetChildrenCount(root) }; + for (int32_t i = 0; i < childCount; ++i) + { + if (const auto& child{ Media::VisualTreeHelper::GetChild(root, i) }) + { + if (const auto& panel{ child.try_as() }) + { + // this is probably some kind of grouping of settings + // let's search through here too + _RegisterNavigationHandlers(panel); + } + else if (const auto& container{ child.try_as() }) + { + container.Navigate([=](const auto&, const auto& args) { + const auto& stateImpl{ winrt::get_self(_State) }; + stateImpl->Navigate(args); + }); + } + } + } + } + ColorScheme Profiles::CurrentColorScheme() { const auto schemeName{ _State.Profile().ColorSchemeName() }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index cec7008778e..bd0122f3ff0 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -111,11 +111,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } void DeleteProfile(); + void Navigate(const IInspectable& target); Windows::Foundation::Collections::IMapView Schemes() { return _Schemes; } void Schemes(const Windows::Foundation::Collections::IMapView& val) { _Schemes = val; } TYPED_EVENT(DeleteProfile, Editor::ProfilePageNavigationState, Editor::DeleteProfileEventArgs); + TYPED_EVENT(Navigate, Editor::ProfilePageNavigationState, Windows::Foundation::IInspectable); GETSET_PROPERTY(IHostedInWindow, WindowRoot, nullptr); GETSET_PROPERTY(Editor::ProfilesPivots, LastActivePivot, Editor::ProfilesPivots::General); GETSET_PROPERTY(Editor::ProfileViewModel, Profile, nullptr); @@ -165,6 +167,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation private: void _UpdateBIAlignmentControl(const int32_t val); + void _RegisterNavigationHandlers(const DependencyObject& root); Windows::Foundation::Collections::IMap _FontWeightMap; Editor::EnumEntry _CustomFontWeight{ nullptr }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index d12d7f0fa85..6e2586889d8 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -77,6 +77,7 @@ namespace Microsoft.Terminal.Settings.Editor ProfilesPivots LastActivePivot; event Windows.Foundation.TypedEventHandler DeleteProfile; + event Windows.Foundation.TypedEventHandler Navigate; }; [default_interface] runtimeclass Profiles : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index 0a32eb21d23..ff5543ac9a8 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -58,7 +58,8 @@ the MIT License. See LICENSE in the project root for license information. --> - + - + @@ -619,7 +620,8 @@ the MIT License. See LICENSE in the project root for license information. --> - + () }) { @@ -237,7 +238,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Documents::Hyperlink hyperlink{}; hyperlink.Click([=](auto&, auto&) { - // TODO CARLOS: navigate + _NavigateHandlers(*this, settingSrc); }); hyperlink.Inlines().Append(msgTarget); tb.Inlines().Append(hyperlink); diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.h b/src/cascadia/TerminalSettingsEditor/SettingContainer.h index 7c18162e37c..07243da2f82 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.h +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.h @@ -55,6 +55,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation DEPENDENCY_PROPERTY(bool, HasSettingValue); DEPENDENCY_PROPERTY(IInspectable, SettingOverrideSource); TYPED_EVENT(ClearSettingValue, Editor::SettingContainer, Windows::Foundation::IInspectable); + TYPED_EVENT(Navigate, Editor::SettingContainer, Windows::Foundation::IInspectable); private: static void _InitializeProperties(); diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.idl b/src/cascadia/TerminalSettingsEditor/SettingContainer.idl index 3c75cd2dc33..4cd1862843a 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.idl +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.idl @@ -20,5 +20,6 @@ namespace Microsoft.Terminal.Settings.Editor static Windows.UI.Xaml.DependencyProperty SettingOverrideSourceProperty { get; }; event Windows.Foundation.TypedEventHandler ClearSettingValue; + event Windows.Foundation.TypedEventHandler Navigate; }; } diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp index 6093be20326..ed2aa0fcb4a 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp @@ -335,6 +335,7 @@ winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings CascadiaSettings:: // tag these profiles as in-box for (const auto& profile : resultPtr->AllProfiles()) { + // TODO CARLOS: it seems like these aren't getting set. Why? const auto& profileImpl{ winrt::get_self(profile) }; profileImpl->Origin(OriginTag::InBox); } From ac9b5498f6c3d90c9c653bd894b834abfcbedbfa Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 9 Feb 2021 11:33:27 -0800 Subject: [PATCH 06/16] polish; ready for review --- .../TerminalSettingsEditor/SettingContainer.cpp | 14 ++++---------- .../CascadiaSettingsSerialization.cpp | 1 - src/cascadia/TerminalSettingsModel/IInheritable.h | 4 ++-- src/cascadia/TerminalSettingsModel/Profile.cpp | 1 + 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp index b4deb7e0d44..f0b19b888aa 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp @@ -79,13 +79,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } // update visibility for override message - if (const auto& overrideMsg{ obj.GetTemplateChild(L"OverrideMessage") }) - { - if (const auto& elem{ overrideMsg.try_as() }) - { - elem.Visibility(newVal ? Visibility::Visible : Visibility::Collapsed); - } - } + get_self(obj)->_UpdateOverrideMessage(); } void SettingContainer::OnApplyTemplate() @@ -212,17 +206,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { msgTarget.Text(RS_(L"SettingContainer_OverrideTargetWSLGenerator")); } - else if (profileSource == AzureGeneratorNamespace) + else if (profileSource == PowershellCoreGeneratorNamespace) { msgTarget.Text(RS_(L"SettingContainer_OverrideTargetPowershellGenerator")); } - else if (profileSource == PowershellCoreGeneratorNamespace) + else if (profileSource == AzureGeneratorNamespace) { msgTarget.Text(RS_(L"SettingContainer_OverrideTargetAzureCloudShellGenerator")); } else { - // TODO CARLOS: we should probably have some special handling for proto-extensions here + // TODO #1690: add special handling for proto-extensions here // unknown generator; use fallback message instead msgTarget.Text(RS_(L"SettingContainer_OverrideTarget")); } diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp index ed2aa0fcb4a..6093be20326 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp @@ -335,7 +335,6 @@ winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings CascadiaSettings:: // tag these profiles as in-box for (const auto& profile : resultPtr->AllProfiles()) { - // TODO CARLOS: it seems like these aren't getting set. Why? const auto& profileImpl{ winrt::get_self(profile) }; profileImpl->Origin(OriginTag::InBox); } diff --git a/src/cascadia/TerminalSettingsModel/IInheritable.h b/src/cascadia/TerminalSettingsModel/IInheritable.h index 6d4d4a793f1..cf5ba8f083c 100644 --- a/src/cascadia/TerminalSettingsModel/IInheritable.h +++ b/src/cascadia/TerminalSettingsModel/IInheritable.h @@ -163,7 +163,7 @@ private: \ /*iterate through parents to find one with a value*/ \ for (auto& parent : _parents) \ { \ - if (auto source{ parent->name##OverrideSource() }) \ + if (auto source{ parent->_get##name##OverrideSourceImpl() }) \ { \ return source; \ } \ @@ -272,7 +272,7 @@ private: \ /*iterate through parents to find one with a value*/ \ for (auto& parent : _parents) \ { \ - if (auto source{ parent->name##OverrideSource() }) \ + if (auto source{ parent->_get##name##OverrideSourceImpl() }) \ { \ return source; \ } \ diff --git a/src/cascadia/TerminalSettingsModel/Profile.cpp b/src/cascadia/TerminalSettingsModel/Profile.cpp index 16fa759a95b..a539399bd7c 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.cpp +++ b/src/cascadia/TerminalSettingsModel/Profile.cpp @@ -113,6 +113,7 @@ winrt::com_ptr Profile::CopySettings(winrt::com_ptr source) profile->_PixelShaderPath = source->_PixelShaderPath; profile->_BackgroundImageAlignment = source->_BackgroundImageAlignment; profile->_ConnectionType = source->_ConnectionType; + profile->_Origin = source->_Origin; return profile; } From a99afb6f9d57b72a9966e4508680708a3c5e4cdd Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 9 Feb 2021 13:32:59 -0800 Subject: [PATCH 07/16] fix build; update TerminalSettings --- src/cascadia/TerminalApp/TerminalSettings.h | 82 ++++++++++----------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalSettings.h b/src/cascadia/TerminalApp/TerminalSettings.h index 8953dc67dbb..2cd6aa0a028 100644 --- a/src/cascadia/TerminalApp/TerminalSettings.h +++ b/src/cascadia/TerminalApp/TerminalSettings.h @@ -50,22 +50,22 @@ namespace winrt::TerminalApp::implementation void ColorTable(std::array colors); std::array ColorTable(); - GETSET_SETTING(uint32_t, DefaultForeground, DEFAULT_FOREGROUND_WITH_ALPHA); - GETSET_SETTING(uint32_t, DefaultBackground, DEFAULT_BACKGROUND_WITH_ALPHA); - GETSET_SETTING(uint32_t, SelectionBackground, DEFAULT_FOREGROUND); - GETSET_SETTING(int32_t, HistorySize, DEFAULT_HISTORY_SIZE); - GETSET_SETTING(int32_t, InitialRows, 30); - GETSET_SETTING(int32_t, InitialCols, 80); - - GETSET_SETTING(bool, SnapOnInput, true); - GETSET_SETTING(bool, AltGrAliasing, true); - GETSET_SETTING(uint32_t, CursorColor, DEFAULT_CURSOR_COLOR); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::CursorStyle, CursorShape, Microsoft::Terminal::TerminalControl::CursorStyle::Vintage); - GETSET_SETTING(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); - GETSET_SETTING(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); - GETSET_SETTING(bool, CopyOnSelect, false); - - GETSET_SETTING(Windows::Foundation::IReference, TabColor, nullptr); + GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, DefaultForeground, DEFAULT_FOREGROUND_WITH_ALPHA); + GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, DefaultBackground, DEFAULT_BACKGROUND_WITH_ALPHA); + GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, SelectionBackground, DEFAULT_FOREGROUND); + GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, HistorySize, DEFAULT_HISTORY_SIZE); + GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, InitialRows, 30); + GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, InitialCols, 80); + + GETSET_SETTING(TerminalApp::TerminalSettings, bool, SnapOnInput, true); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, AltGrAliasing, true); + GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, CursorColor, DEFAULT_CURSOR_COLOR); + GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::CursorStyle, CursorShape, Microsoft::Terminal::TerminalControl::CursorStyle::Vintage); + GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, CopyOnSelect, false); + + GETSET_SETTING(TerminalApp::TerminalSettings, Windows::Foundation::IReference, TabColor, nullptr); // When set, StartingTabColor allows to create a terminal with a "sticky" tab color. // This color is prioritized above the TabColor (that is usually initialized based on profile settings). @@ -75,48 +75,48 @@ namespace winrt::TerminalApp::implementation // TODO: to ensure that this property is not populated during settings reload, // we should consider moving this property to a separate interface, // passed to the terminal only upon creation. - GETSET_SETTING(Windows::Foundation::IReference, StartingTabColor, nullptr); + GETSET_SETTING(TerminalApp::TerminalSettings, Windows::Foundation::IReference, StartingTabColor, nullptr); // ------------------------ End of Core Settings ----------------------- - GETSET_SETTING(hstring, ProfileName); - GETSET_SETTING(bool, UseAcrylic, false); - GETSET_SETTING(double, TintOpacity, 0.5); - GETSET_SETTING(hstring, Padding, DEFAULT_PADDING); - GETSET_SETTING(hstring, FontFace, DEFAULT_FONT_FACE); - GETSET_SETTING(int32_t, FontSize, DEFAULT_FONT_SIZE); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, ProfileName); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, UseAcrylic, false); + GETSET_SETTING(TerminalApp::TerminalSettings, double, TintOpacity, 0.5); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, Padding, DEFAULT_PADDING); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, FontFace, DEFAULT_FONT_FACE); + GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, FontSize, DEFAULT_FONT_SIZE); - GETSET_SETTING(winrt::Windows::UI::Text::FontWeight, FontWeight); + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Text::FontWeight, FontWeight); - GETSET_SETTING(hstring, BackgroundImage); - GETSET_SETTING(double, BackgroundImageOpacity, 1.0); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, BackgroundImage); + GETSET_SETTING(TerminalApp::TerminalSettings, double, BackgroundImageOpacity, 1.0); - GETSET_SETTING(winrt::Windows::UI::Xaml::Media::Stretch, + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill); - GETSET_SETTING(winrt::Windows::UI::Xaml::HorizontalAlignment, + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center); - GETSET_SETTING(winrt::Windows::UI::Xaml::VerticalAlignment, + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::IKeyBindings, KeyBindings, nullptr); + GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::IKeyBindings, KeyBindings, nullptr); - GETSET_SETTING(hstring, Commandline); - GETSET_SETTING(hstring, StartingDirectory); - GETSET_SETTING(hstring, StartingTitle); - GETSET_SETTING(bool, SuppressApplicationTitle); - GETSET_SETTING(hstring, EnvironmentVariables); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, Commandline); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, StartingDirectory); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, StartingTitle); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, SuppressApplicationTitle); + GETSET_SETTING(TerminalApp::TerminalSettings, hstring, EnvironmentVariables); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::ScrollbarState, ScrollState, Microsoft::Terminal::TerminalControl::ScrollbarState::Visible); + GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::ScrollbarState, ScrollState, Microsoft::Terminal::TerminalControl::ScrollbarState::Visible); - GETSET_SETTING(Microsoft::Terminal::TerminalControl::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::TerminalControl::TextAntialiasingMode::Grayscale); + GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::TerminalControl::TextAntialiasingMode::Grayscale); - GETSET_SETTING(bool, RetroTerminalEffect, false); - GETSET_SETTING(bool, ForceFullRepaintRendering, false); - GETSET_SETTING(bool, SoftwareRendering, false); - GETSET_SETTING(bool, ForceVTInput, false); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, RetroTerminalEffect, false); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, ForceFullRepaintRendering, false); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, SoftwareRendering, false); + GETSET_SETTING(TerminalApp::TerminalSettings, bool, ForceVTInput, false); GETSET_PROPERTY(hstring, PixelShaderPath); From 08e1050cd4e19cae991938aaf4fc3f9d07123408 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 9 Feb 2021 14:43:42 -0800 Subject: [PATCH 08/16] code format --- src/cascadia/TerminalApp/TerminalSettings.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalSettings.h b/src/cascadia/TerminalApp/TerminalSettings.h index d140ec1f327..74f438ac73c 100644 --- a/src/cascadia/TerminalApp/TerminalSettings.h +++ b/src/cascadia/TerminalApp/TerminalSettings.h @@ -92,15 +92,9 @@ namespace winrt::TerminalApp::implementation GETSET_SETTING(TerminalApp::TerminalSettings, hstring, BackgroundImage); GETSET_SETTING(TerminalApp::TerminalSettings, double, BackgroundImageOpacity, 1.0); - GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, - BackgroundImageStretchMode, - winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill); - GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, - BackgroundImageHorizontalAlignment, - winrt::Windows::UI::Xaml::HorizontalAlignment::Center); - GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, - BackgroundImageVerticalAlignment, - winrt::Windows::UI::Xaml::VerticalAlignment::Center); + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill); + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center); + GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center); GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::IKeyBindings, KeyBindings, nullptr); From 40d8742a979ced28c99e5505099695dfa9a33cfe Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 16 Feb 2021 15:58:18 -0800 Subject: [PATCH 09/16] redesign: remove text; update reset btn --- .../TerminalSettingsEditor/MainPage.cpp | 49 +------- .../TerminalSettingsEditor/MainPage.h | 2 - .../TerminalSettingsEditor/Profiles.cpp | 34 ------ .../TerminalSettingsEditor/Profiles.h | 3 - .../TerminalSettingsEditor/Profiles.idl | 1 - .../TerminalSettingsEditor/Profiles.xaml | 8 +- .../Resources/en-US/Resources.resw | 79 ++++++------- .../SettingContainer.cpp | 105 +++++------------- .../TerminalSettingsEditor/SettingContainer.h | 1 - .../SettingContainer.idl | 1 - .../SettingContainerStyle.xaml | 8 -- 11 files changed, 68 insertions(+), 223 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index 00b190b20cc..363acf55a43 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -275,7 +275,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // Method Description: // - updates the content frame to present a view of the profile page - // - NOTE: this does not update the selected item. If that functionality is desired, use the public version (Navigate()) instead + // - NOTE: this does not update the selected item. // Arguments: // - profile - the profile object we are getting a view of void MainPage::_Navigate(const Editor::ProfileViewModel& profile) @@ -288,56 +288,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // Add an event handler for when the user wants to delete a profile. _lastProfilesNavState.DeleteProfile({ this, &MainPage::_DeleteProfile }); - // Add an event handler for when the user wants to navigate to another page - _lastProfilesNavState.Navigate([=](const auto&, const auto& args) { - if (const auto& profile{ args.try_as() }) - { - if (profile == _settingsClone.ProfileDefaults()) - { - // navigate to base layer - SettingsNav().SelectedItem(BaseLayerMenuItem()); - _Navigate(hstring{ globalProfileTag }); - } - else - { - // navigate to another profile - Navigate(_viewModelForProfile(profile)); - } - } - }); - contentFrame().Navigate(xaml_typename(), _lastProfilesNavState); } - // Method Description: - // - updates the selected item, and updates the content frame to present a view of the profile page - // - NOTE: this does not update the selected item. If that functionality is desired, use the public version (Navigate()) instead - // Arguments: - // - profile - the profile object we are getting a view of - void MainPage::Navigate(const Editor::ProfileViewModel& profile) - { - for (const auto& item : SettingsNav().MenuItems()) - { - if (const auto& navItem{ item.try_as() }) - { - if (const auto& tag{ navItem.Tag() }) - { - if (const auto& profileTag{ tag.try_as() }) - { - if (profileTag == profile) - { - SettingsNav().SelectedItem(item); - } - } - } - } - } - - // TODO GH#6800: The profile page we're navigating to is not a menu item. - // This page should be exposed as a read-only page. - _Navigate(profile); - } - void MainPage::OpenJsonTapped(IInspectable const& /*sender*/, Windows::UI::Xaml::Input::TappedRoutedEventArgs const& /*args*/) { const CoreWindow window = CoreWindow::GetForCurrentThread(); diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.h b/src/cascadia/TerminalSettingsEditor/MainPage.h index 4e2a916a26f..fdc48752a7e 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.h +++ b/src/cascadia/TerminalSettingsEditor/MainPage.h @@ -25,8 +25,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SetHostingWindow(uint64_t hostingWindow) noexcept; bool TryPropagateHostingWindow(IInspectable object) noexcept; - void Navigate(const Editor::ProfileViewModel& profile); - TYPED_EVENT(OpenJson, Windows::Foundation::IInspectable, Model::SettingsTarget); private: diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index e86fc766ce2..bfe876eff62 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -180,11 +180,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _DeleteProfileHandlers(*this, *deleteProfileArgs); } - void ProfilePageNavigationState::Navigate(const IInspectable& target) - { - _NavigateHandlers(*this, target); - } - Profiles::Profiles() : _ColorSchemeList{ single_threaded_observable_vector() } { @@ -311,11 +306,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } }); - // Hook up the hyperlinks from SettingContainer - _RegisterNavigationHandlers(GeneralStack()); - _RegisterNavigationHandlers(AppearanceStack()); - _RegisterNavigationHandlers(AdvancedStack()); - // Navigate to the pivot in the provided navigation state ProfilesPivot().SelectedIndex(static_cast(_State.LastActivePivot())); } @@ -325,30 +315,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _ViewModelChangedRevoker.revoke(); } - void Profiles::_RegisterNavigationHandlers(const DependencyObject& root) - { - const auto childCount{ Media::VisualTreeHelper::GetChildrenCount(root) }; - for (int32_t i = 0; i < childCount; ++i) - { - if (const auto& child{ Media::VisualTreeHelper::GetChild(root, i) }) - { - if (const auto& panel{ child.try_as() }) - { - // this is probably some kind of grouping of settings - // let's search through here too - _RegisterNavigationHandlers(panel); - } - else if (const auto& container{ child.try_as() }) - { - container.Navigate([=](const auto&, const auto& args) { - const auto& stateImpl{ winrt::get_self(_State) }; - stateImpl->Navigate(args); - }); - } - } - } - } - ColorScheme Profiles::CurrentColorScheme() { const auto schemeName{ _State.Profile().ColorSchemeName() }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index bd0122f3ff0..cec7008778e 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -111,13 +111,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } void DeleteProfile(); - void Navigate(const IInspectable& target); Windows::Foundation::Collections::IMapView Schemes() { return _Schemes; } void Schemes(const Windows::Foundation::Collections::IMapView& val) { _Schemes = val; } TYPED_EVENT(DeleteProfile, Editor::ProfilePageNavigationState, Editor::DeleteProfileEventArgs); - TYPED_EVENT(Navigate, Editor::ProfilePageNavigationState, Windows::Foundation::IInspectable); GETSET_PROPERTY(IHostedInWindow, WindowRoot, nullptr); GETSET_PROPERTY(Editor::ProfilesPivots, LastActivePivot, Editor::ProfilesPivots::General); GETSET_PROPERTY(Editor::ProfileViewModel, Profile, nullptr); @@ -167,7 +165,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation private: void _UpdateBIAlignmentControl(const int32_t val); - void _RegisterNavigationHandlers(const DependencyObject& root); Windows::Foundation::Collections::IMap _FontWeightMap; Editor::EnumEntry _CustomFontWeight{ nullptr }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index 6e2586889d8..d12d7f0fa85 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -77,7 +77,6 @@ namespace Microsoft.Terminal.Settings.Editor ProfilesPivots LastActivePivot; event Windows.Foundation.TypedEventHandler DeleteProfile; - event Windows.Foundation.TypedEventHandler Navigate; }; [default_interface] runtimeclass Profiles : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index ff5543ac9a8..0a32eb21d23 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -58,8 +58,7 @@ the MIT License. See LICENSE in the project root for license information. --> - + - + @@ -620,8 +619,7 @@ the MIT License. See LICENSE in the project root for license information. --> - + - @@ -815,27 +815,14 @@ This color scheme name is already in use. - This overrides the value in {}. + This overrides the value from {}. "{}" is the object being overridden. Generally, it will be the name of another profile. Reset - - a lower layer - This is the object of "SettingContainer_OverrideIntro". - - - Azure Cloud Shell profile generator - - - PowerShell profile generator - - - system default values - - - WSL profile generator + + an autogenerated profile Enable Focus Follow Mouse mode @@ -843,4 +830,8 @@ When checked, the terminal will the focus pane on mouse hover. - + + a lower layer + This is the object of "SettingContainer_OverrideIntro". + + \ No newline at end of file diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp index f0b19b888aa..b3e22d34187 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp @@ -64,21 +64,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } - void SettingContainer::_OnHasSettingValueChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& args) + void SettingContainer::_OnHasSettingValueChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& /*args*/) { + // update visibility for override message and reset button const auto& obj{ d.try_as() }; - const auto& newVal{ unbox_value(args.NewValue()) }; - - // update visibility for reset button - if (const auto& resetButton{ obj.GetTemplateChild(L"ResetButton") }) - { - if (const auto& elem{ resetButton.try_as() }) - { - elem.Visibility(newVal ? Visibility::Visible : Visibility::Collapsed); - } - } - - // update visibility for override message get_self(obj)->_UpdateOverrideMessage(); } @@ -117,19 +106,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } }); - // apply tooltip - const auto& name{ RS_(L"SettingContainer_ResetButtonHelpText") }; - Controls::ToolTipService::SetToolTip(child, box_value(name)); - Automation::AutomationProperties::SetName(child, name); - // apply name (automation property) + Automation::AutomationProperties::SetName(child, RS_(L"SettingContainer_ResetButtonHelpText")); + + // apply help text (automation property) // NOTE: this can only be set _once_. Automation clients do not detect any changes. // As a result, we're using the more generic version of the override message. - hstring overrideMsg{ fmt::format(std::wstring_view{ RS_(L"SettingContainer_OverrideIntro") }, RS_(L"SettingContainer_OverrideTarget")) }; + const hstring overrideMsg{ fmt::format(std::wstring_view{ RS_(L"SettingContainer_OverrideIntro") }, RS_(L"SettingContainer_OverrideTarget")) }; Automation::AutomationProperties::SetHelpText(child, overrideMsg); - - // initialize visibility for reset button - button.Visibility(HasSettingValue() ? Visibility::Visible : Visibility::Collapsed); } } @@ -162,32 +146,32 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SettingContainer::_UpdateOverrideMessage() { - if (const auto& overrideMsg{ GetTemplateChild(L"OverrideMessage") }) + if (const auto& child{ GetTemplateChild(L"ResetButton") }) { - if (const auto& tb{ overrideMsg.try_as() }) + if (const auto& button{ child.try_as() }) { if (HasSettingValue()) { + // We want to be smart about showing the override system. + // Don't just show it if the user explicitly set the setting. + // If this flag is set, we'll hide the entire override system. + bool hideOverrideSystem = false; + const std::wstring templateText{ RS_(L"SettingContainer_OverrideIntro") }; const auto pos{ templateText.find(L"{}") }; + std::wstring tooltip{}; if (pos != std::wstring::npos) { // Append Message Prefix - { - Documents::Run msgPrefix{}; - msgPrefix.Text(templateText.substr(0, pos)); - tb.Inlines().Append(msgPrefix); - } + tooltip = templateText.substr(0, pos); // Append Message Target { - Documents::Run msgTarget{}; const auto& settingSrc{ SettingOverrideSource() }; if (!settingSrc) { - // no source; provide system-default view - msgTarget.Text(RS_(L"SettingContainer_OverrideTargetSystemDefaults")); - tb.Inlines().Append(msgTarget); + // no source; we're using the system-default value + hideOverrideSystem = true; } else if (const auto& profile{ settingSrc.try_as() }) { @@ -195,32 +179,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation if (originTag == Model::OriginTag::InBox) { // in-box profile - msgTarget.Text(profile.Name()); - tb.Inlines().Append(msgTarget); + hideOverrideSystem = true; } else if (originTag == Model::OriginTag::Generated) { // from a dynamic profile generator - const auto& profileSource{ profile.Source() }; - if (profileSource == WslGeneratorNamespace) - { - msgTarget.Text(RS_(L"SettingContainer_OverrideTargetWSLGenerator")); - } - else if (profileSource == PowershellCoreGeneratorNamespace) - { - msgTarget.Text(RS_(L"SettingContainer_OverrideTargetPowershellGenerator")); - } - else if (profileSource == AzureGeneratorNamespace) - { - msgTarget.Text(RS_(L"SettingContainer_OverrideTargetAzureCloudShellGenerator")); - } - else - { - // TODO #1690: add special handling for proto-extensions here - // unknown generator; use fallback message instead - msgTarget.Text(RS_(L"SettingContainer_OverrideTarget")); - } - tb.Inlines().Append(msgTarget); + // TODO #1690: add special handling for proto-extensions here + hideOverrideSystem = true; } else { @@ -228,43 +193,31 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // TODO GH#3818: When we add profile inheritance as a setting, // we'll need an extra conditional check to see if this // is the base layer or some other profile - msgTarget.Text(RS_(L"Nav_ProfileDefaults/Content")); - - Documents::Hyperlink hyperlink{}; - hyperlink.Click([=](auto&, auto&) { - _NavigateHandlers(*this, settingSrc); - }); - hyperlink.Inlines().Append(msgTarget); - tb.Inlines().Append(hyperlink); + tooltip += RS_(L"Nav_ProfileDefaults/Content"); } } else { - // unknown source; use fallback message instead - msgTarget.Text(RS_(L"SettingContainer_OverrideTarget")); - tb.Inlines().Append(msgTarget); + // unknown source + hideOverrideSystem = true; } } // Append Message Suffix - { - Documents::Run msgSuffix{}; - msgSuffix.Text(templateText.substr(pos + 2, templateText.npos)); - tb.Inlines().Append(msgSuffix); - } + tooltip += templateText.substr(pos + 2, templateText.npos); } else { // '{}' was not found - // fallback to more ambiguous version - hstring overrideMsg{ fmt::format(std::wstring_view{ RS_(L"SettingContainer_OverrideIntro") }, RS_(L"SettingContainer_OverrideTarget")) }; - tb.Text(overrideMsg); + hideOverrideSystem = true; } - tb.Visibility(Visibility::Visible); + Controls::ToolTipService::SetToolTip(button, box_value(tooltip)); + button.Visibility(hideOverrideSystem ? Visibility::Collapsed : Visibility::Visible); } else { - tb.Visibility(Visibility::Collapsed); + // a value is not being overridden; hide the override system + button.Visibility(Visibility::Collapsed); } } } diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.h b/src/cascadia/TerminalSettingsEditor/SettingContainer.h index 07243da2f82..7c18162e37c 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.h +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.h @@ -55,7 +55,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation DEPENDENCY_PROPERTY(bool, HasSettingValue); DEPENDENCY_PROPERTY(IInspectable, SettingOverrideSource); TYPED_EVENT(ClearSettingValue, Editor::SettingContainer, Windows::Foundation::IInspectable); - TYPED_EVENT(Navigate, Editor::SettingContainer, Windows::Foundation::IInspectable); private: static void _InitializeProperties(); diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.idl b/src/cascadia/TerminalSettingsEditor/SettingContainer.idl index 4cd1862843a..3c75cd2dc33 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.idl +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.idl @@ -20,6 +20,5 @@ namespace Microsoft.Terminal.Settings.Editor static Windows.UI.Xaml.DependencyProperty SettingOverrideSourceProperty { get; }; event Windows.Foundation.TypedEventHandler ClearSettingValue; - event Windows.Foundation.TypedEventHandler Navigate; }; } diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml b/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml index c7da13a0e48..ebe4bec8760 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml +++ b/src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml @@ -27,10 +27,6 @@ the MIT License. See LICENSE in the project root for license information. --> - -