Show evaluator errors in a console window instead of the first line
This commit is contained in:
parent
575903f921
commit
9f275cc84f
2
external/ImGui/source/TextEditor.cpp
vendored
2
external/ImGui/source/TextEditor.cpp
vendored
@ -1127,7 +1127,7 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder)
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertU32ToFloat4(mPalette[(int)PaletteIndex::Background]));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
|
||||
if (!mIgnoreImGuiChild)
|
||||
ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NoMove);
|
||||
ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoMove);
|
||||
|
||||
if (mHandleKeyboardInputs)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ namespace hex {
|
||||
std::filesystem::path m_possiblePatternFile;
|
||||
|
||||
TextEditor m_textEditor;
|
||||
std::vector<std::string> m_console;
|
||||
imgui_addons::ImGuiFileBrowser m_fileBrowser;
|
||||
|
||||
void loadPatternFile(std::string path);
|
||||
|
@ -185,7 +185,21 @@ namespace hex {
|
||||
auto provider = *SharedData::get().currentProvider;
|
||||
|
||||
if (provider != nullptr && provider->isAvailable()) {
|
||||
this->m_textEditor.Render("Pattern");
|
||||
auto textEditorSize = ImGui::GetContentRegionAvail();
|
||||
textEditorSize.y *= 4.0/5.0;
|
||||
this->m_textEditor.Render("Pattern", textEditorSize, true);
|
||||
|
||||
auto consoleSize = ImGui::GetContentRegionAvail();
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.0, 0.0, 0.0, 1.0));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0, 1.0, 1.0, 1.0));
|
||||
|
||||
if (ImGui::BeginChild("##console", consoleSize, true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
for (auto &line : this->m_console)
|
||||
ImGui::TextUnformatted(line.c_str());
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
if (this->m_textEditor.IsTextChanged()) {
|
||||
this->parsePattern(this->m_textEditor.GetText().data());
|
||||
@ -254,6 +268,7 @@ namespace hex {
|
||||
void ViewPattern::parsePattern(char *buffer) {
|
||||
this->clearPatternData();
|
||||
this->m_textEditor.SetErrorMarkers({ });
|
||||
this->m_console.clear();
|
||||
this->postEvent(Events::PatternChanged);
|
||||
|
||||
hex::lang::Preprocessor preprocessor;
|
||||
@ -307,7 +322,7 @@ namespace hex {
|
||||
hex::lang::Evaluator evaluator(provider, defaultDataEndianess);
|
||||
auto patternData = evaluator.evaluate(ast.value());
|
||||
if (!patternData.has_value()) {
|
||||
this->m_textEditor.SetErrorMarkers({ evaluator.getError() });
|
||||
this->m_console.push_back(evaluator.getError().second);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user