#include #include #include #include #include #include namespace hex::plugin::builtin { void drawHexVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) { static ui::HexEditor editor; static std::unique_ptr dataProvider; if (shouldReset) { auto pattern = arguments[0].toPattern(); std::vector data; dataProvider = std::make_unique(); try { data = pattern->getBytes(); } catch (const std::exception &) { dataProvider->resize(0); throw; } dataProvider->resize(data.size()); dataProvider->writeRaw(0x00, data.data(), data.size()); dataProvider->setReadOnly(true); editor.setProvider(dataProvider.get()); } if (ImGui::BeginChild("##editor", scaled(ImVec2(600, 400)), false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) { editor.draw(); ImGui::EndChild(); } } }