* Created a ViewModel class in the Command Palette called FilteredCommand, aggregating the Command, the filter and the highlighted presentation of the command name * This ListView of the filtered commands is bound to the vector of FilteredCommands * Introduced HighlightedTextControl user control with HighlightedText view model * Added this control to the ListView Item's grid * Bound the FilteredCommand's highlighted command name to the user control ## Validation Steps Performed * UT for matching algorithm * Only manual tests * Searching in CommandLine, SwitchTab and Nested Command modes * Checking for bot matching an non matching filters * Dogfooding Closes #6646
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "HighlightedTextControl.h"
|
|
#include "FilteredCommand.g.h"
|
|
#include "../../cascadia/inc/cppwinrt_utils.h"
|
|
|
|
// fwdecl unittest classes
|
|
namespace TerminalAppLocalTests
|
|
{
|
|
class FilteredCommandTests;
|
|
};
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
{
|
|
struct FilteredCommand : FilteredCommandT<FilteredCommand>
|
|
{
|
|
FilteredCommand() = default;
|
|
FilteredCommand(Microsoft::Terminal::Settings::Model::Command const& command);
|
|
|
|
void UpdateFilter(winrt::hstring const& filter);
|
|
|
|
static int Compare(winrt::TerminalApp::FilteredCommand const& first, winrt::TerminalApp::FilteredCommand const& second);
|
|
|
|
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
|
OBSERVABLE_GETSET_PROPERTY(Microsoft::Terminal::Settings::Model::Command, Command, _PropertyChangedHandlers);
|
|
OBSERVABLE_GETSET_PROPERTY(winrt::hstring, Filter, _PropertyChangedHandlers);
|
|
OBSERVABLE_GETSET_PROPERTY(winrt::TerminalApp::HighlightedText, HighlightedName, _PropertyChangedHandlers);
|
|
OBSERVABLE_GETSET_PROPERTY(int, Weight, _PropertyChangedHandlers);
|
|
|
|
private:
|
|
winrt::TerminalApp::HighlightedText _computeHighlightedName();
|
|
int _computeWeight();
|
|
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _commandChangedRevoker;
|
|
|
|
friend class TerminalAppLocalTests::FilteredCommandTests;
|
|
};
|
|
}
|
|
|
|
namespace winrt::TerminalApp::factory_implementation
|
|
{
|
|
BASIC_FACTORY(FilteredCommand);
|
|
}
|