From 8f1e839b123eb425cafce4e98ba2c618b2808702 Mon Sep 17 00:00:00 2001 From: "Lin Yu-Chieh (Victor)" Date: Sun, 13 Oct 2024 01:04:46 +0800 Subject: [PATCH] Resolves #130 #132 Updated to match 0.85.1 Fixed translations, removed redundant Remove debug feature from release --- ...ity.PowerToys.Run.Plugin.Everything.csproj | 257 +++++++++--------- ContextMenuLoader.cs | 37 +++ Debugger.cs | 4 +- Everything.cs | 23 +- Main.cs | 30 +- Properties/Resources.Designer.cs | 49 +++- Properties/Resources.de-de.resx | 8 +- Properties/Resources.es-es.resx | 12 - Properties/Resources.fr-fr.resx | 12 - Properties/Resources.pl-pl.resx | 14 +- Properties/Resources.resx | 19 +- Properties/Resources.zh-cn.resx | 17 +- Properties/Resources.zh-tw.resx | 28 +- Settings.cs | 20 +- Update.cs | 14 +- bin/.gitinclude | 1 - plugin.json | 2 +- 17 files changed, 334 insertions(+), 213 deletions(-) delete mode 100644 bin/.gitinclude diff --git a/Community.PowerToys.Run.Plugin.Everything.csproj b/Community.PowerToys.Run.Plugin.Everything.csproj index 53b9e1b..8aedf27 100644 --- a/Community.PowerToys.Run.Plugin.Everything.csproj +++ b/Community.PowerToys.Run.Plugin.Everything.csproj @@ -1,142 +1,145 @@  - + + - - net8.0-windows - 12 - {64467D32-4786-4ADD-9B77-FBF3C965D3D1} - Properties - Community.PowerToys.Run.Plugin.Everything - Community.PowerToys.Run.Plugin.Everything - $([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)plugin.json').Split(',')[5].Split(':')[1].Trim().Trim('"')) - false - false - true - lin-ycv - Copyright (C) lin-ycv - True - true - + + 12 + {64467D32-4786-4ADD-9B77-FBF3C965D3D1} + Properties + Community.PowerToys.Run.Plugin.Everything + Community.PowerToys.Run.Plugin.Everything + $([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)plugin.json').Split(',')[5].Split(':')[1].Trim().Trim('"')) - - true - bin\$(Platform)\$(Configuration)\Everything\ - DEBUG;TRACE - full - false - + true + false + false + true + lin-ycv + Copyright (C) lin-ycv + True + - - TRACE - bin\$(Platform)\$(Configuration)\Everything\ - true - none - + + true + bin\$(Platform)\$(Configuration)\Everything\ + DEBUG;TRACE + full + false + - - $(DefineConstants);X64 - + + TRACE + bin\$(Platform)\$(Configuration)\Everything\ + true + none + - - $(DefineConstants);ARM64 - + + $(DefineConstants);X64 + - - - + + $(DefineConstants);ARM64 + - - - PreserveNewest - - + + + - - - False - - - False - - - + + + false + + + false + + + false + + - - - True - True - Resources.resx - - + + + PreserveNewest + + - - - - - - - - - PublicResXFileCodeGenerator - Resources.Designer.cs - - - - + + + True + True + Resources.resx + + - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - True - \ - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - True - \ - - - PreserveNewest - - + + + + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + - - - + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + True + \ + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + True + \ + + + PreserveNewest + + + + + + diff --git a/ContextMenuLoader.cs b/ContextMenuLoader.cs index 1a45ac8..d820cd7 100644 --- a/ContextMenuLoader.cs +++ b/ContextMenuLoader.cs @@ -1,7 +1,11 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; using System.IO; using System.Reflection; +using System.Security.AccessControl; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; @@ -21,10 +25,14 @@ namespace Community.PowerToys.Run.Plugin.Everything private bool _swapCopy; private string _options = options; + private string _customProgram; + private string _customArg; internal void Update(Settings s) { _swapCopy = s.Copy; _options = s.Context; + _customProgram = s.CustomProgram; + _customArg = s.CustomArg; } public List LoadContextMenus(Result selectedResult) @@ -214,6 +222,35 @@ namespace Community.PowerToys.Run.Plugin.Everything }, }); break; + case '6': + // Pass to custom program as parameter + contextMenus.Add(new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = Resources.open_in_custom, + Glyph = "\xE8A7", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.N, + AcceleratorModifiers = ModifierKeys.Control, + + Action = (context) => + { + using var process = new Process(); + process.StartInfo.FileName = _customProgram; + process.StartInfo.Arguments = $"\"{_customArg.Replace("$P", record.Path)}\""; + try + { + process.Start(); + return true; + } + catch (Exception e) + { + Log.Exception($"Failed to execute {_customProgram} with arguments {_customArg}", e, GetType()); + return false; + } + }, + }); + break; default: break; } diff --git a/Debugger.cs b/Debugger.cs index 6bd8f9b..3f53c54 100644 --- a/Debugger.cs +++ b/Debugger.cs @@ -1,4 +1,5 @@ -using System; +#if DEBUG +using System; using System.IO; namespace Community.PowerToys.Run.Plugin.Everything { @@ -12,3 +13,4 @@ namespace Community.PowerToys.Run.Plugin.Everything } } } +#endif diff --git a/Everything.cs b/Everything.cs index 7c3c7ea..8373d86 100644 --- a/Everything.cs +++ b/Everything.cs @@ -33,12 +33,13 @@ namespace Community.PowerToys.Run.Plugin.Everything else if (string.IsNullOrEmpty(exe)) { exe = Path.Exists("C:\\Program Files\\Everything 1.5a\\Everything64.exe") ? "C:\\Program Files\\Everything 1.5a\\Everything64.exe" : - (Path.Exists("C:\\Program Files\\Everything\\Everything64.exe") ? "C:\\Program Files\\Everything\\Everything64.exe" : string.Empty); + (Path.Exists("C:\\Program Files\\Everything\\Everything.exe") ? "C:\\Program Files\\Everything\\Everything.exe" : string.Empty); } } internal IEnumerable Query(string query, Settings setting) { +#if DEBUG if (setting.Log > LogLevel.None) { Debugger.Write($"\r\n\r\nNew Query: {query}\r\n" + @@ -48,6 +49,7 @@ namespace Community.PowerToys.Run.Plugin.Everything $"Match Path {setting.MatchPath}_{Everything_GetMatchPath()} | " + $"Regex {setting.RegEx}_{Everything_GetRegex()}"); } +#endif if (!string.IsNullOrEmpty(setting.Prefix)) query = setting.Prefix + query; @@ -57,8 +59,10 @@ namespace Community.PowerToys.Run.Plugin.Everything if (setting.EnvVar && orgqry.Contains('%')) { query = Environment.ExpandEnvironmentVariables(query).Replace(';', '|'); +#if DEBUG if (setting.Log > LogLevel.None) Debugger.Write($"EnvVariable\r\n{query}"); +#endif } if (orgqry.Contains(':')) @@ -68,8 +72,10 @@ namespace Community.PowerToys.Run.Plugin.Everything if (query.Contains(kv.Key, StringComparison.OrdinalIgnoreCase)) { query = query.Replace(kv.Key, kv.Value); +#if DEBUG if (setting.Log > LogLevel.None) Debugger.Write($"Contains Filter: {kv.Key}\r\n{query}"); +#endif } } } @@ -77,15 +83,18 @@ namespace Community.PowerToys.Run.Plugin.Everything Everything_SetSearchW(query); if (!Everything_QueryW(true)) { +#if DEBUG if (setting.Log > LogLevel.None) Debugger.Write("\r\nUnable to Query\r\n"); - +#endif throw new Win32Exception("Unable to Query"); } uint resultCount = Everything_GetNumResults(); +#if DEBUG if (setting.Log > LogLevel.None) Debugger.Write($"Results: {resultCount}"); +#endif bool showMore = setting.ShowMore && !string.IsNullOrEmpty(exe) && resultCount == setting.Max; if (showMore) @@ -119,23 +128,25 @@ namespace Community.PowerToys.Run.Plugin.Everything for (uint i = 0; i < resultCount; i++) { +#if DEBUG if (setting.Log > LogLevel.None) Debugger.Write($"\r\n===== RESULT #{i} ====="); - +#endif string name = Marshal.PtrToStringUni(Everything_GetResultFileNameW(i)); string path = Marshal.PtrToStringUni(Everything_GetResultPathW(i)); string fullPath = Path.Combine(path, name); - +#if DEBUG if (setting.Log > LogLevel.None) Debugger.Write($"{fullPath.Length} {(setting.Log == LogLevel.Verbose ? fullPath : string.Empty)}"); - +#endif bool isFolder = Everything_IsFolderResult(i); if (isFolder) path = fullPath; string ext = Path.GetExtension(fullPath.Replace(".lnk", string.Empty)); +#if DEBUG 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}"); - +#endif var r = new Result() { Title = name, diff --git a/Main.cs b/Main.cs index b10c879..2d2b340 100644 --- a/Main.cs +++ b/Main.cs @@ -66,6 +66,22 @@ namespace Community.PowerToys.Run.Plugin.Everything TextValue = _setting.EverythingPath, }, new() + { + Key = nameof(Settings.CustomProgram), + DisplayLabel = Resources.CustomProgram, + DisplayDescription = Resources.CustomProgram_Description, + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Textbox, + TextValue = _setting.CustomProgram, + }, + new() + { + Key = nameof(Settings.CustomArg), + DisplayLabel = Resources.CustomArg, + DisplayDescription = Resources.CustomArg_Description, + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Textbox, + TextValue = _setting.CustomArg, + }, + new() { Key = nameof(Settings.Copy), DisplayLabel = Resources.SwapCopy, @@ -121,6 +137,7 @@ namespace Community.PowerToys.Run.Plugin.Everything DisplayDescription = $"v{Assembly.GetExecutingAssembly().GetName().Version}", Value = _setting.Updates, }, +#if DEBUG new() { Key = nameof(Settings.Log), @@ -129,6 +146,7 @@ namespace Community.PowerToys.Run.Plugin.Everything ComboBoxItems = Enum.GetValues(typeof(LogLevel)).Cast().Select(d => new KeyValuePair(((LogLevel)d).ToString(), d + string.Empty)).ToList(), ComboBoxValue = (int)_setting.Log, }, +#endif ]; public void Init(PluginInitContext context) @@ -139,8 +157,10 @@ namespace Community.PowerToys.Run.Plugin.Everything _everything = new Everything(_setting); _contextMenuLoader = new ContextMenuLoader(context, _setting.Context); _contextMenuLoader.Update(_setting); +#if DEBUG if (_setting.Log > LogLevel.None) Debugger.Write("Init Complete\r\n"); +#endif } public void UpdateSettings(PowerLauncherPluginSettings settings) @@ -157,10 +177,14 @@ 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; _setting.Prefix = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Prefix)).TextValue; _setting.EverythingPath = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.EverythingPath)).TextValue; + _setting.CustomProgram = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.CustomProgram)).TextValue; + _setting.CustomArg = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.CustomArg)).TextValue; _setting.ShowMore = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.ShowMore)).Value; +#if DEBUG + _setting.Log = (LogLevel)settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Log)).ComboBoxValue; +#endif _everything?.UpdateSettings(_setting); _contextMenuLoader?.Update(_setting); @@ -196,10 +220,12 @@ namespace Community.PowerToys.Run.Plugin.Everything } catch (Exception e) { +#if DEBUG if (_setting.Log > LogLevel.None) Debugger.Write($"Everything Exception: {e.Message}\r\n{e.StackTrace}\r\n"); +#endif - Log.Exception("Everything Exception", e, GetType()); + Log.Exception("Everything Exception: {e.Message}\r\n{e.StackTrace}\r\n", e, GetType()); } } diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index b454860..30f0cd5 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -80,7 +80,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties { /// /// Looks up a localized string similar to Configure context menu options and order. - ///0_Open folder, 1_Run as Admin, 2_Run as User, 3_Copy, 4_Copy Path, 5_Open in Console. + ///0_Open folder, 1_Run as Admin, 2_Run as User, 3_Copy, 4_Copy Path, 5_Open in Console, 6_Open in custom program. /// public static string Context_Description { get { @@ -124,6 +124,42 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties { } } + /// + /// Looks up a localized string similar to Launch argument. + /// + public static string CustomArg { + get { + return ResourceManager.GetString("CustomArg", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Argument to pass to the program when launching. [$P=path of the selected result ]. + /// + public static string CustomArg_Description { + get { + return ResourceManager.GetString("CustomArg_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Custom Program. + /// + public static string CustomProgram { + get { + return ResourceManager.GetString("CustomProgram", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Path to a external program that'll open the selected result. + /// + public static string CustomProgram_Description { + get { + return ResourceManager.GetString("CustomProgram_Description", resourceCulture); + } + } + /// /// Looks up a localized string similar to Enviroment Variables. /// @@ -170,7 +206,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties { } /// - /// Looks up a localized string similar to Location of Everything64.exe if it's not installed in "Program Files". + /// Looks up a localized string similar to Location of Everything.exe if it's not installed in "Program Files". /// public static string EverythingPath_Description { get { @@ -259,6 +295,15 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties { } } + /// + /// Looks up a localized string similar to Open path in custom program (Ctrl+N). + /// + public static string open_in_custom { + get { + return ResourceManager.GetString("open_in_custom", resourceCulture); + } + } + /// /// Looks up a localized string similar to Get search results from Everything. /// diff --git a/Properties/Resources.de-de.resx b/Properties/Resources.de-de.resx index 4055f11..6674aae 100644 --- a/Properties/Resources.de-de.resx +++ b/Properties/Resources.de-de.resx @@ -156,9 +156,6 @@ Everything-Suchergebnisse anzeigen - - Everything - Vorschau @@ -171,9 +168,6 @@ Ausgewählte Ergebnisse können den Abfragetext aktualisieren. Hilft bei der Anzeige zusätzlicher Informationen, kann aber die Anzeigeergebnisse verändern. - - RegEx - Aktiviert reguläre Ausdrücke in der Suche. @@ -189,4 +183,4 @@ Strg+C zum Kopieren von Dateien/Ordnern, Strg+Alt+C zum Kopieren des Pfades. - + \ No newline at end of file diff --git a/Properties/Resources.es-es.resx b/Properties/Resources.es-es.resx index b739cd6..81f02dd 100644 --- a/Properties/Resources.es-es.resx +++ b/Properties/Resources.es-es.resx @@ -133,12 +133,6 @@ Copiar ruta - - (Ctrl+C) - - - (Ctrl+Alt+C) - Variables de entorno @@ -175,9 +169,6 @@ Obtener resultados de búsqueda desde Everything - - Everything - Vista previa @@ -190,9 +181,6 @@ El resultado seleccionado puede actualizar el texto de búsqueda. Ayuda a mostrar información adicional, pero podría cambiar los resultados mostrados. - - RegEx - Permitir expresiones regulares en las búsquedas. Se recomenda usar expresiones regulares: en la consulta en lugar de habilitar esta opción. diff --git a/Properties/Resources.fr-fr.resx b/Properties/Resources.fr-fr.resx index e99ed18..96e96a4 100644 --- a/Properties/Resources.fr-fr.resx +++ b/Properties/Resources.fr-fr.resx @@ -126,12 +126,6 @@ Copier le chemin - - (Ctrl+C) - - - (Ctrl+Alt+C) - Installer Everything s'il n'est pas installé @@ -156,9 +150,6 @@ Afficher les résultats de recherche Everything - - Everything - Aperçu @@ -171,9 +162,6 @@ Les résultats sélectionnés peuvent mettre à jour le texte de la requête. Aide à afficher des informations supplémentaires, mais peut modifier les résultats de l'affichage. Permet d'afficher des informations supplémentaires, mais peut modifier les résultats de l'affichage. - - RegEx - Active les expressions régulières dans la recherche. diff --git a/Properties/Resources.pl-pl.resx b/Properties/Resources.pl-pl.resx index d990997..b2e4bec 100644 --- a/Properties/Resources.pl-pl.resx +++ b/Properties/Resources.pl-pl.resx @@ -133,12 +133,6 @@ Kopiuj ścieżkę - - (Ctrl+C) - - - (Ctrl+Alt+C) - Zmienne środowiskowe @@ -175,9 +169,6 @@ Pokazuj wyniki wyszukiwania z Everything - - Everything - Podgląd @@ -190,9 +181,6 @@ Wybrany wynik może zmienić zapytanie. Pomaga wyświetlić dodatkowe informacje, ale może zmienić wyświetlane wyniki. - - RegEx - Włącz wyrażenia regularne w wyszukiwaniu. @@ -224,4 +212,4 @@ Dostępna: {1} Sprawdź aktualizacje - + \ No newline at end of file diff --git a/Properties/Resources.resx b/Properties/Resources.resx index f9f7b77..cb8dce2 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -125,7 +125,7 @@ Configure context menu options and order. -0_Open folder, 1_Run as Admin, 2_Run as User, 3_Copy, 4_Copy Path, 5_Open in Console +0_Open folder, 1_Run as Admin, 2_Run as User, 3_Copy, 4_Copy Path, 5_Open in Console, 6_Open in custom program Copy @@ -149,7 +149,7 @@ Everything64.exe - Location of Everything64.exe if it's not installed in "Program Files" + Location of Everything.exe if it's not installed in "Program Files" Install Everything if not installed @@ -250,4 +250,19 @@ Latest: {1} Check for updates + + Custom Program + + + Path to a external program that'll open the selected result + + + Launch argument + + + Argument to pass to the program when launching. [$P=path of the selected result ] + + + Open path in custom program (Ctrl+N) + \ No newline at end of file diff --git a/Properties/Resources.zh-cn.resx b/Properties/Resources.zh-cn.resx index 33323ab..eb60b01 100644 --- a/Properties/Resources.zh-cn.resx +++ b/Properties/Resources.zh-cn.resx @@ -120,6 +120,10 @@ 无法设置剪贴板中的文本 + + + + 配置选单选项与顺序 0_打开所在文件夹、1_以管理员身分运行、2_以不同的使用者身分运行、3_复制、4_复制路径、5_在控制台中开启 @@ -134,7 +138,7 @@ 搜索时可以使用环境变量,但会增加搜索时间 - 若Everything安装位置非预设的Program Files,请提供Everything64exe的位置 + 若Everything安装位置非预设的Program Files,请提供Everything.exe的位置 是否安装了 Everything? @@ -166,9 +170,6 @@ 利用 Everything 搜索磁盘文件 - - Everything - 为搜索词添加固定的前缀,搜索时无需再手动输入修饰词/筛选词 前缀与搜索词之间不会自动加入空格 @@ -197,14 +198,14 @@ 使用 Ctrl+C 复制档案,Ctrl+Alt+C 复制路径 - - 检查是否有更新 - - + 更新EverythingPowerToys吗? 点击 '否' 将不再收到有关此版本更新的通知 安装版本:{0} 最新版本:{1} + + 检查是否有更新 + \ No newline at end of file diff --git a/Properties/Resources.zh-tw.resx b/Properties/Resources.zh-tw.resx index 5da6b1b..221a17f 100644 --- a/Properties/Resources.zh-tw.resx +++ b/Properties/Resources.zh-tw.resx @@ -122,7 +122,7 @@ 配置選單選項與順序 -0_開啟資料夾、1_以管理員身分執行、2_以其他使用者身分執行、3_複製、4_複製路徑、5_在命令提示字元中開啟 +0_開啟資料夾、1_以管理員身分執行、2_以其他使用者身分執行、3_複製、4_複製路徑、5_在命令提示字元中開啟、6_在指定軟體中開啟 複製 @@ -134,7 +134,7 @@ 搜尋時可用環境變數,但會增加搜尋時間 - 若Everything安裝位置非預設的Program Files,請提供Everything64.exe的位置 + 若Everything安裝位置非預設的Program Files,請提供Everything.exe的位置 是否有安裝 Everything? @@ -166,9 +166,6 @@ 利用 Everything 搜尋電腦上的檔案 - - Everything 搜尋 - 為收尋詞增加固定的前綴,在收詢時不用再自行打修飾詞/篩選詞 前綴與收尋詞之間不會自動加入空格 @@ -189,8 +186,8 @@ 以其他使用者身分執行 (Ctrl+Shift+U) - - 顯示一個以用目前搜尋詞打開 Everything的結果 + + 在Everything裡顯示剩餘的收尋結果 設定結果排序方法 @@ -198,14 +195,23 @@ 使用 Ctrl+C 複製檔案,Ctrl+Alt+C 複製路徑 - - 啟用時檢查是否有更新 - - + 更新EverythingPowerToys? 按 '否' 不再通知這版的更新 安裝版本:{0} 最新版本:{1} + + 啟用時檢查是否有更新 + + + 要使用的指定軟體路徑 + + + 執行參數 [$P=收尋結果路徑] + + + 在指定軟體裡開起 (Ctrl+N) + \ No newline at end of file diff --git a/Settings.cs b/Settings.cs index aa5bd39..b4a4a04 100644 --- a/Settings.cs +++ b/Settings.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using Wox.Plugin.Logger; using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods; namespace Community.PowerToys.Run.Plugin.Everything @@ -11,7 +12,7 @@ namespace Community.PowerToys.Run.Plugin.Everything // Settings from PTR settings public Sort Sort { get; set; } = Sort.NAME_ASCENDING; public uint Max { get; set; } = 10; - public string Context { get; set; } = "012345"; + public string Context { get; set; } = "0123456"; public bool Copy { get; set; } public bool MatchPath { get; set; } public bool Preview { get; set; } = true; @@ -20,23 +21,32 @@ 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; public string Prefix { get; set; } public string EverythingPath { get; set; } public bool ShowMore { get; set; } = true; + public string CustomProgram { get; set; } = "notepad.exe"; + public string CustomArg { get; set; } = "$P"; +#if DEBUG + public LogLevel Log { get; set; } = LogLevel.None; +#endif // Get Filters from settings.toml public Dictionary Filters { get; } = []; internal void Getfilters() { +#if DEBUG if (Log > LogLevel.None) Debugger.Write("2.Getting Filters..."); +#endif string[] strArr; try { strArr = File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "settings.toml")); } catch (Exception e) { +#if DEBUG if (Log > LogLevel.None) Debugger.Write($"\r\nERROR: {e.Message}\r\n"); +#endif + Log.Error($"Error reading settings.toml: {e.Message}", GetType()); return; } @@ -49,16 +59,18 @@ namespace Community.PowerToys.Run.Plugin.Everything if (kv[0].Contains(':')) Filters.TryAdd(kv[0].ToLowerInvariant(), kv[1] + (kv[1].EndsWith(';') ? ' ' : string.Empty)); } - +#if DEBUG if (Log > LogLevel.None) Debugger.Write(Log > LogLevel.Debug ? string.Join(Environment.NewLine, Filters) + "\r\n" : string.Empty + " GettingFilters...Done"); +#endif } } - +#if DEBUG public enum LogLevel { None, Debug, Verbose, } +#endif } diff --git a/Update.cs b/Update.cs index d421098..335e66c 100644 --- a/Update.cs +++ b/Update.cs @@ -17,18 +17,19 @@ 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 DEBUG if (s.Log > LogLevel.None) Debugger.Write("1.Checking Update..."); - +#endif try { using HttpClient httpClient = new(); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0"); HttpResponseMessage response = await httpClient.GetAsync(apiUrl); - +#if DEBUG if (s.Log == LogLevel.Verbose) Debugger.Write($"\tResponse: {response.StatusCode}"); - +#endif if (response.IsSuccessStatusCode) { using JsonDocument jsonDocument = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync()); @@ -79,14 +80,19 @@ namespace Community.PowerToys.Run.Plugin.Everything } } } +#if RELEASE + catch + { } +#else catch (Exception e) { if (s.Log > LogLevel.None) Debugger.Write($"\r\nERROR: {e.Message}\r\n{e.StackTrace}\r\n"); + } - if (s.Log > LogLevel.None) Debugger.Write(" Checking Update...Done"); +#endif } } } diff --git a/bin/.gitinclude b/bin/.gitinclude deleted file mode 100644 index 7c6e123..0000000 --- a/bin/.gitinclude +++ /dev/null @@ -1 +0,0 @@ -folder needs to exist so nsis doesn't complain \ No newline at end of file diff --git a/plugin.json b/plugin.json index 3a60fb6..87f8088 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "IsGlobal": true, "Name": "Everything", "Author": "Yu Chieh (Victor) Lin", - "Version": "0.82.1", + "Version": "0.85.1", "Language": "csharp", "Website": "https://github.com/Lin-ycv/EverythingPowerToys", "ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",