Skip to content

Commit

Permalink
Fix "return" key in disassembler widget (rizinorg#3090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yappa committed Feb 23, 2023
1 parent 68ec5a3 commit a34fa40
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/common/DisassemblyPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,13 @@ RVA DisassemblyPreview::readDisassemblyOffset(QTextCursor tc)

return userData->line.offset;
}

RVA DisassemblyPreview::readDisassemblyArrow(QTextCursor tc)
{
auto userData = getUserData(tc.block());
if (!userData && userData->line.arrow != RVA_INVALID) {
return RVA_INVALID;
}

return userData->line.arrow;
}
6 changes: 6 additions & 0 deletions src/common/DisassemblyPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ bool showDisasPreview(QWidget *parent, const QPoint &pointOfEvent, const RVA off
* @return The disassembly offset of the hovered asm text
*/
RVA readDisassemblyOffset(QTextCursor tc);

/*!
* @brief Reads the arrow offset for the cursor position
* @return The jump address of the hovered asm text
*/
RVA readDisassemblyArrow(QTextCursor tc);
}
#endif
8 changes: 7 additions & 1 deletion src/widgets/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ void DisassemblyWidget::jumpToOffsetUnderCursor(const QTextCursor &cursor)
seekable->seekToReference(offset);
}

void DisassemblyWidget::jumpToArrowOffsetUnderCursor(const QTextCursor &cursor)
{
RVA offset = DisassemblyPreview::readDisassemblyArrow(cursor);
seekable->seek(offset);
}

bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonDblClick
Expand Down Expand Up @@ -647,7 +653,7 @@ void DisassemblyWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Return) {
const QTextCursor cursor = mDisasTextEdit->textCursor();
jumpToOffsetUnderCursor(cursor);
jumpToArrowOffsetUnderCursor(cursor);
}

MemoryDockWidget::keyPressEvent(event);
Expand Down
1 change: 1 addition & 0 deletions src/widgets/DisassemblyWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ protected slots:
void moveCursorRelative(bool up, bool page);

void jumpToOffsetUnderCursor(const QTextCursor &);
void jumpToArrowOffsetUnderCursor(const QTextCursor &);
};

class DisassemblyScrollArea : public QAbstractScrollArea
Expand Down

0 comments on commit a34fa40

Please sign in to comment.