parent
0454a369e5
commit
0be539b8a5
@ -797,6 +797,7 @@
|
||||
"hex.builtin.view.hex_editor.copy.crystal": "Crystal Array",
|
||||
"hex.builtin.view.hex_editor.copy.csharp": "C# Array",
|
||||
"hex.builtin.view.hex_editor.copy.custom_encoding": "Custom Encoding",
|
||||
"hex.builtin.view.hex_editor.copy.escaped_string": "Escaped String",
|
||||
"hex.builtin.view.hex_editor.copy.go": "Go Array",
|
||||
"hex.builtin.view.hex_editor.copy.hex_view": "Hex View",
|
||||
"hex.builtin.view.hex_editor.copy.html": "HTML",
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
static std::string formatLanguageArray(prv::Provider *provider, u64 offset, size_t size, const std::string &start, const std::string &byteFormat, const std::string &end, bool removeFinalDelimiter= false) {
|
||||
static std::string formatLanguageArray(prv::Provider *provider, u64 offset, size_t size, const std::string &start, const std::string &byteFormat, const std::string &end, bool removeFinalDelimiter = false, bool newLines = true) {
|
||||
constexpr static auto NewLineIndent = "\n ";
|
||||
constexpr static auto LineLength = 16;
|
||||
|
||||
std::string result;
|
||||
result.reserve(start.size() + hex::format(byteFormat, 0x00).size() * size + + std::string(NewLineIndent).size() / LineLength + end.size());
|
||||
result.reserve(start.size() + hex::format(byteFormat, 0x00).size() * size + std::string(NewLineIndent).size() / LineLength + end.size());
|
||||
|
||||
result += start;
|
||||
|
||||
@ -29,8 +29,11 @@ namespace hex::plugin::builtin {
|
||||
|
||||
u64 index = 0x00;
|
||||
for (u8 byte : reader) {
|
||||
if ((index % LineLength) == 0x00)
|
||||
result += NewLineIndent;
|
||||
|
||||
if (newLines) {
|
||||
if ((index % LineLength) == 0x00)
|
||||
result += NewLineIndent;
|
||||
}
|
||||
|
||||
result += hex::format(byteFormat, byte);
|
||||
|
||||
@ -43,7 +46,8 @@ namespace hex::plugin::builtin {
|
||||
result.pop_back();
|
||||
}
|
||||
|
||||
result += "\n" + end;
|
||||
if (newLines) result += "\n";
|
||||
result += end;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -176,6 +180,10 @@ namespace hex::plugin::builtin {
|
||||
return result;
|
||||
});
|
||||
|
||||
ContentRegistry::DataFormatter::addExportMenuEntry("hex.builtin.view.hex_editor.copy.escaped_string", [](prv::Provider *provider, u64 offset, size_t size) {
|
||||
return formatLanguageArray(provider, offset, size, "\"", "\\x{0:02X}", "\"", false, false);
|
||||
});
|
||||
|
||||
ContentRegistry::DataFormatter::addFindExportFormatter("csv", "csv", [](const std::vector<ContentRegistry::DataFormatter::impl::FindOccurrence>& occurrences, const auto &transformFunc) {
|
||||
export_fmt::ExportFormatterCsv formatter;
|
||||
return formatter.format(occurrences, transformFunc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user