feat: Make CTRL + N automatically create a memory provider (#966)
"CTRL + N" can open a mem_file directly.
This commit is contained in:
parent
f661f4d1d6
commit
cdd5d33e89
@ -65,18 +65,11 @@ namespace hex::plugin::builtin {
|
||||
|
||||
EventManager::subscribe<RequestOpenWindow>([](const std::string &name) {
|
||||
if (name == "Create File") {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.popup.error.create"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
file.setSize(1);
|
||||
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
});
|
||||
auto newProvider = hex::ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true);
|
||||
if (newProvider != nullptr && !newProvider->open())
|
||||
hex::ImHexApi::Provider::remove(newProvider);
|
||||
else
|
||||
EventManager::post<EventProviderOpened>(newProvider);
|
||||
} else if (name == "Open File") {
|
||||
ImHexApi::Provider::createProvider("hex.builtin.provider.file");
|
||||
} else if (name == "Open Project") {
|
||||
@ -141,4 +134,4 @@ namespace hex::plugin::builtin {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user