Skip to content

Commit

Permalink
plugin icon
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Sep 26, 2021
1 parent 0204689 commit b326651
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Windows.Controls;
using System.Windows.Input;
using ManagedCommon;
using Microsoft.PowerToys.Run.Plugin.WindowsTerminal.Helpers;
using Microsoft.PowerToys.Run.Plugin.WindowsTerminal.Properties;
using Microsoft.PowerToys.Settings.UI.Library;
Expand All @@ -19,8 +20,9 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsTerminal
public class Main : IPlugin, IContextMenu, IPluginI18n, ISettingProvider
{
private const string OpenNewTab = nameof(OpenNewTab);
private static PluginInitContext _context;
private readonly ITerminalQuery _terminalQuery = new TerminalQuery();
private PluginInitContext _context;
private string _icoPath;
private bool _openNewTab;

public string Name => Resources.plugin_name;
Expand All @@ -40,6 +42,8 @@ public class Main : IPlugin, IContextMenu, IPluginI18n, ISettingProvider
public void Init(PluginInitContext context)
{
_context = context;
_context.API.ThemeChanged += OnThemeChanged;
UpdateIconPath(_context.API.GetCurrentTheme());
}

public List<Result> Query(Query query)
Expand All @@ -58,6 +62,7 @@ public List<Result> Query(Query query)
{
Title = profile.Name,
SubTitle = profile.Terminal.DisplayName,
IcoPath = _icoPath,
Action = _ =>
{
Launch(profile.Terminal.AppUserModelId, profile.Name);
Expand Down Expand Up @@ -165,5 +170,22 @@ public void UpdateSettings(PowerLauncherPluginSettings settings)

_openNewTab = openNewTab;
}

private void UpdateIconPath(Theme theme)
{
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
{
_icoPath = "Images/WindowsTerminal.light.png";
}
else
{
_icoPath = "Images/WindowsTerminal.dark.png";
}
}

private void OnThemeChanged(Theme currentTheme, Theme newTheme)
{
UpdateIconPath(newTheme);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
Expand All @@ -89,5 +88,16 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Images\" />
</ItemGroup>
<ItemGroup>
<None Update="Images\WindowsTerminal.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\WindowsTerminal.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"ID": "F59BA85006B14389A72A0EA756695F1D",
"Disabled": true,
"ActionKeyword": "_",
"IsGlobal": true,
"Name": "Windows Terminal",
Expand All @@ -8,6 +9,6 @@
"Language": "csharp",
"Website": "https://aka.ms/powertoys",
"ExecuteFileName": "Microsoft.PowerToys.Run.Plugin.WindowsTerminal.dll",
"IcoPathDark": "Images\\service.dark.png",
"IcoPathLight": "Images\\service.light.png"
"IcoPathDark": "Images\\WindowsTerminal.dark.png",
"IcoPathLight": "Images\\WindowsTerminal.light.png"
}

1 comment on commit b326651

@github-actions
Copy link

@github-actions github-actions bot commented on b326651 Sep 26, 2021

Choose a reason for hiding this comment

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

@check-spelling-bot Report

Unrecognized words, please review:

  • ITerminal
Previously acknowledged words that are now absent Accessible available chrisharris CIEXYZ coc CTriage djsoref docsmsft dogancelik dupenv estdir Fody ftps gmx htt inprivate installpowertoys itsme listbox mfreadwrite mfuuid Nefario nitroin null nunit powertoyswiki PROGRAMFILES Radiobuttons sidepanel spamming systray ulazy windevbuildagents winstore xia XSmall xunit
Some files were were automatically ignored

These sample patterns would exclude them:

^src/modules/previewpane/UnitTests-MarkdownPreviewHandler/HelperFiles/MarkdownWithHTMLImageTag\.txt$

You should consider adding them to:

.github/actions/spell-check/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the git@github.com:microsoft/PowerToys.git repository
on the users/davidegiacometti/terminal-plugin branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
(cat '.github/actions/spell-check/excludes.txt' - <<EOF
$should_exclude_patterns
EOF
) |grep .|
sort -f |
uniq > '.github/actions/spell-check/excludes.txt.temp' &&
mv '.github/actions/spell-check/excludes.txt.temp' '.github/actions/spell-check/excludes.txt'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/PowerToys/comments/57070182" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  

should_exclude_patterns=$(perl -e '$/=undef;
$_=<>;
exit unless s{(?:You should consider excluding directory paths|You should consider adding them to).*}{}s;
s{.*These sample patterns would exclude them:}{}s;
s{.*\`\`\`([^`]*)\`\`\`.*}{$1}m;
print' < "$comment_body" | grep . || true)

update_files
rm $comment_body
git add -u
If you see a bunch of garbage

If it relates to a ...

well-formed pattern

See if there's a pattern that would match it.

If not, try writing one and 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.

binary-ish string

Please add a file path to the excludes.txt file instead of just accepting the garbage.

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).

Please sign in to comment.