mirror of
https://github.com/lin-ycv/EverythingPowerToys.git
synced 2025-01-08 11:57:59 +08:00
parent
3d743f1f06
commit
6097e4b436
3
.github/workflows/packageManagers.yml
vendored
3
.github/workflows/packageManagers.yml
vendored
@ -9,7 +9,6 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
if: "!github.event.release.prerelease"
|
||||
permissions: write-all
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
@ -50,7 +49,7 @@ jobs:
|
||||
cd .\EverythingPowerToys
|
||||
rm .git -Recurse -Force -Confirm:$false
|
||||
Get-ChildItem *.* -Recurse | ForEach { (Get-Content $_) | ForEach {$_ -Replace '_VERSION_', $ver} | ForEach {$_ -Replace '_URL_', $exe} | ForEach {$_ -Replace '_CRC_', $exehash} | Set-Content $_ }
|
||||
..\wingetcreate submit -p "New version: lin-ycv.EverythingPowerToys version $ver" -t ${{ secrets.GITHUB_TOKEN }} .
|
||||
..\wingetcreate submit -p "New version: lin-ycv.EverythingPowerToys version $ver" -t ${{ secrets.EVERYTHINGPT }} .
|
||||
|
||||
# scoop # takes too long to get approvaed, impractical to implement
|
||||
# cd ..
|
||||
|
14
Debugger.cs
Normal file
14
Debugger.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
internal static class Debugger
|
||||
{
|
||||
private static readonly string FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "EverythingPT.log");
|
||||
public static void Write(string message)
|
||||
{
|
||||
using StreamWriter writer = new(FilePath, true);
|
||||
writer.WriteLine(message);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
internal Everything(Settings setting)
|
||||
{
|
||||
Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME);
|
||||
UpdateSettings(setting);
|
||||
Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME);
|
||||
UpdateSettings(setting);
|
||||
}
|
||||
|
||||
internal void UpdateSettings(Settings setting)
|
||||
@ -27,15 +27,29 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
|
||||
internal IEnumerable<Result> Query(string query, Settings setting)
|
||||
{
|
||||
if (setting.Log > LogLevel.None)
|
||||
{
|
||||
Debugger.Write($"\r\n\r\nNew Query: {query}\r\n" +
|
||||
$"Sort {(int)setting.Sort}_{Everything_GetSort()} | " +
|
||||
$"Max {setting.Max}_{Everything_GetMax()} | " +
|
||||
$"Match Path {setting.MatchPath}_{Everything_GetMatchPath()} | " +
|
||||
$"Regex {setting.RegEx}_{Everything_GetRegex()}");
|
||||
}
|
||||
|
||||
string orgqry = query;
|
||||
if (orgqry.Contains('\"') && !setting.MatchPath)
|
||||
{
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write("MatchPath");
|
||||
|
||||
Everything_SetMatchPath(true);
|
||||
}
|
||||
|
||||
if (setting.EnvVar && orgqry.Contains('%'))
|
||||
{
|
||||
query = Environment.ExpandEnvironmentVariables(query).Replace(';', '|');
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write($"EnvVariable\r\n{query}");
|
||||
}
|
||||
|
||||
if (orgqry.Contains(':'))
|
||||
@ -45,6 +59,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
if (query.Contains(kv.Key, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
query = query.Replace(kv.Key, kv.Value);
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write($"Contains Filter: {kv.Key}\r\n{query}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,6 +68,9 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
Everything_SetSearchW(query);
|
||||
if (!Everything_QueryW(true))
|
||||
{
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write("\r\nUnable to Query\r\n");
|
||||
|
||||
throw new Win32Exception("Unable to Query");
|
||||
}
|
||||
|
||||
@ -61,16 +80,27 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
}
|
||||
|
||||
uint resultCount = Everything_GetNumResults();
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write($"Results: {resultCount}");
|
||||
|
||||
for (uint i = 0; i < resultCount; i++)
|
||||
{
|
||||
char[] buffer = new char[260];
|
||||
uint length = Everything_GetResultFullPathName(i, buffer, (uint)buffer.Length);
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write($"\r\n===== RESULT #{i} =====");
|
||||
|
||||
char[] buffer = new char[32767];
|
||||
uint length = Everything_GetResultFullPathNameW(i, buffer, (uint)buffer.Length);
|
||||
|
||||
string fullPath = new(buffer, 0, (int)length);
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write($"{length} {(setting.Log == LogLevel.Verbose ? fullPath : string.Empty)}");
|
||||
string name = Path.GetFileName(fullPath);
|
||||
bool isFolder = Everything_IsFolderResult(i);
|
||||
|
||||
string path = isFolder ? fullPath : Path.GetDirectoryName(fullPath);
|
||||
string ext = Path.GetExtension(fullPath.Replace(".lnk", string.Empty));
|
||||
if (setting.Log > LogLevel.None)
|
||||
Debugger.Write($"Folder: {isFolder}\r\nFile Path {(setting.Log == LogLevel.Verbose ? path : path.Length)}\r\nFile Name {(setting.Log == LogLevel.Verbose ? name : name.Length)}\r\nExt: {ext}");
|
||||
|
||||
var r = new Result()
|
||||
{
|
||||
@ -96,7 +126,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
try
|
||||
{
|
||||
process.Start();
|
||||
_ = Everything_IncRunCountFromFileName(fullPath);
|
||||
_ = Everything_IncRunCountFromFileNameW(fullPath);
|
||||
return true;
|
||||
}
|
||||
catch (Win32Exception)
|
||||
|
@ -108,10 +108,20 @@ namespace Community.PowerToys.Run.Plugin.Everything.Interop
|
||||
internal const string dllName = "Everything64.dll";
|
||||
[LibraryImport(dllName)]
|
||||
internal static partial uint Everything_GetNumResults();
|
||||
[LibraryImport(dllName, EntryPoint = "Everything_GetResultFullPathNameW", StringMarshalling = StringMarshalling.Utf16)]
|
||||
internal static partial uint Everything_GetResultFullPathName(uint nIndex, [Out] char[] lpString, uint nMaxCount);
|
||||
[LibraryImport(dllName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool Everything_GetMatchPath();
|
||||
[LibraryImport(dllName)]
|
||||
internal static partial uint Everything_GetMax();
|
||||
[LibraryImport(dllName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool Everything_GetRegex();
|
||||
[LibraryImport(dllName, StringMarshalling = StringMarshalling.Utf16)]
|
||||
internal static partial uint Everything_IncRunCountFromFileName(string lpFileName);
|
||||
internal static partial uint Everything_GetResultFullPathNameW(uint nIndex, [Out] char[] lpString, uint nMaxCount);
|
||||
[LibraryImport(dllName)]
|
||||
internal static partial uint Everything_GetSort();
|
||||
[LibraryImport(dllName, StringMarshalling = StringMarshalling.Utf16)]
|
||||
internal static partial uint Everything_IncRunCountFromFileNameW(string lpFileName);
|
||||
[LibraryImport(dllName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool Everything_IsFolderResult(uint index);
|
||||
|
27
Main.cs
27
Main.cs
@ -26,8 +26,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
private ContextMenuLoader _contextMenuLoader;
|
||||
private bool _disposed;
|
||||
|
||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions => new List<PluginAdditionalOption>()
|
||||
{
|
||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions =>
|
||||
[
|
||||
new()
|
||||
{
|
||||
Key = nameof(Settings.Context),
|
||||
@ -102,7 +102,15 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
DisplayDescription = $"v{Assembly.GetExecutingAssembly().GetName().Version}",
|
||||
Value = _setting.Updates,
|
||||
},
|
||||
};
|
||||
new()
|
||||
{
|
||||
Key = nameof(Settings.Log),
|
||||
DisplayLabel = "Debug Mode",
|
||||
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Combobox,
|
||||
ComboBoxItems = Enum.GetValues(typeof(LogLevel)).Cast<int>().Select(d => new KeyValuePair<string, string>(((LogLevel)d).ToString(), d + string.Empty)).ToList(),
|
||||
ComboBoxValue = (int)_setting.Log,
|
||||
},
|
||||
];
|
||||
|
||||
private void CheckArm()
|
||||
{
|
||||
@ -111,6 +119,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
if (File.Exists(arm))
|
||||
{
|
||||
Architecture arch = RuntimeInformation.ProcessArchitecture;
|
||||
if (_setting.Log > LogLevel.None)
|
||||
Debugger.Write("0.Checking ARM..." + (_setting.Log == LogLevel.Verbose ? $"\r\n\tArchitecture: {arch}" : string.Empty));
|
||||
if (arch == Architecture.Arm64)
|
||||
{
|
||||
File.Delete(Path.Combine(dir, "Everything64.dll"));
|
||||
@ -121,6 +131,9 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
File.Delete(arm);
|
||||
}
|
||||
}
|
||||
|
||||
if (_setting.Log > LogLevel.None)
|
||||
Debugger.Write(" Checking ARM...Done");
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
@ -132,6 +145,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
_everything = new Everything(_setting);
|
||||
_contextMenuLoader = new ContextMenuLoader(context, _setting.Context);
|
||||
_contextMenuLoader.Update(_setting);
|
||||
if (_setting.Log > LogLevel.None)
|
||||
Debugger.Write("Init Complete\r\n");
|
||||
}
|
||||
|
||||
public void UpdateSettings(PowerLauncherPluginSettings settings)
|
||||
@ -148,6 +163,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
_setting.QueryText = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.QueryText)).Value;
|
||||
_setting.EnvVar = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.EnvVar)).Value;
|
||||
_setting.Updates = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Updates)).Value;
|
||||
_setting.Log = (LogLevel)settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Log)).ComboBoxValue;
|
||||
|
||||
_everything?.UpdateSettings(_setting);
|
||||
_contextMenuLoader?.Update(_setting);
|
||||
@ -165,7 +181,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
List<Result> results = [];
|
||||
if (!string.IsNullOrEmpty(query.Search))
|
||||
{
|
||||
var searchQuery = query.Search;
|
||||
string searchQuery = query.Search;
|
||||
|
||||
try
|
||||
{
|
||||
@ -183,6 +199,9 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_setting.Log > LogLevel.None)
|
||||
Debugger.Write($"Everything Exception: {e.Message}\r\n{e.StackTrace}\r\n");
|
||||
|
||||
Log.Exception("Everything Exception", e, GetType());
|
||||
}
|
||||
}
|
||||
|
2
Properties/Resources.Designer.cs
generated
2
Properties/Resources.Designer.cs
generated
@ -288,7 +288,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enable regular expression in search.
|
||||
///Recommend using r: in query instead of enabling this option.
|
||||
///Recommend using regex: in query instead of enabling this option.
|
||||
/// </summary>
|
||||
public static string RegEx_Description {
|
||||
get {
|
||||
|
@ -195,7 +195,7 @@
|
||||
</data>
|
||||
<data name="RegEx_Description" xml:space="preserve">
|
||||
<value>Enable regular expression in search.
|
||||
Recommend using r: in query instead of enabling this option</value>
|
||||
Recommend using regex: in query instead of enabling this option</value>
|
||||
</data>
|
||||
<data name="run_as_admin" xml:space="preserve">
|
||||
<value>Run as administrator (Ctrl+Shift+Enter)</value>
|
||||
|
@ -168,7 +168,7 @@
|
||||
</data>
|
||||
<data name="RegEx_Description" xml:space="preserve">
|
||||
<value>RegEx 正規表示式搜尋
|
||||
不建議啟用,建議在收尋詞裡使用 r:</value>
|
||||
不建議啟用,建議在收尋詞裡使用 regex:</value>
|
||||
</data>
|
||||
<data name="run_as_admin" xml:space="preserve">
|
||||
<value>以系統管理員身分執行 (Ctrl+Shift+Enter)</value>
|
||||
|
23
Settings.cs
23
Settings.cs
@ -20,14 +20,23 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
public bool EnvVar { get; set; }
|
||||
public bool Updates { get; set; } = true;
|
||||
public string Skip { get; set; }
|
||||
public LogLevel Log { get; set; } = LogLevel.None;
|
||||
|
||||
// Get Filters from settings.toml
|
||||
public Dictionary<string, string> Filters { get; } = [];
|
||||
internal void Getfilters()
|
||||
{
|
||||
if (Log > LogLevel.None)
|
||||
Debugger.Write("2.Getting Filters...");
|
||||
string[] strArr;
|
||||
try { strArr = File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "settings.toml")); }
|
||||
catch { return; }
|
||||
catch (Exception e)
|
||||
{
|
||||
if (Log > LogLevel.None)
|
||||
Debugger.Write($"\r\nERROR: {e.Message}\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string str in strArr)
|
||||
{
|
||||
if (str.Length == 0 || str[0] == '#') continue;
|
||||
@ -35,8 +44,18 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
if (kv.Length != 2) continue;
|
||||
|
||||
if (kv[0].Contains(':'))
|
||||
Filters.TryAdd(kv[0].ToLowerInvariant(), kv[1]);
|
||||
Filters.TryAdd(kv[0].ToLowerInvariant(), kv[1] + (kv[1].EndsWith(';') ? ' ' : string.Empty));
|
||||
}
|
||||
|
||||
if (Log > LogLevel.None)
|
||||
Debugger.Write(Log > LogLevel.Debug ? string.Join(Environment.NewLine, Filters) + "\r\n" : string.Empty + " GettingFilters...Done");
|
||||
}
|
||||
}
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
None,
|
||||
Debug,
|
||||
Verbose,
|
||||
}
|
||||
}
|
||||
|
14
Update.cs
14
Update.cs
@ -17,12 +17,18 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
internal async Task UpdateAsync(Version v, Settings s)
|
||||
{
|
||||
string apiUrl = "https://api.github.com/repos/lin-ycv/EverythingPowerToys/releases/latest";
|
||||
if (s.Log > LogLevel.None)
|
||||
Debugger.Write("1.Checking Update...");
|
||||
|
||||
try
|
||||
{
|
||||
using HttpClient httpClient = new();
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0");
|
||||
|
||||
HttpResponseMessage response = await httpClient.GetAsync(apiUrl);
|
||||
|
||||
if (s.Log == LogLevel.Verbose) Debugger.Write($"\tResponse: {response.StatusCode}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
using JsonDocument jsonDocument = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync());
|
||||
@ -69,7 +75,13 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception e)
|
||||
{
|
||||
if (s.Log > LogLevel.None)
|
||||
Debugger.Write($"\r\nERROR: {e.Message}\r\n{e.StackTrace}\r\n");
|
||||
}
|
||||
|
||||
Debugger.Write(" Checking Update...Done");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
"IsGlobal": true,
|
||||
"Name": "Everything",
|
||||
"Author": "Yu Chieh (Victor) Lin",
|
||||
"Version": "0.81.0",
|
||||
"Version": "0.81.0.1",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Lin-ycv/EverythingPowerToys",
|
||||
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
|
||||
|
@ -1,12 +1,11 @@
|
||||
# Lines starting with # are comments
|
||||
# Search filters, filters result with extension type, seperated by ;
|
||||
Audio: = ext:aac;ac3;aif;aifc;aiff;amr;ape;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;m4b;m4p;mid;midi;mka;mod;mp2;mp3;mpa;ogg;opus;ra;rmi;spc;rmi;snd;umx;voc;wav;weba;wma;xm
|
||||
Zip: = ext:7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip
|
||||
Doc: = ext:c;cc;chm;cpp;cs;css;csv;cxx;doc;docm;docx;dot;dotm;dotx;epub;gh;h;hpp;htm;html;hxx;ini;java;js;json;lua;mht;mhtml;mobi;odp;ods;odt;pdf;php;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;pub;py;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml;vb
|
||||
Exe: = ext:bat;cmd;exe;msi;msp;msu;ps1;scr
|
||||
Pic: = ext:ani;apng;bmp;bpg;cur;gif;ico;jfi;jfif;jif;jpe;jpeg;jpg;pcx;png;psb;psd;rle;svg;tga;tif;tiff;webp;wmf
|
||||
Video: = ext:3g2;3gp;3gp2;3gpp;amv;asf;asx;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv
|
||||
r: = regex:
|
||||
Audio: = ext:aac;ac3;aif;aifc;aiff;amr;ape;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;m4b;m4p;mid;midi;mka;mod;mp2;mp3;mpa;ogg;opus;ra;rmi;spc;rmi;snd;umx;voc;wav;weba;wma;xm;
|
||||
Zip: = ext:7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip;
|
||||
Doc: = ext:c;cc;chm;cpp;cs;css;csv;cxx;doc;docm;docx;dot;dotm;dotx;epub;gh;h;hpp;htm;html;hxx;ini;java;js;json;lua;mht;mhtml;mobi;odp;ods;odt;pdf;php;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;pub;py;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml;vb;
|
||||
Exe: = ext:bat;cmd;exe;msi;msp;msu;ps1;scr;
|
||||
Pic: = ext:ani;apng;bmp;bpg;cur;gif;ico;jfi;jfif;jif;jpe;jpeg;jpg;pcx;png;psb;psd;rle;svg;tga;tif;tiff;webp;wmf;
|
||||
Video: = ext:3g2;3gp;3gp2;3gpp;amv;asf;asx;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv;
|
||||
|
||||
# Search filters, filters result with custom path(s), seperated by |
|
||||
# Demo: = C:\Windows\|C:\ProgramData
|
Loading…
Reference in New Issue
Block a user