patterns: Allow console log to be printed immediately and from format functions
This commit is contained in:
parent
60a95eddd7
commit
59aa52e744
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
||||
Subproject commit 9fe6b2bd4b428f6e31473cbd83e66a5e04d4a045
|
||||
Subproject commit 86e4a8d4c0934412cf69713516a96f268f1d7e6d
|
@ -155,8 +155,9 @@ namespace hex::plugin::builtin {
|
||||
PerProvider<std::vector<std::pair<pl::core::LogConsole::Level, std::string>>> m_console;
|
||||
PerProvider<bool> m_executionDone = true;
|
||||
|
||||
std::mutex m_logMutex;
|
||||
|
||||
PerProvider<std::optional<pl::core::err::PatternLanguageError>> m_lastEvaluationError;
|
||||
PerProvider<std::vector<std::pair<pl::core::LogConsole::Level, std::string>>> m_lastEvaluationLog;
|
||||
PerProvider<std::map<std::string, pl::core::Token::Literal>> m_lastEvaluationOutVars;
|
||||
PerProvider<std::map<std::string, PatternVariable>> m_patternVariables;
|
||||
PerProvider<std::map<u64, pl::api::Section>> m_sections;
|
||||
|
@ -220,6 +220,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::BeginChild("##console", size, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar)) {
|
||||
ImGuiListClipper clipper;
|
||||
|
||||
std::scoped_lock lock(this->m_logMutex);
|
||||
clipper.Begin(console.size());
|
||||
|
||||
while (clipper.Step())
|
||||
@ -512,8 +513,6 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (!this->m_lastEvaluationProcessed) {
|
||||
*this->m_console = this->m_lastEvaluationLog;
|
||||
|
||||
if (!this->m_lastEvaluationResult) {
|
||||
if (this->m_lastEvaluationError->has_value()) {
|
||||
TextEditor::ErrorMarkers errorMarkers = {
|
||||
@ -689,8 +688,12 @@ namespace hex::plugin::builtin {
|
||||
return this->m_dangerousFunctionsAllowed == DangerousFunctionPerms::Allow;
|
||||
});
|
||||
|
||||
runtime.setLogCallback([this](auto level, auto message) {
|
||||
std::scoped_lock lock(this->m_logMutex);
|
||||
this->m_console->emplace_back(level, message);
|
||||
});
|
||||
|
||||
ON_SCOPE_EXIT {
|
||||
*this->m_lastEvaluationLog = runtime.getConsoleLog();
|
||||
*this->m_lastEvaluationOutVars = runtime.getOutVariables();
|
||||
*this->m_sections = runtime.getSections();
|
||||
|
||||
@ -698,7 +701,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
this->m_lastEvaluationProcessed = false;
|
||||
|
||||
this->m_lastEvaluationLog->emplace_back(
|
||||
std::scoped_lock lock(this->m_logMutex);
|
||||
this->m_console->emplace_back(
|
||||
pl::core::LogConsole::Level::Info,
|
||||
hex::format("Evaluation took {}", runtime.getLastRunningTime())
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user