EverythingPowerToys/Settings.cs
Lin Yu-Chieh (Victor) 3841365af3 Enhanced ARM64 support and code cleanup
- Updated `Community.PowerToys.Run.Plugin.Everything.csproj` for better `x64` and `ARM64` support, including platform-specific constants and simplified resource management.

- Improved `ARM64` build process in `PostBuild` event, including automatic replacement of `Everything64.dll` with `EverythingARM64.dll`.

- Streamlined result processing in `Everything.cs` for efficiency and readability, using direct paths and filenames from the Everything SDK.

- Reverted to `[DllImport]` in `NativeMethods.cs` for P/Invoke, updating method signatures accordingly.

- Cleaned up `Main.cs` by removing unused `using` directives, handling a new `Prefix` setting, and removing obsolete ARM DLL logic.

- Extended plugin configuration options in `Settings.cs` with a new property for the query prefix and differentiated update logic in `Update.cs` for `x64` and `ARM64` executables.

- Closes #115 #112
2024-07-03 22:08:20 +08:00

63 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods;
namespace Community.PowerToys.Run.Plugin.Everything
{
public class Settings
{
// Settings from PTR settings
public Sort Sort { get; set; } = Sort.DATE_MODIFIED_DESCENDING;
public uint Max { get; set; } = 20;
public string Context { get; set; } = "012345";
public bool Copy { get; set; }
public bool MatchPath { get; set; }
public bool Preview { get; set; } = true;
public bool QueryText { get; set; }
public bool RegEx { get; set; }
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; }
// 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 (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;
string[] kv = str.Split('=', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (kv.Length != 2) continue;
if (kv[0].Contains(':'))
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,
}
}