-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathSettings.cs
64 lines (56 loc) · 2.47 KB
/
Settings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using NLog;
using Wox.Plugin.Logger;
using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods;
namespace Community.PowerToys.Run.Plugin.Everything
{
public class Settings
{
internal bool Is1_4 { get; set; }
// Settings from PTR settings
internal Sort Sort { get; set; } = Sort.NAME_ASCENDING;
internal uint Max { get; set; } = 10;
internal string Context { get; set; } = "01234568";
internal bool Copy { get; set; }
internal bool MatchPath { get; set; }
internal bool Preview { get; set; } = true;
internal bool QueryText { get; set; }
internal bool RegEx { get; set; }
internal bool EnvVar { get; set; }
internal bool Updates { get; set; } = true;
internal string Prefix { get; set; }
internal string EverythingPath { get; set; }
internal bool ShowMore { get; set; } = true;
internal string CustomProgram { get; set; } = "notepad.exe";
internal string CustomArg { get; set; } = "$P";
internal LogLevel LoggingLevel { get; set; } = LogLevel.Error;
// Get Filters from settings.toml
public Dictionary<string, string> Filters { get; } = [];
internal void Getfilters()
{
Is1_4 = true;
if (LoggingLevel <= LogLevel.Info)
Log.Info("User on Everything 1.4, GettingFilters...", GetType());
string[] strArr;
try { strArr = File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "settings.toml")); }
catch (Exception e)
{
Log.Error($"Error reading settings.toml: {e.Message}", GetType());
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 (LoggingLevel <= LogLevel.Info)
Log.Info(LoggingLevel < LogLevel.Debug ? string.Join(Environment.NewLine, Filters) : " GettingFilters...Done", GetType());
}
}
}