doc/devdocs/modules/launcher/plugins/calculator.md
The Calculator plugin as the name suggests is used to perform calculations on the user entered query.
We have the following settings that the user can configure to change the behavior of the plugin:
| Key | Default value | Name | Description |
|---|---|---|---|
InputUseEnglishFormat | false | Use English (United States) number format for input | Ignores your system setting and expects numbers in the format '1,000.50' |
OutputUseEnglishFormat | false | Use English (United States) number format for output | Ignores your system setting and returns numbers in the format '1000.50' |
The optional plugin settings are implemented via the ISettingProvider interface from Wox.Plugin project. All available settings for the plugin are defined in the Main class of the plugin.
BracketHelperCalculateHelperCalculateHelper.cs class checks to see if the user entered query is a valid input to the calculator and only if the input is valid does it perform the operation.
2(1+2) and (2+3)(3+4) in order to be computed by Mages lib.
'*' where appropriate, e.g: 2(1+2) -> 2 * (1+2)num), constants (const), functions (func) and expressions in parentheses ((exp)).'const num' or 'func const'CalculateEngineCalculateEngine.cs file using the Mages library.var result = CalculateEngine.Interpret(query.Search, CultureInfo.CurrentUICulture);
CalculateResultResult and RoundedResult properties.ErrorHandlerThe score of each result from the calculator plugin is 300.
We have a Unit Test project that executes various test to ensure that the plugin works as expected.
BracketHelperTestsBracketHelperTests.cs class contains tests to validate that brackets are handled correctly.ExtendedCalculatorParserTestsExtendedCalculatorParserTests.cs class contains tests to validate that the input is parsed correctly and the result is correct.NumberTranslatorTestsNumberTranslatorTests.cs class contains tests to validate that each number is converted correctly based on the defined locals.QueryTestsQueryTests.cs class contains tests to validate that the user gets the correct results when searching.