summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2019-05-27 18:11:32 -0400
committerRusty Wagner <rusty@vector35.com>2019-05-27 22:48:55 -0400
commit131952a79f4efebd71117376310f2a8726e118b0 (patch)
tree92b858e36e9c5444886a0b9bf70509e6b1b7effc
parentdbfb178ba212ec513804171346572e7dd0e7d999 (diff)
Add keyboard navigation and selection to linear view
-rw-r--r--ui/linearview.h40
1 files changed, 34 insertions, 6 deletions
diff --git a/ui/linearview.h b/ui/linearview.h
index 9df1aafc..f89465dc 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -14,20 +14,32 @@
#define MAX_STRING_TYPE_LENGTH 1048576
#define EDGE_GUTTER_WIDTH 4
+struct BINARYNINJAUIAPI LinearViewCursorPosition: public BinaryNinja::LinearDisassemblyPosition
+{
+ uint64_t lineAddress;
+ size_t lineIndexForAddress;
+ size_t tokenIndex;
+
+ LinearViewCursorPosition();
+ LinearViewCursorPosition(const LinearViewCursorPosition& pos);
+ LinearViewCursorPosition(const BinaryNinja::LinearDisassemblyPosition& pos);
+};
+
class BINARYNINJAUIAPI LinearViewHistoryEntry: public HistoryEntry
{
- BinaryNinja::LinearDisassemblyPosition m_topPosition, m_cursorPosition;
+ BinaryNinja::LinearDisassemblyPosition m_topPosition;
+ LinearViewCursorPosition m_cursorPosition;
size_t m_topLineOffset;
HighlightTokenState m_highlight;
public:
const BinaryNinja::LinearDisassemblyPosition& getTopPosition() const { return m_topPosition; }
- const BinaryNinja::LinearDisassemblyPosition& getCursorPosition() const { return m_cursorPosition; }
+ const LinearViewCursorPosition& getCursorPosition() const { return m_cursorPosition; }
size_t getTopLineOffset() const { return m_topLineOffset; }
const HighlightTokenState& getHighlightTokenState() const { return m_highlight; }
void setTopPosition(const BinaryNinja::LinearDisassemblyPosition& pos) { m_topPosition = pos; }
- void setCursorPosition(const BinaryNinja::LinearDisassemblyPosition& pos) { m_cursorPosition = pos; }
+ void setCursorPosition(const LinearViewCursorPosition& pos) { m_cursorPosition = pos; }
void setTopLineOffset(size_t offset) { m_topLineOffset = offset; }
void setHighlightTokenState(const HighlightTokenState& state) { m_highlight = state; }
};
@@ -73,9 +85,8 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
bool m_updatesRequired;
bool m_updateBounds, m_updateBlockRef;
- BinaryNinja::LinearDisassemblyPosition m_cursorPosition;
- bool m_cursorPositionHasOffset = false;
- size_t m_cursorPositionOffset = 0;
+ LinearViewCursorPosition m_cursorPosition, m_selectionStartPos;
+ bool m_tokenSelection = false;
HighlightTokenState m_highlight;
uint64_t m_navByRefTarget;
bool m_navByRef = false;
@@ -112,6 +123,9 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ
void setSectionSemantics(const std::string& name, BNSectionSemantics semantics);
+ bool isLineValidHighlight(const BinaryNinja::LinearDisassemblyLine& line);
+ void ensureLineVisible(size_t line);
+
private Q_SLOTS:
void viewInHexEditor();
void viewInGraph();
@@ -216,7 +230,21 @@ protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
+ virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
+
+ void up(bool selecting, size_t count = 1);
+ void down(bool selecting, size_t count = 1);
+ void left(bool selecting);
+ void right(bool selecting);
+ void leftToSymbol(bool selecting);
+ void rightToSymbol(bool selecting);
+ void moveToStartOfLine(bool selecting);
+ void moveToEndOfLine(bool selecting);
+ void moveToStartOfView();
+ void moveToEndOfView();
+ void selectNone();
+ void navigateToHighlightedToken();
};
class LinearViewType: public ViewType