Skip to content

Commit

Permalink
Merge pull request #20 from hlaueriksson/Fyra
Browse files Browse the repository at this point in the history
Fyra
  • Loading branch information
hlaueriksson authored Dec 26, 2022
2 parents c7ddef7 + 5bd311b commit ed43c13
Show file tree
Hide file tree
Showing 24 changed files with 481 additions and 351 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v3
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: |
6.0.x
7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion Analyzers.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/GEmojiSharp.Blazor/GEmojiSharp.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.12" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/GEmojiSharp.DotnetTool/GEmojiSharp.DotnetTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="TextCopy" Version="6.1.0" />
<PackageReference Include="Tomlyn" Version="0.14.1" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="TextCopy" Version="6.2.1" />
<PackageReference Include="Tomlyn" Version="0.16.2" />
<PackageReference Include="YamlDotNet" Version="12.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 16 additions & 2 deletions src/GEmojiSharp.DotnetTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,40 @@
var copyOption = new Option<bool>(new[] { "-c", "--copy" }, "Copy to clipboard");

// raw
var skinTonesOption = new Option<bool>(new[] { "-st", "--skin-tones" }, "Include skin tone variants");

var rawCommand = new Command("raw", "Get raw emojis")
{
argument,
skinTonesOption,
copyOption,
};

rawCommand.AddAlias("r");

rawCommand.SetHandler(
(string[] args, bool copy) =>
(string[] args, bool skinTones, bool copy) =>
{
var value = string.Join(" ", args);
var emojis = Emoji.Find(value);

foreach (var e in emojis)
{
Console.WriteLine(e.Raw);
if (skinTones && e.HasSkinTones)
{
foreach (var tone in e.RawSkinToneVariants())
{
Console.WriteLine(tone);
}
}
}

if (copy)
ClipboardService.SetText(string.Join(string.Empty, emojis.Select(x => x.Raw)));
ClipboardService.SetText(string.Join(string.Empty, emojis.Select(e => skinTones && e.HasSkinTones ? e.Raw + string.Join(string.Empty, e.RawSkinToneVariants()) : e.Raw)));
},
argument,
skinTonesOption,
copyOption);

// alias
Expand Down
8 changes: 6 additions & 2 deletions src/GEmojiSharp.PowerToysRun/GEmojiSharp.PowerToysRun.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
Expand Down Expand Up @@ -50,7 +50,11 @@
<PackageReference Include="ilmerge" Version="3.0.41" />
</ItemGroup>
<Target Name="ILMerge">
<Exec Command="$(ILMergeConsolePath) /out:bin\Release\net6.0-windows\GEmojiSharp.PowerToysRun.dll bin\Release\net6.0-windows\GEmojiSharp.PowerToysRun.dll bin\Release\net6.0-windows\GEmojiSharp.dll /lib:&quot;C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.3\ref\net6.0&quot;" />
<Exec Command="$(ILMergeConsolePath) ^
/out:bin\Release\net7.0-windows\GEmojiSharp.PowerToysRun.dll ^
bin\Release\net7.0-windows\GEmojiSharp.PowerToysRun.dll ^
bin\Release\net7.0-windows\GEmojiSharp.dll ^
/lib:&quot;C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\7.0.1\ref\net7.0&quot;" />
</Target>

</Project>
68 changes: 45 additions & 23 deletions src/GEmojiSharp.PowerToysRun/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public List<Result> Query(Query query)
return Emoji.All.Select(GetResult).ToList();
}

var emojis = Emoji.Find(value);
var emojis = (GEmoji[])Emoji.Find(value);

