feat: Added option to move selection back to hex editor footer
Closes #2024
This commit is contained in:
parent
3024c79f4f
commit
5f5f6ac539
@ -493,6 +493,7 @@
|
|||||||
"hex.builtin.setting.hex_editor.pattern_parent_highlighting": "Highlight pattern parents on hover",
|
"hex.builtin.setting.hex_editor.pattern_parent_highlighting": "Highlight pattern parents on hover",
|
||||||
"hex.builtin.setting.hex_editor.paste_behaviour": "Single-Byte Paste behaviour",
|
"hex.builtin.setting.hex_editor.paste_behaviour": "Single-Byte Paste behaviour",
|
||||||
"hex.builtin.setting.hex_editor.sync_scrolling": "Synchronize editor scroll position",
|
"hex.builtin.setting.hex_editor.sync_scrolling": "Synchronize editor scroll position",
|
||||||
|
"hex.builtin.setting.hex_editor.show_selection": "Move selection display to hex editor footer",
|
||||||
"hex.builtin.setting.imhex": "ImHex",
|
"hex.builtin.setting.imhex": "ImHex",
|
||||||
"hex.builtin.setting.imhex.recent_files": "Recent Files",
|
"hex.builtin.setting.imhex.recent_files": "Recent Files",
|
||||||
"hex.builtin.setting.interface": "Interface",
|
"hex.builtin.setting.interface": "Interface",
|
||||||
|
@ -834,6 +834,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
ContentRegistry::Settings::add<Widgets::ColorPicker>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60));
|
ContentRegistry::Settings::add<Widgets::ColorPicker>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60));
|
||||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false);
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false);
|
||||||
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.show_selection", false);
|
||||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50);
|
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50);
|
||||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50);
|
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50);
|
||||||
|
|
||||||
|
@ -313,16 +313,6 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ContentRegistry::Interface::addFooterItem([] {
|
|
||||||
if (auto selection = ImHexApi::HexEditor::getSelection(); selection.has_value()) {
|
|
||||||
ImGuiExt::TextFormatted("0x{0:02X} - 0x{1:02X} (0x{2:02X} | {2} bytes)",
|
|
||||||
selection->getStartAddress(),
|
|
||||||
selection->getEndAddress(),
|
|
||||||
selection->getSize()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawProviderContextMenu(prv::Provider *provider) {
|
static void drawProviderContextMenu(prv::Provider *provider) {
|
||||||
|
@ -1110,6 +1110,26 @@ namespace hex::plugin::builtin {
|
|||||||
ContentRegistry::Settings::onChange("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.char_padding", [this](const ContentRegistry::Settings::SettingsValue &value) {
|
ContentRegistry::Settings::onChange("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.char_padding", [this](const ContentRegistry::Settings::SettingsValue &value) {
|
||||||
m_hexEditor.setCharacterCellPadding(value.get<int>(0));
|
m_hexEditor.setCharacterCellPadding(value.get<int>(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static bool showSelectionInWindowFooter = true;
|
||||||
|
ContentRegistry::Settings::onChange("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.show_selection", [this](const ContentRegistry::Settings::SettingsValue &value) {
|
||||||
|
const auto show = value.get<bool>(false);
|
||||||
|
|
||||||
|
m_hexEditor.setShowSelectionInFooter(show);
|
||||||
|
showSelectionInWindowFooter = !show;
|
||||||
|
});
|
||||||
|
|
||||||
|
ContentRegistry::Interface::addFooterItem([] {
|
||||||
|
if (!showSelectionInWindowFooter) return;
|
||||||
|
|
||||||
|
if (auto selection = ImHexApi::HexEditor::getSelection(); selection.has_value()) {
|
||||||
|
ImGuiExt::TextFormatted("0x{0:02X} - 0x{1:02X} (0x{2:02X} | {2} bytes)",
|
||||||
|
selection->getStartAddress(),
|
||||||
|
selection->getEndAddress(),
|
||||||
|
selection->getSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewHexEditor::registerMenuItems() {
|
void ViewHexEditor::registerMenuItems() {
|
||||||
|
@ -90,6 +90,11 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
|||||||
|
|
||||||
registerMainMenuEntries();
|
registerMainMenuEntries();
|
||||||
|
|
||||||
|
addFooterItems();
|
||||||
|
addTitleBarButtons();
|
||||||
|
addToolbarItems();
|
||||||
|
addGlobalUIItems();
|
||||||
|
|
||||||
registerEventHandlers();
|
registerEventHandlers();
|
||||||
registerDataVisualizers();
|
registerDataVisualizers();
|
||||||
registerMiniMapVisualizers();
|
registerMiniMapVisualizers();
|
||||||
@ -122,10 +127,5 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
|||||||
addWindowDecoration();
|
addWindowDecoration();
|
||||||
createWelcomeScreen();
|
createWelcomeScreen();
|
||||||
|
|
||||||
addFooterItems();
|
|
||||||
addTitleBarButtons();
|
|
||||||
addToolbarItems();
|
|
||||||
addGlobalUIItems();
|
|
||||||
|
|
||||||
setupOutOfBoxExperience();
|
setupOutOfBoxExperience();
|
||||||
}
|
}
|
||||||
|
@ -279,6 +279,10 @@ namespace hex::ui {
|
|||||||
m_tooltipCallback = callback;
|
m_tooltipCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setShowSelectionInFooter(bool showSelection) {
|
||||||
|
m_showSelectionInFooter = showSelection;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] i64 getScrollPosition() {
|
[[nodiscard]] i64 getScrollPosition() {
|
||||||
return m_scrollPosition.get();
|
return m_scrollPosition.get();
|
||||||
}
|
}
|
||||||
@ -367,6 +371,7 @@ namespace hex::ui {
|
|||||||
bool m_showAscii = true;
|
bool m_showAscii = true;
|
||||||
bool m_showCustomEncoding = true;
|
bool m_showCustomEncoding = true;
|
||||||
bool m_showMiniMap = false;
|
bool m_showMiniMap = false;
|
||||||
|
bool m_showSelectionInFooter = false;
|
||||||
int m_miniMapWidth = 5;
|
int m_miniMapWidth = 5;
|
||||||
u32 m_byteCellPadding = 0, m_characterCellPadding = 0;
|
u32 m_byteCellPadding = 0, m_characterCellPadding = 0;
|
||||||
bool m_footerCollapsed = true;
|
bool m_footerCollapsed = true;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <algorithm>
|
|
||||||
#include <ui/hex_editor.hpp>
|
#include <ui/hex_editor.hpp>
|
||||||
|
|
||||||
#include <hex/api/content_registry.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
@ -12,6 +11,8 @@
|
|||||||
#include <fonts/vscode_icons.hpp>
|
#include <fonts/vscode_icons.hpp>
|
||||||
#include <hex/providers/buffered_reader.hpp>
|
#include <hex/providers/buffered_reader.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace hex::ui {
|
namespace hex::ui {
|
||||||
|
|
||||||
/* Data Visualizer */
|
/* Data Visualizer */
|
||||||
@ -1075,6 +1076,14 @@ namespace hex::ui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine(0, 15_scaled);
|
||||||
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2_scaled);
|
||||||
|
if (m_mode == Mode::Insert) {
|
||||||
|
ImGui::TextUnformatted("[ INSERT ]");
|
||||||
|
} else {
|
||||||
|
ImGui::Dummy({});
|
||||||
|
}
|
||||||
|
|
||||||
// Collapse button
|
// Collapse button
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
{
|
{
|
||||||
@ -1084,9 +1093,16 @@ namespace hex::ui {
|
|||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
ImGui::SameLine(0, 20_scaled);
|
if (m_showSelectionInFooter && this->isSelectionValid()) {
|
||||||
if (m_mode == Mode::Insert) {
|
const auto selection = this->getSelection();
|
||||||
ImGui::TextUnformatted("[ INSERT ]");
|
|
||||||
|
ImGui::SameLine(0, 15_scaled);
|
||||||
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2_scaled);
|
||||||
|
ImGuiExt::TextFormattedSelectable("0x{0:02X} - 0x{1:02X} (0x{2:02X} | {2} bytes)",
|
||||||
|
selection.getStartAddress(),
|
||||||
|
selection.getEndAddress(),
|
||||||
|
selection.getSize()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_footerCollapsed) {
|
if (!m_footerCollapsed) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user