Huge refactoring of builtin features into an external plugin

This commit is contained in:
WerWolv
2021-01-22 18:01:39 +01:00
parent 9bc569bf9a
commit 104000fbc4
30 changed files with 1095 additions and 842 deletions

View File

@@ -2,35 +2,12 @@
#include <GLFW/glfw3.h>
#include "helpers/math_evaluator.hpp"
namespace hex {
ViewCommandPalette::ViewCommandPalette() : View("Command Palette") {
this->getWindowOpenState() = true;
this->m_commandBuffer.resize(1024, 0x00);
ContentRegistry::CommandPaletteCommands::add(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
"#", "Calculator",
[](auto input) {
MathEvaluator evaluator;
evaluator.registerStandardVariables();
evaluator.registerStandardFunctions();
std::optional<long double> result;
try {
result = evaluator.evaluate(input);
} catch (std::runtime_error &e) {}
if (result.has_value())
return hex::format("#%s = %Lf", input.data(), result.value());
else
return hex::format("#%s = ???", input.data());
});
this->m_lastResults = this->getCommandResults("");
}