From 6daa70a36318bf6325711d1b24a0bdc5504938c8 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 26 Feb 2020 12:41:17 -0800 Subject: [PATCH 1/3] automation properties for TermControl --- src/cascadia/TerminalApp/Profile.cpp | 1 + src/cascadia/TerminalControl/TermControl.cpp | 5 ++ src/cascadia/TerminalControl/TermControl.h | 1 + .../TermControlAutomationPeer.cpp | 47 +++++++++++++++---- .../TermControlAutomationPeer.h | 23 +++++---- .../TerminalSettings/IControlSettings.idl | 2 + .../TerminalSettings/TerminalSettings.cpp | 11 +++++ .../TerminalSettings/terminalsettings.h | 3 ++ 8 files changed, 75 insertions(+), 18 deletions(-) diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp index adcc9f76662..266e9905eeb 100644 --- a/src/cascadia/TerminalApp/Profile.cpp +++ b/src/cascadia/TerminalApp/Profile.cpp @@ -178,6 +178,7 @@ TerminalSettings Profile::CreateTerminalSettings(const std::unordered_map(*owner) // pass owner to FrameworkElementAutomationPeer + TermControlAutomationPeerT(*owner), // pass owner to FrameworkElementAutomationPeer + _owner{ owner } { THROW_IF_FAILED(::Microsoft::WRL::MakeAndInitialize<::Microsoft::Terminal::TermControlUiaProvider>(&_uiaProvider, owner, std::bind(&TermControlAutomationPeer::GetBoundingRectWrapped, this))); }; @@ -75,7 +76,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation }); } - winrt::hstring TermControlAutomationPeer::GetClassNameCore() const + hstring TermControlAutomationPeer::GetClassNameCore() const { return L"TermControl"; } @@ -85,13 +86,13 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return AutomationControlType::Text; } - winrt::hstring TermControlAutomationPeer::GetLocalizedControlTypeCore() const + hstring TermControlAutomationPeer::GetLocalizedControlTypeCore() const { // TODO GitHub #2142: Localize string return L"TerminalControl"; } - winrt::Windows::Foundation::IInspectable TermControlAutomationPeer::GetPatternCore(PatternInterface patternInterface) const + Windows::Foundation::IInspectable TermControlAutomationPeer::GetPatternCore(PatternInterface patternInterface) const { switch (patternInterface) { @@ -103,15 +104,41 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation } } + AutomationOrientation TermControlAutomationPeer::GetOrientationCore() const + { + return AutomationOrientation::Vertical; + } + + hstring TermControlAutomationPeer::GetNameCore() const + { + // fallback to title if profile name is empty + auto profileName = _owner->GetProfileName(); + if (profileName.empty()) + { + return _owner->Title(); + } + return profileName; + } + + hstring TermControlAutomationPeer::GetHelpTextCore() const + { + return _owner->Title(); + } + + AutomationLiveSetting TermControlAutomationPeer::GetLiveSettingCore() const + { + return AutomationLiveSetting::Polite; + } + #pragma region ITextProvider - winrt::com_array TermControlAutomationPeer::GetSelection() + com_array TermControlAutomationPeer::GetSelection() { SAFEARRAY* pReturnVal; THROW_IF_FAILED(_uiaProvider->GetSelection(&pReturnVal)); return WrapArrayOfTextRangeProviders(pReturnVal); } - winrt::com_array TermControlAutomationPeer::GetVisibleRanges() + com_array TermControlAutomationPeer::GetVisibleRanges() { SAFEARRAY* pReturnVal; THROW_IF_FAILED(_uiaProvider->GetVisibleRanges(&pReturnVal)); @@ -150,7 +177,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return xutr.as(); } - Windows::UI::Xaml::Automation::SupportedTextSelection TermControlAutomationPeer::SupportedTextSelection() + XamlAutomation::SupportedTextSelection TermControlAutomationPeer::SupportedTextSelection() { UIA::SupportedTextSelection returnVal; THROW_IF_FAILED(_uiaProvider->get_SupportedTextSelection(&returnVal)); @@ -176,7 +203,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation // - SAFEARRAY of UIA::UiaTextRange (ITextRangeProviders) // Return Value: // - com_array of Xaml Wrapped UiaTextRange (ITextRangeProviders) - winrt::com_array TermControlAutomationPeer::WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges) + com_array TermControlAutomationPeer::WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges) { // transfer ownership of UiaTextRanges to this new vector auto providers = SafeArrayToOwningVector<::Microsoft::Terminal::UiaTextRange>(textRanges); @@ -187,11 +214,11 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation auto parentProvider = this->ProviderFromPeer(*this); for (int i = 0; i < count; i++) { - auto xutr = winrt::make_self(providers[i].detach(), parentProvider); + auto xutr = make_self(providers[i].detach(), parentProvider); vec.emplace_back(xutr.as()); } - winrt::com_array result{ vec }; + com_array result{ vec }; return result; } diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.h b/src/cascadia/TerminalControl/TermControlAutomationPeer.h index d5bfc4b09d1..3cf758103bc 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.h +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.h @@ -37,12 +37,18 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation ::Microsoft::Console::Types::IUiaEventDispatcher { public: - TermControlAutomationPeer(winrt::Microsoft::Terminal::TerminalControl::implementation::TermControl* owner); + TermControlAutomationPeer(Microsoft::Terminal::TerminalControl::implementation::TermControl* owner); - winrt::hstring GetClassNameCore() const; - winrt::Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() const; - winrt::hstring GetLocalizedControlTypeCore() const; - winrt::Windows::Foundation::IInspectable GetPatternCore(winrt::Windows::UI::Xaml::Automation::Peers::PatternInterface patternInterface) const; +#pragma region FrameworkElementAutomationPeer + hstring GetClassNameCore() const; + Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() const; + hstring GetLocalizedControlTypeCore() const; + Windows::Foundation::IInspectable GetPatternCore(Windows::UI::Xaml::Automation::Peers::PatternInterface patternInterface) const; + Windows::UI::Xaml::Automation::Peers::AutomationOrientation GetOrientationCore() const; + hstring GetNameCore() const; + hstring GetHelpTextCore() const; + Windows::UI::Xaml::Automation::Peers::AutomationLiveSetting GetLiveSettingCore() const; +#pragma endregion #pragma region IUiaEventDispatcher void SignalSelectionChanged() override; @@ -53,8 +59,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation #pragma region ITextProvider Pattern Windows::UI::Xaml::Automation::Provider::ITextRangeProvider RangeFromPoint(Windows::Foundation::Point screenLocation); Windows::UI::Xaml::Automation::Provider::ITextRangeProvider RangeFromChild(Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple childElement); - winrt::com_array GetVisibleRanges(); - winrt::com_array GetSelection(); + com_array GetVisibleRanges(); + com_array GetSelection(); Windows::UI::Xaml::Automation::SupportedTextSelection SupportedTextSelection(); Windows::UI::Xaml::Automation::Provider::ITextRangeProvider DocumentRange(); #pragma endregion @@ -63,7 +69,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation private: ::Microsoft::WRL::ComPtr<::Microsoft::Terminal::TermControlUiaProvider> _uiaProvider; + ::Microsoft::WRL::ComPtr _owner; - winrt::com_array WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges); + com_array WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges); }; } diff --git a/src/cascadia/TerminalSettings/IControlSettings.idl b/src/cascadia/TerminalSettings/IControlSettings.idl index f290792932b..fce0af39654 100644 --- a/src/cascadia/TerminalSettings/IControlSettings.idl +++ b/src/cascadia/TerminalSettings/IControlSettings.idl @@ -19,6 +19,8 @@ namespace Microsoft.Terminal.Settings // for specifically the control. interface IControlSettings requires Microsoft.Terminal.Settings.ICoreSettings { + String ProfileName; + Boolean UseAcrylic; Double TintOpacity; ScrollbarState ScrollState; diff --git a/src/cascadia/TerminalSettings/TerminalSettings.cpp b/src/cascadia/TerminalSettings/TerminalSettings.cpp index 10d7fbd7f78..46179d157a0 100644 --- a/src/cascadia/TerminalSettings/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettings/TerminalSettings.cpp @@ -28,6 +28,7 @@ namespace winrt::Microsoft::Terminal::Settings::implementation _cursorHeight{ DEFAULT_CURSOR_HEIGHT }, _wordDelimiters{ DEFAULT_WORD_DELIMITERS }, _copyOnSelect{ false }, + _profileName{}, _useAcrylic{ false }, _tintOpacity{ 0.5 }, _padding{ DEFAULT_PADDING }, @@ -194,6 +195,16 @@ namespace winrt::Microsoft::Terminal::Settings::implementation _copyOnSelect = value; } + void TerminalSettings::ProfileName(hstring const& value) + { + _profileName = value; + } + + hstring TerminalSettings::ProfileName() + { + return _profileName; + } + bool TerminalSettings::UseAcrylic() noexcept { return _useAcrylic; diff --git a/src/cascadia/TerminalSettings/terminalsettings.h b/src/cascadia/TerminalSettings/terminalsettings.h index 111874131fa..cb05a64f54f 100644 --- a/src/cascadia/TerminalSettings/terminalsettings.h +++ b/src/cascadia/TerminalSettings/terminalsettings.h @@ -55,6 +55,8 @@ namespace winrt::Microsoft::Terminal::Settings::implementation void CopyOnSelect(bool value) noexcept; // ------------------------ End of Core Settings ----------------------- + hstring ProfileName(); + void ProfileName(hstring const& value); bool UseAcrylic() noexcept; void UseAcrylic(bool value) noexcept; double TintOpacity() noexcept; @@ -117,6 +119,7 @@ namespace winrt::Microsoft::Terminal::Settings::implementation uint32_t _cursorHeight; hstring _wordDelimiters; + hstring _profileName; bool _useAcrylic; double _tintOpacity; hstring _fontFace; From 563b578cfa4f92b96cb44f0e705e1be60b80adca Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 26 Feb 2020 16:56:07 -0800 Subject: [PATCH 2/3] Localize Search Box and TCAP --- .../Resources/en-US/Resources.resw | 97 +++++++++++-------- .../TerminalControl/SearchBoxControl.xaml | 39 +++++--- .../TermControlAutomationPeer.cpp | 4 +- .../TerminalControl.vcxproj.filters | 10 +- 4 files changed, 96 insertions(+), 54 deletions(-) diff --git a/src/cascadia/TerminalControl/Resources/en-US/Resources.resw b/src/cascadia/TerminalControl/Resources/en-US/Resources.resw index afcdaee51e5..628d7071023 100644 --- a/src/cascadia/TerminalControl/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalControl/Resources/en-US/Resources.resw @@ -1,17 +1,17 @@ - @@ -117,27 +117,48 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Match Case - The tooltip text for CaseSensitivityButton + The tooltip text for the case sensitivity button on the search box control. - + Close - The tooltip text for CloseButton + The tooltip text for the close button on the search box control. - + Find Up - The tooltip text for GoBackward Button + The tooltip text for the search backward button. - + Find Down - The tooltip text for GoForward Button + The tooltip text for the search forward button. - + Find... - The placeholder text in the search dialog TextBox + The placeholder text in the search box control. Copy path to file + The displayed caption for dragging a file onto a terminal. + + + Case Sensitivity + The name of the case sensitivity button on the search box control for accessibility. + + + Search Forward + The name of the search forward button for accessibility. + + + Search Backward + The name of the search backward button for accessibility. + + + Search Text + The name of the text box on the search box control for accessibility. + + + terminal + The type of control that the terminal ahderes to. Used to identify how a user can interact with this kind of control. - + \ No newline at end of file diff --git a/src/cascadia/TerminalControl/SearchBoxControl.xaml b/src/cascadia/TerminalControl/SearchBoxControl.xaml index 08a0bd5ef44..2bf71326451 100644 --- a/src/cascadia/TerminalControl/SearchBoxControl.xaml +++ b/src/cascadia/TerminalControl/SearchBoxControl.xaml @@ -153,29 +153,44 @@ - + - + - - + - diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp index 4d54c63241e..4863761fe85 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp @@ -3,6 +3,7 @@ #include "pch.h" #include +#include #include "TermControlAutomationPeer.h" #include "TermControl.h" #include "TermControlAutomationPeer.g.cpp" @@ -88,8 +89,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation hstring TermControlAutomationPeer::GetLocalizedControlTypeCore() const { - // TODO GitHub #2142: Localize string - return L"TerminalControl"; + return RS_(L"TerminalControl_ControlType"); } Windows::Foundation::IInspectable TermControlAutomationPeer::GetPatternCore(PatternInterface patternInterface) const diff --git a/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters b/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters index 3a9cb6eab60..4beb0ecafcf 100644 --- a/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters +++ b/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters @@ -18,6 +18,7 @@ + @@ -26,12 +27,12 @@ - + @@ -43,4 +44,9 @@ - + + + Resources + + + \ No newline at end of file From 2e475e661767af461fa539c8bba60b7ed1aa381e Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett (MSFT)" Date: Thu, 27 Feb 2020 16:36:28 -0800 Subject: [PATCH 3/3] Update src/cascadia/TerminalControl/TerminalControl.vcxproj.filters --- src/cascadia/TerminalControl/TerminalControl.vcxproj.filters | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters b/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters index 4beb0ecafcf..d90f6304cae 100644 --- a/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters +++ b/src/cascadia/TerminalControl/TerminalControl.vcxproj.filters @@ -45,8 +45,8 @@ - + Resources - \ No newline at end of file +