Skip to content

Commit

Permalink
lots of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Feb 21, 2024
1 parent 02a5593 commit 14a00c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 99 deletions.
24 changes: 8 additions & 16 deletions src/cascadia/TerminalApp/TasksPaneContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,24 @@ namespace winrt::TerminalApp::implementation
{
const auto& queryString = _filterBox().Text();

// You'd think that `FilterToSendInput(queryString)` would work. It
// doesn't! That uses the queryString as the current command the user
// has typed, then relies on the sxnui to _also_ filter with that
// string.

// In the fullness of time, we'll actually want to filter things here.
// Probably with something that re-uses the suggestions control list
//
// huh. now that's a thought.

// const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(L""); // IVector<Model::Command>
// auto itemSource = winrt::single_threaded_observable_vector<TerminalApp::FilteredTask>();
// DON'T replace the itemSource here. If you do, it'll un-expand all the
// nested items the user has expanded. Instead, just update the filter.
// That'll also trigger a PropertyChanged for the Visibility property.
for (const auto& t : _allTasks)
{
// const auto& filtered{ winrt::make<FilteredTask>(t) };
t.UpdateFilter(queryString);
// itemSource.Append(filtered);
}

// _treeView().ItemsSource(itemSource);
}

void TasksPaneContent::UpdateSettings(const CascadiaSettings& settings)
{
_settings = settings;

// You'd think that `FilterToSendInput(queryString)` would work. It
// doesn't! That uses the queryString as the current command the user
// has typed, then relies on the sxnui to _also_ filter with that
// string.

const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(L""); // IVector<Model::Command>
_allTasks = winrt::single_threaded_observable_vector<TerminalApp::FilteredTask>();
for (const auto& t : tasks)
Expand Down
55 changes: 7 additions & 48 deletions src/cascadia/TerminalApp/TasksPaneContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace winrt::TerminalApp::implementation
void Close();
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const bool asContent) const;

winrt::hstring Title() { return L"Scratchpad"; }
// TODO! lots of strings here and in XAML that need RS_-ifying
winrt::hstring Title() { return L"Tasks"; }
uint64_t TaskbarState() { return 0; }
uint64_t TaskbarProgress() { return 0; }
bool ReadOnly() { return false; }
Expand Down Expand Up @@ -58,42 +59,6 @@ namespace winrt::TerminalApp::implementation
void _updateFilteredCommands();
};

struct TaskViewModel : TaskViewModelT<TaskViewModel>
{
TaskViewModel(const winrt::Microsoft::Terminal::Settings::Model::Command& command) :
_command{ command }
{
// The Children() method must always return a non-null vector
_children = winrt::single_threaded_observable_vector<TerminalApp::TaskViewModel>();
if (_command.HasNestedCommands())
{
for (const auto& [_, child] : _command.NestedCommands())
{
auto vm{ winrt::make<TaskViewModel>(child) };
_children.Append(vm);
}
}
}

winrt::hstring Name() { return _command.Name(); }
winrt::hstring IconPath() { return _command.IconPath(); }
winrt::hstring Input()
{
if (const auto& sendInput{ _command.ActionAndArgs().Args().try_as<winrt::Microsoft::Terminal::Settings::Model::SendInputArgs>() })
{
return sendInput.Input();
}
return L"";
};
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::TaskViewModel> Children() { return _children; }
winrt::Microsoft::Terminal::Settings::Model::Command Command() { return _command; }

private:
winrt::Microsoft::Terminal::Settings::Model::Command _command{ nullptr };
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::TaskViewModel> _children{ nullptr };
};

// struct FilteredTask : public winrt::TerminalApp::implementation::FilteredCommand, FilteredTaskT<FilteredTask, FilteredCommand>
struct FilteredTask : FilteredTaskT<FilteredTask, TerminalApp::implementation::FilteredCommand>
{
FilteredTask() = default;
Expand All @@ -115,9 +80,6 @@ namespace winrt::TerminalApp::implementation
}
}

// FilteredCommand() = default;
// FilteredCommand(const winrt::TerminalApp::PaletteItem& item);

void UpdateFilter(const winrt::hstring& filter) override
{
TerminalApp::implementation::FilteredCommand::UpdateFilter(filter);
Expand All @@ -129,14 +91,6 @@ namespace winrt::TerminalApp::implementation
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Visibility" });
}

// static int Compare(const winrt::TerminalApp::FilteredCommand& first, const winrt::TerminalApp::FilteredCommand& second);

// WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
// WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::PaletteItem, Item, _PropertyChangedHandlers, nullptr);
// WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Filter, _PropertyChangedHandlers);
// WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::HighlightedText, HighlightedName, _PropertyChangedHandlers);
// WINRT_OBSERVABLE_PROPERTY(int, Weight, _PropertyChangedHandlers);

