summaryrefslogtreecommitdiff
path: root/ui/addressindicator.h
diff options
context:
space:
mode:
authorJon Palmisciano <jp@jonpalmisc.com>2022-05-13 12:21:36 -0400
committerJon Palmisciano <jp@jonpalmisc.com>2022-05-16 12:46:32 -0400
commitae60aab3fc9202f761901cdce4196261dcbb3527 (patch)
tree4f0f1b1e811a23b908df6b1acf4e18e7ad35d7a5 /ui/addressindicator.h
parent8cab5619637978732f0736c570562eddbf731b31 (diff)
Improve address indicator UI/UX
Diffstat (limited to 'ui/addressindicator.h')
-rw-r--r--ui/addressindicator.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/ui/addressindicator.h b/ui/addressindicator.h
index 3288de35..4d7d8cf1 100644
--- a/ui/addressindicator.h
+++ b/ui/addressindicator.h
@@ -5,6 +5,31 @@
#include "menus.h"
#include "uicontext.h"
+//! Format for displaying offsets.
+enum class OffsetFormat
+{
+ VirtualAddress,
+ FileStart,
+ SegmentStart,
+ SectionStart,
+ FunctionStart
+};
+
+//! Format for displaying an address range.
+enum class RangeFormat
+{
+ StartOnly,
+ EndOnly,
+ StartAndLength,
+ StartAndEnd
+};
+
+//! Options for displaying an address or address range.
+struct DisplayOptions
+{
+ OffsetFormat format = OffsetFormat::VirtualAddress;
+ RangeFormat rangeFormat = RangeFormat::StartAndEnd;
+};
class BINARYNINJAUIAPI AddressIndicator : public MenuHelper
{
@@ -13,7 +38,25 @@ class BINARYNINJAUIAPI AddressIndicator : public MenuHelper
uint64_t m_begin, m_end;
BinaryViewRef m_view;
- public:
+ DisplayOptions m_options;
+
+ //! Format an offset as a string.
+ //!
+ //! \returns An empty string in case of failure.
+ QString formatOffset(uint64_t, OffsetFormat) const;
+
+ //! Format an address range as a string.
+ //!
+ //! \returns An empty string in case of failure.
+ QString formatRange(uint64_t start, uint64_t end, RangeFormat, OffsetFormat) const;
+
+ //! Create a QAction to copy a formatted offset/range.
+ void addActionForFormat(QMenu*, RangeFormat, OffsetFormat, QString help = "");
+
+ //! Refresh the text displayed in the status bar.
+ void updateDisplay();
+
+public:
AddressIndicator(QWidget* parent);
void clear();