From b9324f44e63f4cd845aa35e6fc27dd1aec822c60 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 21 Dec 2020 15:20:57 +0100 Subject: [PATCH] Added selected addresses to hex editor footer This (and the two previous commits) fixes #99 --- libs/ImGui/include/imgui_memory_editor.h | 12 ++++++++++++ source/views/view_hexeditor.cpp | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libs/ImGui/include/imgui_memory_editor.h b/libs/ImGui/include/imgui_memory_editor.h index de81d4edc..d6034e930 100644 --- a/libs/ImGui/include/imgui_memory_editor.h +++ b/libs/ImGui/include/imgui_memory_editor.h @@ -547,6 +547,7 @@ struct MemoryEditor IM_UNUSED(mem_data); ImGuiStyle& style = ImGui::GetStyle(); const char* format_range = OptUpperCaseHex ? "Range %0*" _PRISizeT "X..%0*" _PRISizeT "X" : "Range %0*" _PRISizeT "x..%0*" _PRISizeT "x"; + const char* format_selection = OptUpperCaseHex ? "Selection %0*" _PRISizeT "X..%0*" _PRISizeT "X (%ld %s)" : "Range %0*" _PRISizeT "x..%0*" _PRISizeT "x (%ld %s)"; // Options menu if (ImGui::Button("Options")) @@ -566,6 +567,17 @@ struct MemoryEditor ImGui::SameLine(); ImGui::Text(format_range, s.AddrDigitsCount, base_display_addr, s.AddrDigitsCount, base_display_addr + mem_size - 1); + if (DataPreviewAddr != (size_t)-1 && DataPreviewAddrEnd != (size_t)-1) { + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); + + auto selectionStart = std::min(DataPreviewAddr, DataPreviewAddrEnd); + auto selectionEnd = std::max(DataPreviewAddr, DataPreviewAddrEnd); + + size_t regionSize = (selectionEnd - selectionStart) + 1; + ImGui::Text(format_selection, s.AddrDigitsCount, selectionStart, s.AddrDigitsCount, selectionEnd, regionSize, regionSize == 1 ? "byte" : "bytes"); + } if (GotoAddr != (size_t)-1) { diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index 81b72405c..b76d8cd29 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -109,6 +109,8 @@ namespace hex { if (dataSize != 0x00) { ImGui::Begin("Hex Editor"); ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); ImGui::Text("Page %d / %d", this->m_dataProvider->getCurrentPage() + 1, this->m_dataProvider->getPageCount()); ImGui::SameLine();