2023-11-12 01:22:01 +01:00
|
|
|
#include <hex/helpers/http_requests.hpp>
|
|
|
|
#include <hex/helpers/utils.hpp>
|
2023-11-21 14:38:01 +01:00
|
|
|
#include <hex/api/localization_manager.hpp>
|
2023-11-12 01:22:01 +01:00
|
|
|
|
|
|
|
#include <regex>
|
|
|
|
|
|
|
|
#include <imgui.h>
|
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
|
|
|
|
2023-12-01 13:53:51 +01:00
|
|
|
#include <fonts/codicons_font.h>
|
|
|
|
|
2023-11-12 01:22:01 +01:00
|
|
|
namespace hex::plugin::builtin {
|
2023-12-01 13:53:51 +01:00
|
|
|
|
|
|
|
void drawRegexReplacer() {
|
|
|
|
static auto regexInput = [] { std::string s; s.reserve(0xFFF); return s; }();
|
|
|
|
static auto regexPattern = [] { std::string s; s.reserve(0xFFF); return s; }();
|
|
|
|
static auto replacePattern = [] { std::string s; s.reserve(0xFFF); return s; }();
|
|
|
|
static auto regexOutput = [] { std::string s; s.reserve(0xFFF); return s; }();
|
|
|
|
|
|
|
|
ImGui::PushItemWidth(-150_scaled);
|
|
|
|
bool changed1 = ImGuiExt::InputTextIcon("hex.builtin.tools.regex_replacer.pattern"_lang, ICON_VS_REGEX, regexPattern);
|
|
|
|
bool changed2 = ImGuiExt::InputTextIcon("hex.builtin.tools.regex_replacer.replace"_lang, ICON_VS_REGEX, replacePattern);
|
|
|
|
bool changed3 = ImGui::InputTextMultiline("hex.builtin.tools.regex_replacer.input"_lang, regexInput, ImVec2(0, 0));
|
|
|
|
|
|
|
|
if (changed1 || changed2 || changed3) {
|
|
|
|
try {
|
|
|
|
regexOutput = std::regex_replace(regexInput.data(), std::regex(regexPattern.data()), replacePattern.data());
|
|
|
|
} catch (std::regex_error &) { }
|
2023-11-12 01:22:01 +01:00
|
|
|
}
|
2023-12-01 13:53:51 +01:00
|
|
|
|
|
|
|
ImGui::InputTextMultiline("hex.builtin.tools.regex_replacer.output"_lang, regexOutput.data(), regexOutput.size(), ImVec2(0, 0), ImGuiInputTextFlags_ReadOnly);
|
|
|
|
|
|
|
|
ImGui::PopItemWidth();
|
2023-11-12 01:22:01 +01:00
|
|
|
}
|
2023-12-01 13:53:51 +01:00
|
|
|
|
2023-11-12 01:22:01 +01:00
|
|
|
}
|