if (emojis.Any())
{
Expand Down Expand Up @@ -97,7 +97,7 @@ public List<Result> Query(Query query)
IcoPath = IconPath,
Title = emoji.Raw,
SubTitle = string.Join(" ", emoji.Aliases.Select(x => x.PadAlias())),
ToolTipData = new ToolTipData("GEmoji", $"Description: {emoji.Description}\nCategory: {emoji.Category}\nTags: {string.Join(", ", emoji.Tags ?? Enumerable.Empty<string>())}\n"),
ToolTipData = new ToolTipData("GEmoji", $"Description: {emoji.Description}\nCategory: {emoji.Category}\nTags: {string.Join(", ", emoji.Tags ?? Enumerable.Empty<string>())}\nUnicodeVersion: {emoji.UnicodeVersion}\nHasSkinTones: {(emoji.HasSkinTones ? "Yes" : "No")}"),
Action = _ => CopyToClipboard(emoji.Raw),
ContextData = emoji,
};
Expand Down Expand Up @@ -133,27 +133,49 @@ public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
{
if (selectedResult?.ContextData is GEmoji emoji)
{
return new List<ContextMenuResult>
var raw = new ContextMenuResult
{
new ContextMenuResult
{
PluginName = Name,
Title = "Copy raw emoji (Enter)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xE8C8", // E8C8 => Symbol: Copy
AcceleratorKey = Key.Enter,
Action = _ => CopyToClipboard(emoji.Raw),
},
new ContextMenuResult
PluginName = Name,
Title = "Copy raw emoji (Enter)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xE8C8", // E8C8 => Symbol: Copy
/*AcceleratorKey = Key.Enter,*/
Action = _ => CopyToClipboard(emoji.Raw),
};
var alias = new ContextMenuResult
{
PluginName = Name,
Title = "Copy emoji aliases (Ctrl+C)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xF413", // F413 => Symbol: CopyTo
AcceleratorKey = Key.C,
AcceleratorModifiers = ModifierKeys.Control,
Action = _ => CopyToClipboard(string.Join(string.Empty, emoji.Aliases.Select(x => x.PadAlias()))),
};

if (emoji.HasSkinTones)
{
return new List<ContextMenuResult>
{
PluginName = Name,
Title = "Copy emoji aliases (Ctrl+C)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xF413", // F413 => Symbol: CopyTo
AcceleratorKey = Key.C,
AcceleratorModifiers = ModifierKeys.Control,
Action = _ => CopyToClipboard(string.Join(string.Empty, emoji.Aliases.Select(x => x.PadAlias()))),
},
raw,
alias,
new ContextMenuResult
{
PluginName = Name,
Title = "Copy raw emoji skin tone variants (Ctrl+Enter)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xE748", // E748 => Symbol: SwitchUser
AcceleratorKey = Key.Enter,
AcceleratorModifiers = ModifierKeys.Control,
Action = _ => CopyToClipboard(emoji.Raw + string.Join(string.Empty, emoji.RawSkinToneVariants())),
},
};
}

return new List<ContextMenuResult>
{
raw,
alias,
};
}

Expand All @@ -167,7 +189,7 @@ public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
Title = "Copy emojified text (Enter)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xE8C8", // E8C8 => Symbol: Copy
AcceleratorKey = Key.Enter,
/*AcceleratorKey = Key.Enter,*/
Action = _ => CopyToClipboard(emojified.Value),
},
};
Expand All @@ -183,7 +205,7 @@ public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
Title = "Copy demojified text (Enter)",
FontFamily = "Segoe MDL2 Assets",
Glyph = "\xE8C8", // E8C8 => Symbol: Copy
AcceleratorKey = Key.Enter,
/*AcceleratorKey = Key.Enter,*/
Action = _ => CopyToClipboard(demojified.Value),
},
};
Expand Down
7 changes: 7 additions & 0 deletions src/GEmojiSharp.PowerToysRun/deploy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
call pack.bat

taskkill /f /im PowerToys.exe /t

xcopy /s /y .\bin\Release\GEmojiSharp\ "C:\Program Files\PowerToys\modules\launcher\Plugins\GEmojiSharp\"

start "" "C:\Program Files\PowerToys\PowerToys.exe"
Binary file modified src/GEmojiSharp.PowerToysRun/libs/PowerToys.Common.UI.dll
Binary file not shown.
Binary file modified src/GEmojiSharp.PowerToysRun/libs/PowerToys.ManagedCommon.dll
Binary file not shown.
Binary file modified src/GEmojiSharp.PowerToysRun/libs/Wox.Plugin.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/GEmojiSharp/Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static GEmoji Get(string value)
{
if (value is null) throw new ArgumentNullException(nameof(value));

var key = value.TrimAlias();
var key = value.TrimAlias().TrimSkinToneVariants();

return
AliasToGEmoji.ContainsKey(key) ? AliasToGEmoji[key] :
Expand Down
Loading

0 comments on commit ed43c13

Please sign in to comment.