From 18d86bca091f1316f4176b90cfac6973f990966d Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Thu, 10 Oct 2024 16:54:31 -0700 Subject: [PATCH] Add a Compatibility and Terminal page to the Settings UI (#17895) ## Summary of the Pull Request Adds a global Compatibility page to the settings UI. This page exposes several existing settings and introduces a few new settings: - compatibility.allowHeadless - compatibility.isolatedMode - compatibility.textMeasurement - debugFeatures This also adds a Terminal subpage for profiles in the settings UI. This page includes: - suppressApplicationTitle - compatibility.input.forceVT - compatibility.allowDECRQCRA - answerbackMessage Several smaller changes were accomplished as a part of this PR: - `experimental.input.forceVT` was renamed to `compatibility.input.forceVT` - introduced the `compatibility.allowDECRQCRA` setting - updated the schema for these new settings and `compatibility.allowHeadless` (which was missing) - add `Feature_DebugModeUI` feature flag to control if debug features should be shown in the SUI Verified accessible via Accessibility Insights A part of #10000 Closes #16672 --- doc/cascadia/profiles.schema.json | 10 ++ src/cascadia/TerminalCore/ICoreSettings.idl | 1 + src/cascadia/TerminalCore/Terminal.cpp | 11 ++ src/cascadia/TerminalCore/Terminal.hpp | 1 + .../TerminalSettingsEditor/Compatibility.cpp | 35 ++++++ .../TerminalSettingsEditor/Compatibility.h | 47 ++++++++ .../TerminalSettingsEditor/Compatibility.idl | 29 +++++ .../TerminalSettingsEditor/Compatibility.xaml | 56 ++++++++++ .../TerminalSettingsEditor/MainPage.cpp | 23 ++++ .../TerminalSettingsEditor/MainPage.idl | 1 + .../TerminalSettingsEditor/MainPage.xaml | 7 ++ ...Microsoft.Terminal.Settings.Editor.vcxproj | 28 +++++ .../TerminalSettingsEditor/ProfileViewModel.h | 3 + .../ProfileViewModel.idl | 6 +- .../Profiles_Advanced.xaml | 9 -- .../TerminalSettingsEditor/Profiles_Base.cpp | 6 + .../TerminalSettingsEditor/Profiles_Base.h | 1 + .../TerminalSettingsEditor/Profiles_Base.xaml | 13 +-- .../Profiles_Terminal.cpp | 31 ++++++ .../Profiles_Terminal.h | 31 ++++++ .../Profiles_Terminal.idl | 13 +++ .../Profiles_Terminal.xaml | 75 +++++++++++++ .../TerminalSettingsEditor/Rendering.xaml | 8 -- .../RenderingViewModel.cpp | 1 - .../RenderingViewModel.h | 1 - .../RenderingViewModel.idl | 2 - .../Resources/en-US/Resources.resw | 52 +++++++++ .../CascadiaSettingsSerialization.cpp | 9 ++ .../GlobalAppSettings.cpp | 7 ++ .../TerminalSettingsModel/GlobalAppSettings.h | 2 + .../GlobalAppSettings.idl | 1 - .../TerminalSettingsModel/MTSMSettings.h | 6 +- .../TerminalSettingsModel/Profile.idl | 4 +- .../TerminalSettings.cpp | 3 +- .../TerminalSettingsModel/TerminalSettings.h | 1 + .../SerializationTests.cpp | 2 - src/cascadia/inc/ControlProperties.h | 3 +- src/features.xml | 7 ++ src/terminal/adapter/ITermDispatch.hpp | 1 + src/terminal/adapter/adaptDispatch.cpp | 104 ++++++++++-------- src/terminal/adapter/adaptDispatch.hpp | 4 + src/terminal/adapter/termDispatch.hpp | 2 + .../adapter/ut_adapter/adapterTest.cpp | 1 + 43 files changed, 572 insertions(+), 86 deletions(-) create mode 100644 src/cascadia/TerminalSettingsEditor/Compatibility.cpp create mode 100644 src/cascadia/TerminalSettingsEditor/Compatibility.h create mode 100644 src/cascadia/TerminalSettingsEditor/Compatibility.idl create mode 100644 src/cascadia/TerminalSettingsEditor/Compatibility.xaml create mode 100644 src/cascadia/TerminalSettingsEditor/Profiles_Terminal.cpp create mode 100644 src/cascadia/TerminalSettingsEditor/Profiles_Terminal.h create mode 100644 src/cascadia/TerminalSettingsEditor/Profiles_Terminal.idl create mode 100644 src/cascadia/TerminalSettingsEditor/Profiles_Terminal.xaml diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index c0b659ccc42..ec903dc5b80 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -2355,11 +2355,21 @@ "description": "When set to true, the terminal will focus the pane on mouse hover.", "type": "boolean" }, + "compatibility.allowHeadless": { + "default": false, + "description": "When set to true, Windows Terminal will run in the background. This allows globalSummon and quakeMode actions to work even when no windows are open.", + "type": "boolean" + }, "compatibility.isolatedMode": { "default": false, "description": "When set to true, Terminal windows will not be able to interact with each other (including global hotkeys, tab drag/drop, running commandlines in existing windows, etc.). This is a compatibility escape hatch for users who are running into certain windowing issues.", "type": "boolean" }, + "compatibility.allowDECRQCRA": { + "default": false, + "description": "When set to true, the terminal will support the DECRQCRA (Request Checksum of Rectangular Area) escape sequence.", + "type": "boolean" + }, "copyFormatting": { "default": true, "description": "When set to `true`, the color and font formatting of selected text is also copied to your clipboard. When set to `false`, only plain text is copied to your clipboard. An array of specific formats can also be used. Supported array values include `html` and `rtf`. Plain text is always copied.", diff --git a/src/cascadia/TerminalCore/ICoreSettings.idl b/src/cascadia/TerminalCore/ICoreSettings.idl index 112a6f6b1f2..ff6588c2ead 100644 --- a/src/cascadia/TerminalCore/ICoreSettings.idl +++ b/src/cascadia/TerminalCore/ICoreSettings.idl @@ -21,6 +21,7 @@ namespace Microsoft.Terminal.Core String WordDelimiters; Boolean ForceVTInput; + Boolean AllowVtChecksumReport; Boolean TrimBlockSelection; Boolean DetectURLs; diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 135c8abd785..c61c339b79e 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -90,6 +90,11 @@ void Terminal::UpdateSettings(ICoreSettings settings) _autoMarkPrompts = settings.AutoMarkPrompts(); _rainbowSuggestions = settings.RainbowSuggestions(); + if (_stateMachine) + { + SetVtChecksumReportSupport(settings.AllowVtChecksumReport()); + } + _getTerminalInput().ForceDisableWin32InputMode(settings.ForceVTInput()); if (settings.TabColor() == nullptr) @@ -212,6 +217,12 @@ void Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) engine.Dispatch().SetCursorStyle(cursorStyle); } +void Terminal::SetVtChecksumReportSupport(const bool enabled) +{ + auto& engine = reinterpret_cast(_stateMachine->Engine()); + engine.Dispatch().SetVtChecksumReportSupport(enabled); +} + bool Terminal::IsXtermBracketedPasteModeEnabled() const noexcept { return _systemMode.test(Mode::BracketedPaste); diff --git a/src/cascadia/TerminalCore/Terminal.hpp b/src/cascadia/TerminalCore/Terminal.hpp index e8accf24e7e..7fdf0995013 100644 --- a/src/cascadia/TerminalCore/Terminal.hpp +++ b/src/cascadia/TerminalCore/Terminal.hpp @@ -94,6 +94,7 @@ class Microsoft::Terminal::Core::Terminal final : void UpdateAppearance(const winrt::Microsoft::Terminal::Core::ICoreAppearance& appearance); void SetFontInfo(const FontInfo& fontInfo); void SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle); + void SetVtChecksumReportSupport(const bool enabled); bool IsXtermBracketedPasteModeEnabled() const noexcept; std::wstring_view GetWorkingDirectory() noexcept; diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.cpp b/src/cascadia/TerminalSettingsEditor/Compatibility.cpp new file mode 100644 index 00000000000..e95b17fe135 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.cpp @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "Compatibility.h" +#include "EnumEntry.h" +#include "Compatibility.g.cpp" +#include "CompatibilityViewModel.g.cpp" + +using namespace winrt::Windows::UI::Xaml::Navigation; +using namespace winrt::Microsoft::Terminal::Settings::Model; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + CompatibilityViewModel::CompatibilityViewModel(Model::GlobalAppSettings globalSettings) : + _GlobalSettings{ globalSettings } + { + INITIALIZE_BINDABLE_ENUM_SETTING(TextMeasurement, TextMeasurement, winrt::Microsoft::Terminal::Control::TextMeasurement, L"Globals_TextMeasurement_", L"Text"); + } + + bool CompatibilityViewModel::DebugFeaturesAvailable() const noexcept + { + return Feature_DebugModeUI::IsEnabled(); + } + + Compatibility::Compatibility() + { + InitializeComponent(); + } + + void Compatibility::OnNavigatedTo(const NavigationEventArgs& e) + { + _ViewModel = e.Parameter().as(); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.h b/src/cascadia/TerminalSettingsEditor/Compatibility.h new file mode 100644 index 00000000000..018bb276ceb --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.h @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "Compatibility.g.h" +#include "CompatibilityViewModel.g.h" +#include "ViewModelHelpers.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct CompatibilityViewModel : CompatibilityViewModelT, ViewModelHelper + { + public: + CompatibilityViewModel(Model::GlobalAppSettings globalSettings); + + bool DebugFeaturesAvailable() const noexcept; + + // DON'T YOU DARE ADD A `WINRT_CALLBACK(PropertyChanged` TO A CLASS DERIVED FROM ViewModelHelper. Do this instead: + using ViewModelHelper::PropertyChanged; + + PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AllowHeadless); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, IsolatedMode); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, DebugFeaturesEnabled); + GETSET_BINDABLE_ENUM_SETTING(TextMeasurement, winrt::Microsoft::Terminal::Control::TextMeasurement, _GlobalSettings.TextMeasurement); + + private: + Model::GlobalAppSettings _GlobalSettings; + }; + + struct Compatibility : public HasScrollViewer, CompatibilityT + { + Compatibility(); + + void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e); + + til::property_changed_event PropertyChanged; + WINRT_OBSERVABLE_PROPERTY(Editor::CompatibilityViewModel, ViewModel, PropertyChanged.raise, nullptr); + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(Compatibility); + BASIC_FACTORY(CompatibilityViewModel); +} diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.idl b/src/cascadia/TerminalSettingsEditor/Compatibility.idl new file mode 100644 index 00000000000..a05ed30e7ad --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.idl @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import "EnumEntry.idl"; + +#include "ViewModelHelpers.idl.h" + +namespace Microsoft.Terminal.Settings.Editor +{ + runtimeclass CompatibilityViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + CompatibilityViewModel(Microsoft.Terminal.Settings.Model.GlobalAppSettings globalSettings); + + Boolean DebugFeaturesAvailable { get; }; + + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AllowHeadless); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, IsolatedMode); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DebugFeaturesEnabled); + + IInspectable CurrentTextMeasurement; + Windows.Foundation.Collections.IObservableVector TextMeasurementList { get; }; + } + + [default_interface] runtimeclass Compatibility : Windows.UI.Xaml.Controls.Page + { + Compatibility(); + CompatibilityViewModel ViewModel { get; }; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.xaml b/src/cascadia/TerminalSettingsEditor/Compatibility.xaml new file mode 100644 index 00000000000..b982cd50d30 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index 76bbeacb248..696579ae950 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -6,6 +6,7 @@ #include "MainPage.g.cpp" #include "Launch.h" #include "Interaction.h" +#include "Compatibility.h" #include "Rendering.h" #include "RenderingViewModel.h" #include "Actions.h" @@ -39,6 +40,7 @@ using namespace winrt::Windows::Foundation::Collections; static const std::wstring_view launchTag{ L"Launch_Nav" }; static const std::wstring_view interactionTag{ L"Interaction_Nav" }; static const std::wstring_view renderingTag{ L"Rendering_Nav" }; +static const std::wstring_view compatibilityTag{ L"Compatibility_Nav" }; static const std::wstring_view actionsTag{ L"Actions_Nav" }; static const std::wstring_view globalProfileTag{ L"GlobalProfile_Nav" }; static const std::wstring_view addProfileTag{ L"AddProfile" }; @@ -339,6 +341,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _breadcrumbs.Append(crumb); SettingsMainPage_ScrollViewer().ScrollToVerticalOffset(0); } + else if (currentPage == ProfileSubPage::Terminal) + { + contentFrame().Navigate(xaml_typename(), profile); + const auto crumb = winrt::make(breadcrumbTag, RS_(L"Profile_Terminal/Header"), BreadcrumbSubPage::Profile_Terminal); + _breadcrumbs.Append(crumb); + SettingsMainPage_ScrollViewer().ScrollToVerticalOffset(0); + } else if (currentPage == ProfileSubPage::Advanced) { contentFrame().Navigate(xaml_typename(), profile); @@ -372,6 +381,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation const auto crumb = winrt::make(box_value(clickedItemTag), RS_(L"Nav_Rendering/Content"), BreadcrumbSubPage::None); _breadcrumbs.Append(crumb); } + else if (clickedItemTag == compatibilityTag) + { + contentFrame().Navigate(xaml_typename(), winrt::make(_settingsClone.GlobalSettings())); + const auto crumb = winrt::make(box_value(clickedItemTag), RS_(L"Nav_Compatibility/Content"), BreadcrumbSubPage::None); + _breadcrumbs.Append(crumb); + } else if (clickedItemTag == actionsTag) { contentFrame().Navigate(xaml_typename(), winrt::make(_settingsClone)); @@ -395,6 +410,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { profileVM.CurrentPage(ProfileSubPage::Appearance); } + else if (subPage == BreadcrumbSubPage::Profile_Terminal) + { + profileVM.CurrentPage(ProfileSubPage::Terminal); + } else if (subPage == BreadcrumbSubPage::Profile_Advanced) { profileVM.CurrentPage(ProfileSubPage::Advanced); @@ -452,6 +471,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { profile.CurrentPage(ProfileSubPage::Appearance); } + else if (subPage == BreadcrumbSubPage::Profile_Terminal) + { + profile.CurrentPage(ProfileSubPage::Terminal); + } else if (subPage == BreadcrumbSubPage::Profile_Advanced) { profile.CurrentPage(ProfileSubPage::Advanced); diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.idl b/src/cascadia/TerminalSettingsEditor/MainPage.idl index 419981d94de..d02251f7a4d 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.idl +++ b/src/cascadia/TerminalSettingsEditor/MainPage.idl @@ -17,6 +17,7 @@ namespace Microsoft.Terminal.Settings.Editor { None = 0, Profile_Appearance, + Profile_Terminal, Profile_Advanced, ColorSchemes_Edit }; diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.xaml b/src/cascadia/TerminalSettingsEditor/MainPage.xaml index d63d634d2e0..7d96589f0ec 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.xaml +++ b/src/cascadia/TerminalSettingsEditor/MainPage.xaml @@ -135,6 +135,13 @@ + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj index 836ec79a904..7d2aed1b744 100644 --- a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj +++ b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj @@ -64,6 +64,9 @@ Interaction.xaml + + Compatibility.xaml + KeyChordListener.xaml @@ -118,6 +121,10 @@ Profiles_Appearance.xaml Code + + Profiles_Terminal.xaml + Code + Appearances.xaml Code @@ -154,6 +161,9 @@ Designer + + Designer + Designer @@ -172,6 +182,9 @@ Designer + + Designer + Designer @@ -204,6 +217,9 @@ Interaction.xaml + + Compatibility.xaml + KeyChordListener.xaml @@ -261,6 +277,10 @@ Profiles_Appearance.xaml Code + + Profiles_Terminal.xaml + Code + Appearances.xaml Code @@ -311,6 +331,10 @@ Interaction.xaml Code + + Compatibility.xaml + Code + Rendering.xaml Code @@ -338,6 +362,10 @@ Profiles_Appearance.xaml Code + + Profiles_Terminal.xaml + Code + Appearances.xaml Code diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index 5002f46ca6c..c396fe38ec8 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -120,6 +120,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation OBSERVABLE_PROJECTED_SETTING(_profile, ShowMarks); OBSERVABLE_PROJECTED_SETTING(_profile, AutoMarkPrompts); OBSERVABLE_PROJECTED_SETTING(_profile, RepositionCursorWithMouse); + OBSERVABLE_PROJECTED_SETTING(_profile, ForceVTInput); + OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtChecksumReport); + OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage); OBSERVABLE_PROJECTED_SETTING(_profile, RainbowSuggestions); WINRT_PROPERTY(bool, IsBaseLayer, false); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl index 534b5572238..9bf20079cba 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl @@ -29,7 +29,8 @@ namespace Microsoft.Terminal.Settings.Editor { Base = 0, Appearance = 1, - Advanced = 2 + Terminal = 2, + Advanced = 3 }; runtimeclass ProfileViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged @@ -111,6 +112,9 @@ namespace Microsoft.Terminal.Settings.Editor OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ShowMarks); OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AutoMarkPrompts); OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RepositionCursorWithMouse); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ForceVTInput); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtChecksumReport); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, AnswerbackMessage); OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RainbowSuggestions); } } diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml index 13f0d12507d..d7abab4f733 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml @@ -37,15 +37,6 @@ Visibility="{x:Bind Profile.IsBaseLayer}" /> - - - - - - Appearance - + Style="{StaticResource NavigatorButtonStyle}" /> + + Style="{StaticResource NavigatorButtonStyle}" />