This commit is contained in:
Koisu 2025-06-20 11:17:58 -07:00
commit 8d8388be61

View file

@ -8,6 +8,7 @@ using Mages.Core;
using Flow.Launcher.Plugin.Calculator.ViewModels;
using Flow.Launcher.Plugin.Calculator.Views;
namespace Flow.Launcher.Plugin.Calculator
{
public class Main : IPlugin, IPluginI18n, ISettingProvider
@ -15,7 +16,7 @@ namespace Flow.Launcher.Plugin.Calculator
private static readonly Regex RegValidExpressChar = new Regex(
@"^(" +
@"ceil|floor|exp|pi|e|max|min|det|abs|log|ln|sqrt|" +
@"sin|cos|tan|arcsin|arccos|arctan|" +
@"sin|cos|tan|arcsin|arccos|arctan|rad2deg|deg2rad|" +
@"eigval|eigvec|eig|sum|polar|plot|round|sort|real|zeta|" +
@"bin2dec|hex2dec|oct2dec|" +
@"factorial|sign|isprime|isinfty|" +
@ -45,6 +46,8 @@ namespace Flow.Launcher.Plugin.Calculator
{ "e", Math.E }, // e is not contained in the default mages engine
}
});
MagesEngine.SetFunction("rad2deg", (double rad) => rad * (180.0 / Math.PI));
MagesEngine.SetFunction("deg2rad", (double x) => x * (Math.PI / 180.0));
}
public List<Result> Query(Query query)
@ -169,9 +172,9 @@ namespace Flow.Launcher.Plugin.Calculator
private bool IsBracketComplete(string query)
{
var matchs = RegBrackets.Matches(query);
var matches = RegBrackets.Matches(query);
var leftBracketCount = 0;
foreach (Match match in matchs)
foreach (Match match in matches)
{
if (match.Value == "(" || match.Value == "[")
{