diff options
| author | Rusty Wagner <rusty@vector35.com> | 2019-04-12 14:54:33 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2019-04-12 14:54:33 -0400 |
| commit | 6dc73b519845a361327f5923ca30552d48d21201 (patch) | |
| tree | 793672aebf30e0a9e67075bc9cbed4c5ad6b747b | |
| parent | 8f7901c4709826acc0e53aeea4442b1fb9a25876 (diff) | |
Add multiselect and keyboard navigation to graph view
| -rw-r--r-- | ui/action.h | 1 | ||||
| -rw-r--r-- | ui/assembledialog.h | 6 | ||||
| -rw-r--r-- | ui/commands.h | 2 | ||||
| -rw-r--r-- | ui/flowgraphwidget.h | 26 | ||||
| -rw-r--r-- | ui/render.h | 3 | ||||
| -rw-r--r-- | ui/theme.h | 1 |
6 files changed, 37 insertions, 2 deletions
diff --git a/ui/action.h b/ui/action.h index e61164eb..dbeb06d1 100644 --- a/ui/action.h +++ b/ui/action.h @@ -30,6 +30,7 @@ struct BINARYNINJAUIAPI HighlightTokenState bool addrValid, localVarValid, isDest; uint64_t addr; BinaryNinja::Variable localVar; + size_t tokenIndex; HighlightTokenState(); }; diff --git a/ui/assembledialog.h b/ui/assembledialog.h index 8d1f1c45..7db619a2 100644 --- a/ui/assembledialog.h +++ b/ui/assembledialog.h @@ -12,16 +12,20 @@ class BINARYNINJAUIAPI AssembleDialog: public QDialog BinaryViewRef m_view; uint64_t m_addr; + size_t m_length; QComboBox* m_archSelection; + ArchitectureRef m_fixedArch; DialogTextEdit* m_code; BinaryNinja::DataBuffer m_bytes; bool m_setDefault; public: - AssembleDialog(QWidget* parent, BinaryViewRef data, uint64_t addr, ArchitectureRef prefArch = NULL, const QString& code = ""); + AssembleDialog(QWidget* parent, BinaryViewRef data, uint64_t addr, ArchitectureRef prefArch = NULL, + const QString& code = "", bool fixedArch = false); ArchitectureRef getArchitecture(); const BinaryNinja::DataBuffer& getBytes() const { return m_bytes; } + void setLength(size_t len) { m_length = len; } private Q_SLOTS: void saveOnFinish(int result); diff --git a/ui/commands.h b/ui/commands.h index 0bc7d8f2..dd088850 100644 --- a/ui/commands.h +++ b/ui/commands.h @@ -20,6 +20,8 @@ bool BINARYNINJAUIAPI inputNewType(QWidget* parent, BinaryViewRef data, Function uint64_t currentAddr, HighlightTokenState& highlight); bool BINARYNINJAUIAPI overwriteCode(BinaryViewRef data, ArchitectureRef arch, + uint64_t addr, size_t len, const BinaryNinja::DataBuffer& buffer); +bool BINARYNINJAUIAPI overwriteCode(BinaryViewRef data, ArchitectureRef arch, uint64_t addr, const BinaryNinja::DataBuffer& buffer); StructureRef BINARYNINJAUIAPI getInnerMostStructureContaining( diff --git a/ui/flowgraphwidget.h b/ui/flowgraphwidget.h index 1ebaded2..8418a22c 100644 --- a/ui/flowgraphwidget.h +++ b/ui/flowgraphwidget.h @@ -59,6 +59,7 @@ class BINARYNINJAUIAPI FlowGraphWidget: public QAbstractScrollArea, public View, uint64_t address; size_t instrIndex; size_t lineIndexForAddress; + size_t tokenIndex; }; BinaryViewRef m_data; @@ -88,10 +89,15 @@ class BINARYNINJAUIAPI FlowGraphWidget: public QAbstractScrollArea, public View, bool m_scrollMode; int m_scrollBaseX, m_scrollBaseY; + bool m_mouseSelectMode; - FlowGraphNodeRef m_selectedNode; + FlowGraphNodeRef m_selectedNode, m_selectedEdgeSource; + bool m_selectedEdgeIncoming = false; + std::map<FlowGraphNodeRef, FlowGraphNodeRef> m_selectedEdgeIncomingPriority, m_selectedEdgeOutgoingPriority; + BinaryNinja::FlowGraphEdge m_selectedEdge; CursorPosition m_cursorPos, m_selectionStartPos; HighlightTokenState m_highlight; + bool m_tokenSelection = false; ContextMenuManager m_contextMenuManager; QPointer<CommentDialog> m_commentDialog; @@ -138,6 +144,8 @@ protected: bool getNodeForMouseEvent(QMouseEvent* event, FlowGraphNodeRef& node); bool getLineForMouseEvent(QMouseEvent* event, CursorPosition& pos); + bool getEdgeForMouseEvent(QMouseEvent* event, FlowGraphNodeRef& source, + BinaryNinja::FlowGraphEdge& edge, bool& incoming); HighlightTokenState getTokenForMouseEvent(QMouseEvent* event); void showContextMenu(); @@ -147,6 +155,21 @@ protected: void setGraphInternal(FlowGraphRef graph, FlowGraphHistoryEntry* entry, bool useAddr, uint64_t addr, bool notify); + 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 pageUp(bool selecting); + void pageDown(bool selecting); + void moveToStartOfLine(bool selecting); + void moveToEndOfLine(bool selecting); + void moveToStartOfView(); + void selectAll(); + void selectNone(); + void navigateToHighlightedToken(); + public: FlowGraphWidget(QWidget* parent, BinaryViewRef view, FlowGraphRef graph = FlowGraphRef()); ~FlowGraphWidget(); @@ -214,6 +237,7 @@ public: void showTopNode(); void showNode(FlowGraphNodeRef node); void showLineInNode(FlowGraphNodeRef node, size_t lineIndex); + void ensureCursorVisible(); void viewInTypesView(std::string typeName); diff --git a/ui/render.h b/ui/render.h index 2ae59d63..770326ab 100644 --- a/ui/render.h +++ b/ui/render.h @@ -75,6 +75,9 @@ public: QColor getHighlightColor(BNHighlightColor color); HighlightTokenState getTokenForDisassemblyLinePosition(size_t col, const std::vector<BinaryNinja::InstructionTextToken>& tokens); + HighlightTokenState getTokenForDisassemblyTokenIndex(size_t tokenIndex, + const std::vector<BinaryNinja::InstructionTextToken>& tokens); + HighlightTokenState getHighlightTokenForTextToken(const BinaryNinja::InstructionTextToken& token); void drawText(QPainter& p, int x, int y, QColor color, const QString& text); @@ -55,6 +55,7 @@ enum ThemeColor ImportColor, InstructionHighlightColor, TokenHighlightColor, + TokenSelectionColor, AnnotationColor, OpcodeColor, LinearDisassemblyFunctionHeaderColor, |
