From f3234412a9b51128aab97b6014420ea1b055040d Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 17 Aug 2023 13:23:12 -0500 Subject: [PATCH 1/3] Replace leftover cmdpal a11y strings --- .../Resources/en-US/Resources.resw | 22 ++++++++++++++- .../TerminalApp/SuggestionsControl.cpp | 27 +++++-------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index 80f0a9df574..2b0819d315c 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -590,6 +590,26 @@ Enter a wt commandline to run {Locked="wt"} + + More options for "{}" + This text will be read aloud using assistive technologies when the user selects a command that has additional options. The {} will be expanded to the name of the command containing more options. + + + Type a command name... + + + No matching commands + + + Suggestions menu + + + More options + + + Suggestions found: {0} + {0} will be replaced with a number. + Crimson @@ -840,4 +860,4 @@ Run as Administrator This text is displayed on context menu for profile entries in add new tab button. - \ No newline at end of file + diff --git a/src/cascadia/TerminalApp/SuggestionsControl.cpp b/src/cascadia/TerminalApp/SuggestionsControl.cpp index d70c9a6bc4d..ea969e84010 100644 --- a/src/cascadia/TerminalApp/SuggestionsControl.cpp +++ b/src/cascadia/TerminalApp/SuggestionsControl.cpp @@ -584,7 +584,7 @@ namespace winrt::TerminalApp::implementation automationPeer.RaiseNotificationEvent( Automation::Peers::AutomationNotificationKind::ActionCompleted, Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent, - fmt::format(std::wstring_view{ RS_(L"CommandPalette_NestedCommandAnnouncement") }, ParentCommandName()), + fmt::format(std::wstring_view{ RS_(L"SuggestionsControl_NestedCommandAnnouncement") }, ParentCommandName()), L"SuggestionsControlNestingLevelChanged" /* unique name for this notification category */); } } @@ -738,7 +738,7 @@ namespace winrt::TerminalApp::implementation Automation::Peers::AutomationNotificationKind::ActionCompleted, Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent, currentNeedleHasResults ? - winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"CommandPalette_MatchesAvailable") }, _filteredActions.Size()) } : + winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"SuggestionsControl_MatchesAvailable") }, _filteredActions.Size()) } : NoMatchesText(), // what to announce if results were found L"SuggestionsControlResultAnnouncement" /* unique name for this group of notifications */); } @@ -783,7 +783,6 @@ namespace winrt::TerminalApp::implementation { const auto currentlyVisible{ Visibility() == Visibility::Visible }; - auto modeAnnouncementResourceKey{ USES_RESOURCE(L"CommandPaletteModeAnnouncement_ActionMode") }; ParsedCommandLineText(L""); _searchBox().Text(L""); _searchBox().Select(_searchBox().Text().size(), 0); @@ -795,23 +794,9 @@ namespace winrt::TerminalApp::implementation // guarantees that the correct text is shown for the mode // whenever _switchToMode is called. - SearchBoxPlaceholderText(RS_(L"CommandPalette_SearchBox/PlaceholderText")); - NoMatchesText(RS_(L"CommandPalette_NoMatchesText/Text")); - ControlName(RS_(L"CommandPaletteControlName")); - // modeAnnouncementResourceKey is already set to _ActionMode - // We did this above to deduce the type (and make it easier on ourselves later). - - if (currentlyVisible) - { - if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(_searchBox()) }) - { - automationPeer.RaiseNotificationEvent( - Automation::Peers::AutomationNotificationKind::ActionCompleted, - Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent, - GetLibraryResourceString(modeAnnouncementResourceKey), - L"SuggestionsControlModeSwitch" /* unique ID for this notification */); - } - } + SearchBoxPlaceholderText(RS_(L"SuggestionsControl_SearchBox/PlaceholderText")); + NoMatchesText(RS_(L"SuggestionsControl_NoMatchesText/Text")); + ControlName(RS_(L"SuggestionsControlName")); // The smooth remove/add animations that happen during // UpdateFilteredActions don't work very well when switching between @@ -1004,7 +989,7 @@ namespace winrt::TerminalApp::implementation if (dataTemplate == _itemTemplateSelector.NestedItemTemplate()) { - const auto helpText = winrt::box_value(RS_(L"CommandPalette_MoreOptions/[using:Windows.UI.Xaml.Automation]AutomationProperties/HelpText")); + const auto helpText = winrt::box_value(RS_(L"SuggestionsControl_MoreOptions/[using:Windows.UI.Xaml.Automation]AutomationProperties/HelpText")); listViewItem.SetValue(Automation::AutomationProperties::HelpTextProperty(), helpText); } From a8b4bb95b09ce2f30feccfcb5420a7dfbbca6b34 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 17 Aug 2023 13:39:14 -0500 Subject: [PATCH 2/3] automove the cursor to the right place --- src/cascadia/TerminalApp/SuggestionsControl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalApp/SuggestionsControl.cpp b/src/cascadia/TerminalApp/SuggestionsControl.cpp index ea969e84010..8454e4040dd 100644 --- a/src/cascadia/TerminalApp/SuggestionsControl.cpp +++ b/src/cascadia/TerminalApp/SuggestionsControl.cpp @@ -781,8 +781,6 @@ namespace winrt::TerminalApp::implementation void SuggestionsControl::_switchToMode() { - const auto currentlyVisible{ Visibility() == Visibility::Visible }; - ParsedCommandLineText(L""); _searchBox().Text(L""); _searchBox().Select(_searchBox().Text().size(), 0); @@ -1089,6 +1087,11 @@ namespace winrt::TerminalApp::implementation Margin(newMargin); _searchBox().Text(filter); + + // Move the cursor to the very last position, so it starts immediately + // after the text. This is apparently done by starting a 0-wide + // selection starting at the end of the string. + _searchBox().Select(filter.size(), 0); } } From 5e2d1a89d545396d770d9e068d8ebece43516a89 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 17 Aug 2023 14:58:53 -0500 Subject: [PATCH 3/3] last nit --- src/cascadia/TerminalApp/SuggestionsControl.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/SuggestionsControl.cpp b/src/cascadia/TerminalApp/SuggestionsControl.cpp index 8454e4040dd..742e8222015 100644 --- a/src/cascadia/TerminalApp/SuggestionsControl.cpp +++ b/src/cascadia/TerminalApp/SuggestionsControl.cpp @@ -725,10 +725,12 @@ namespace winrt::TerminalApp::implementation // here will ensure that we can check this case appropriately. _lastFilterTextWasEmpty = _searchBox().Text().empty(); + const auto lastSelectedIndex = _filteredActionsView().SelectedIndex(); + _updateFilteredActions(); // In the command line mode we want the user to explicitly select the command - _filteredActionsView().SelectedIndex(0); + _filteredActionsView().SelectedIndex(std::min(lastSelectedIndex, _filteredActionsView().Items().Size() - 1)); const auto currentNeedleHasResults{ _filteredActions.Size() > 0 }; _noMatchesText().Visibility(currentNeedleHasResults ? Visibility::Collapsed : Visibility::Visible); @@ -1088,6 +1090,14 @@ namespace winrt::TerminalApp::implementation _searchBox().Text(filter); + // If we're in bottom-up mode, make sure to re-select the _last_ item in + // the list, so that it's like we're starting with the most recent one + // selected. + if (_direction == TerminalApp::SuggestionsDirection::BottomUp) + { + const auto last = _filteredActionsView().Items().Size() - 1; + _filteredActionsView().SelectedIndex(last); + } // Move the cursor to the very last position, so it starts immediately // after the text. This is apparently done by starting a 0-wide // selection starting at the end of the string.