feat: Added Paste all option to paste and resize file without checks
Closes #791
This commit is contained in:
parent
6a8611d98d
commit
139a379a09
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
namespace hex::plugin::builtin::prv {
|
||||
|
||||
@ -29,7 +30,7 @@ namespace hex::plugin::builtin::prv {
|
||||
void save() override;
|
||||
void saveAs(const std::fs::path &path) override;
|
||||
|
||||
[[nodiscard]] std::string getName() const override { return "hex.builtin.provider.mem_file.unsaved"; }
|
||||
[[nodiscard]] std::string getName() const override { return LangEntry("hex.builtin.provider.mem_file.unsaved"); }
|
||||
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override { return { }; }
|
||||
|
||||
[[nodiscard]] std::string getTypeName() const override {
|
||||
|
@ -1320,7 +1320,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::SetClipboardText(result.c_str());
|
||||
}
|
||||
|
||||
static void pasteBytes(const Region &selection) {
|
||||
static void pasteBytes(const Region &selection, bool selectionCheck) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
std::string clipboard = ImGui::GetClipboardText();
|
||||
@ -1343,8 +1343,14 @@ namespace hex::plugin::builtin {
|
||||
// Convert hex string to bytes
|
||||
std::vector<u8> buffer = crypt::decode16(clipboard);
|
||||
|
||||
if (!selectionCheck) {
|
||||
if (selection.getStartAddress() + buffer.size() >= provider->getActualSize())
|
||||
provider->resize(selection.getStartAddress() + buffer.size());
|
||||
}
|
||||
|
||||
// Write bytes
|
||||
provider->write(selection.getStartAddress() + provider->getBaseAddress() + provider->getCurrentPageAddress(), buffer.data(), std::min(selection.size, buffer.size()));
|
||||
auto size = selectionCheck ? std::min(buffer.size(), selection.getSize()) : buffer.size();
|
||||
provider->write(selection.getStartAddress() + provider->getBaseAddress() + provider->getCurrentPageAddress(), buffer.data(), size);
|
||||
}
|
||||
|
||||
static void copyString(const Region &selection) {
|
||||
@ -1520,7 +1526,13 @@ namespace hex::plugin::builtin {
|
||||
// Paste
|
||||
ShortcutManager::addShortcut(this, CTRL + Keys::V, [] {
|
||||
const auto selection = getSelection();
|
||||
pasteBytes(selection);
|
||||
pasteBytes(selection, true);
|
||||
});
|
||||
|
||||
// Paste and resize
|
||||
ShortcutManager::addShortcut(this, CTRL + SHIFT + Keys::V, [] {
|
||||
const auto selection = getSelection();
|
||||
pasteBytes(selection, false);
|
||||
});
|
||||
|
||||
// Undo / Redo
|
||||
@ -1738,7 +1750,9 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.edit.paste"_lang, "CTRL + V", false, selection.has_value()))
|
||||
pasteBytes(*selection);
|
||||
pasteBytes(*selection, true);
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.edit.paste_all"_lang, "CTRL + V", false, selection.has_value()))
|
||||
pasteBytes(*selection, false);
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hex_editor.menu.edit.select_all"_lang, "CTRL + A", false, selection.has_value() && providerValid))
|
||||
ImHexApi::HexEditor::setSelection(provider->getBaseAddress(), provider->getActualSize());
|
||||
|
@ -336,6 +336,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "Einfügen" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Alles einfügen" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "Alles auswählen" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "Basisadresse setzen" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "Grösse ändern..." },
|
||||
|
@ -339,6 +339,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "Paste" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "Select all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "Set base address" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "Resize..." },
|
||||
|
@ -341,6 +341,7 @@ namespace hex::plugin::builtin {
|
||||
//{ "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "Incolla" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "Seleziona tutti" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "Imposta indirizzo di base" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "Ridimensiona..." },
|
||||
|
@ -340,6 +340,7 @@ namespace hex::plugin::builtin {
|
||||
//{ "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "貼り付け" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "すべて選択" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.bookmark", "ブックマークを作成" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "ベースアドレスをセット" },
|
||||
|
@ -338,6 +338,7 @@ namespace hex::plugin::builtin {
|
||||
//{ "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "붙여넣기" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "모두 선택하기" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "베이스 주소 설정" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "크기 변경..." },
|
||||
|
@ -338,6 +338,7 @@ namespace hex::plugin::builtin {
|
||||
//{ "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "Colar" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "Selecionar tudo" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "Definir endereço base" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "Redimensionar..." },
|
||||
|
@ -341,6 +341,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.view.hex_editor.copy.ascii", "ASCII 文本" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "粘贴" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "全选" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "设置基地址" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "修改大小..." },
|
||||
|
@ -338,6 +338,7 @@ namespace hex::plugin::builtin {
|
||||
// { "hex.builtin.view.hex_editor.copy.ascii", "Text Area" },
|
||||
{ "hex.builtin.view.hex_editor.copy.html", "HTML" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.paste", "貼上" },
|
||||
//{ "hex.builtin.view.hex_editor.menu.edit.paste_all", "Paste all" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.select_all", "全選" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.set_base", "設置基址" },
|
||||
{ "hex.builtin.view.hex_editor.menu.edit.resize", "縮放..." },
|
||||
|
Loading…
x
Reference in New Issue
Block a user