sys: Copy pattern source code from current provider to newly created one
This commit is contained in:
parent
623756c4f4
commit
4d3538781b
@ -245,9 +245,9 @@ namespace hex {
|
||||
return;
|
||||
|
||||
s_providers.push_back(provider);
|
||||
setCurrentProvider(s_providers.size() - 1);
|
||||
|
||||
EventManager::post<EventProviderCreated>(provider);
|
||||
|
||||
setCurrentProvider(s_providers.size() - 1);
|
||||
}
|
||||
|
||||
void remove(prv::Provider *provider) {
|
||||
|
@ -307,7 +307,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_TabActive, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
ImGui::PushStyleColor(ImGuiCol_TabUnfocusedActive, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
auto providerSelectorVisible = ImGui::BeginTabBar("provider_switcher", ImGuiTabBarFlags_FittingPolicyScroll | ImGuiTabBarFlags_Reorderable);
|
||||
auto providerSelectorVisible = ImGui::BeginTabBar("provider_switcher", ImGuiTabBarFlags_FittingPolicyScroll | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_AutoSelectNewTabs);
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
if (providerSelectorVisible) {
|
||||
|
@ -96,16 +96,15 @@ namespace hex::plugin::builtin {
|
||||
this->m_textEditor.SetText(code);
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventFileLoaded>(this, [this](const std::fs::path &path) {
|
||||
hex::unused(path);
|
||||
|
||||
EventManager::subscribe<EventProviderCreated>(this, [this](prv::Provider *provider) {
|
||||
if (!ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_load_patterns", 1))
|
||||
return;
|
||||
|
||||
if (!ImHexApi::Provider::isValid())
|
||||
return;
|
||||
// Copy over current pattern source code to the new provider
|
||||
{
|
||||
provider->getPatternLanguageSourceCode() = this->m_textEditor.GetText();
|
||||
}
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
auto &runtime = provider->getPatternLanguageRuntime();
|
||||
|
||||
auto mimeType = magic::getMIMEType(ImHexApi::Provider::get());
|
||||
|
Loading…
Reference in New Issue
Block a user