winrt::hstring Input()
{
if (const auto& actionItem{ _Item.try_as<winrt::TerminalApp::ActionPaletteItem>() })
Expand All @@ -155,12 +109,17 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::Foundation::Collections::IObservableVector<TerminalApp::FilteredTask> Children() { return _children; }
winrt::Microsoft::Terminal::Settings::Model::Command Command() { return _command; }

// Used to control if this item is visible in the TreeView. Turns out,
// TreeView is in fact sane enough to remove items entirely if they're
// Collapsed.
winrt::Windows::UI::Xaml::Visibility Visibility()
{
// Is there no filter, or do we match it?
if (_Filter.empty() || _Weight > 0)
{
return winrt::Windows::UI::Xaml::Visibility::Visible;
}
// If we don't match, maybe one of our children does
auto totalWeight = _Weight;
for (const auto& c : _children)
{
Expand Down
32 changes: 7 additions & 25 deletions src/cascadia/TerminalApp/TasksPaneContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
<ResourceDictionary>
<model:IconPathConverter x:Key="IconSourceConverter" />

<DataTemplate x:Key="ListItemTemplate"
x:DataType="local:FilteredCommand">
<ListViewItem Height="32"
MinHeight="0"
Padding="16,0,12,0"
HorizontalContentAlignment="Stretch"
AutomationProperties.AcceleratorKey="{x:Bind Item.KeyChordText, Mode=OneWay}"
AutomationProperties.Name="{x:Bind Item.Name, Mode=OneWay}"
FontSize="12" />
</DataTemplate>
<DataTemplate x:Key="TaskItemTemplate"
x:DataType="local:FilteredTask">
<mux:TreeViewItem x:Name="rootItem"
Expand All @@ -44,20 +34,14 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<ContentPresenter Grid.Column="0">
<IconSourceElement Width="16"
Height="16"
IconSource="{x:Bind Item.Icon, Converter={StaticResource IconSourceConverter}}"
Visibility="Collapsed" />
</ContentPresenter>
<!-- <Ellipse x:Name="Ellipse"
Grid.RowSpan="2"
Width ="32"
Height="32"
Margin="6"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Fill="{ThemeResource SystemControlBackgroundBaseMediumBrush}"/>-->

<Button Grid.Row="0"
Grid.RowSpan="1"
Grid.Column="0"
Expand All @@ -72,7 +56,11 @@
<FontIcon FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets"
FontSize="12"
Glyph="&#xE768;" />
<!-- xF5B0 is PlaySolid, also a good option. Seemed better to have a lightweight outline though -->
<!--
xE768 is Play, which is just an outline.
xF5B0 is PlaySolid, also a good option. Seemed
better to have a lightweight outline though
-->
</Button.Content>

<Button.Resources>
Expand Down Expand Up @@ -109,12 +97,6 @@
</Button.Resources>
</Button>

<!-- <TextBlock Grid.Column="1"
Margin="12,6,0,0"
Style="{ThemeResource BaseTextBlockStyle}"
Text="{x:Bind Item.Name, Mode=OneWay}"
TextWrapping="WrapWholeWords" />-->

<local:HighlightedTextControl Grid.Column="1"
HorizontalAlignment="Left"
Text="{x:Bind HighlightedName, Mode=OneWay}" />
Expand Down
10 changes: 0 additions & 10 deletions src/cascadia/TerminalApp/TerminalPaneContent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ namespace TerminalApp
SettingsPaneContent(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
}

[default_interface] runtimeclass TaskViewModel
{
TaskViewModel(Microsoft.Terminal.Settings.Model.Command command);
String Name{ get; };
String IconPath{ get; };
String Input{ get; };
Microsoft.Terminal.Settings.Model.Command Command{ get; };
Windows.Foundation.Collections.IObservableVector<TaskViewModel> Children { get; };

}
[default_interface] runtimeclass FilteredTask : TerminalApp.FilteredCommand
{
String Input{ get; };
Expand Down

1 comment on commit 14a00c8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (5)

actiopn
ifying
sxnui
taskpane
tbh

Previously acknowledged words that are now absent chcbpat DESTINATIONNAME inputrc kcub kcud kcuf kcuu khome Mbxy QUESTIONMARK reallocs reamapping RTFTo WScript xff 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/migrie/fhl/tasks-pane branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/8006355692/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2245) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (5)

Dictionary Entries Covers Uniquely
cspell:k8s/dict/k8s.txt 153 2 2
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:k8s/dict/k8s.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
Errors (1)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 3

See ❌ Event descriptions for more information.

✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.