ui: Added strings to data inspector
This commit is contained in:
parent
82cb7917e4
commit
19c367b540
@ -2,11 +2,15 @@
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/shared_data.hpp>
|
||||
#include <hex/api/event.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
@ -127,6 +131,27 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.string", 0, [](auto buffer, auto endian, auto style) {
|
||||
Region currSelection = { 0 };
|
||||
EventManager::post<QuerySelection>(currSelection);
|
||||
|
||||
constexpr static auto MaxStringLength = 32;
|
||||
|
||||
std::string stringBuffer(std::min<ssize_t>(MaxStringLength, currSelection.size), 0x00);
|
||||
SharedData::currentProvider->read(currSelection.address, stringBuffer.data(), stringBuffer.size());
|
||||
if (currSelection.size > MaxStringLength)
|
||||
stringBuffer += "...";
|
||||
|
||||
for (auto &c : stringBuffer)
|
||||
if (c < 0x20 || c == '\n' || c == '\r')
|
||||
c = ' ';
|
||||
|
||||
|
||||
auto value = hex::format("\"{0}\"", stringBuffer);
|
||||
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
#if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(__time32_t), [](auto buffer, auto endian, auto style) {
|
||||
|
@ -319,6 +319,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.ascii", "ASCII Zeichen" },
|
||||
{ "hex.builtin.inspector.wide", "Wide Zeichen" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8 code point" },
|
||||
{ "hex.builtin.inspector.string", "String" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
|
@ -319,6 +319,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.ascii", "ASCII Character" },
|
||||
{ "hex.builtin.inspector.wide", "Wide Character" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8 code point" },
|
||||
{ "hex.builtin.inspector.string", "String" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
|
@ -318,6 +318,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.ascii", "ASCII Character" },
|
||||
{ "hex.builtin.inspector.wide", "Wide Character" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8 code point" },
|
||||
{ "hex.builtin.inspector.string", "String" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
|
@ -208,7 +208,10 @@ namespace hex {
|
||||
});
|
||||
|
||||
EventManager::subscribe<QuerySelection>(this, [this](auto ®ion) {
|
||||
region = Region { this->m_memoryEditor.DataPreviewAddr, (this->m_memoryEditor.DataPreviewAddrEnd - this->m_memoryEditor.DataPreviewAddr) + 1 };
|
||||
u64 address = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
|
||||
size_t size = std::abs(s64(this->m_memoryEditor.DataPreviewAddrEnd) - s64(this->m_memoryEditor.DataPreviewAddr)) + 1;
|
||||
|
||||
region = Region { address, size };
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user