mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 21:56:06 +00:00
Pressing Enter in disassembly will jump to the desired location (#1910)
* Implemented processing of 'Return' key in the disassembly widget * renamed method in the DisasmWidget
This commit is contained in:
parent
53452726ac
commit
3700bc63f5
@ -614,35 +614,50 @@ void DisassemblyWidget::moveCursorRelative(bool up, bool page)
|
||||
}
|
||||
}
|
||||
|
||||
void DisassemblyWidget::jumpToOffsetUnderCursor(const QTextCursor &cursor)
|
||||
{
|
||||
RVA offset = readDisassemblyOffset(cursor);
|
||||
RVA jump = Core()->getOffsetJump(offset);
|
||||
|
||||
if (jump == RVA_INVALID) {
|
||||
bool ok;
|
||||
RVA xref = Core()->cmdj("axfj@" + QString::number(
|
||||
offset)).array().first().toObject().value("to").toVariant().toULongLong(&ok);
|
||||
if (ok) {
|
||||
jump = xref;
|
||||
}
|
||||
}
|
||||
|
||||
if (jump != RVA_INVALID) {
|
||||
seekable->seek(jump);
|
||||
}
|
||||
}
|
||||
|
||||
bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonDblClick
|
||||
&& (obj == mDisasTextEdit || obj == mDisasTextEdit->viewport())) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
|
||||
QTextCursor cursor = mDisasTextEdit->cursorForPosition(QPoint(mouseEvent->x(), mouseEvent->y()));
|
||||
RVA offset = readDisassemblyOffset(cursor);
|
||||
|
||||
RVA jump = Core()->getOffsetJump(offset);
|
||||
|
||||
if (jump == RVA_INVALID) {
|
||||
bool ok;
|
||||
RVA xref = Core()->cmdj("axfj@" + QString::number(
|
||||
offset)).array().first().toObject().value("to").toVariant().toULongLong(&ok);
|
||||
if (ok) {
|
||||
jump = xref;
|
||||
}
|
||||
}
|
||||
|
||||
if (jump != RVA_INVALID) {
|
||||
seekable->seek(jump);
|
||||
}
|
||||
const QTextCursor& cursor = mDisasTextEdit->cursorForPosition(QPoint(mouseEvent->x(), mouseEvent->y()));
|
||||
jumpToOffsetUnderCursor(cursor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return MemoryDockWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void DisassemblyWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->key() == Qt::Key_Return) {
|
||||
const QTextCursor cursor = mDisasTextEdit->textCursor();
|
||||
jumpToOffsetUnderCursor(cursor);
|
||||
}
|
||||
|
||||
MemoryDockWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
QString DisassemblyWidget::getWindowTitle() const
|
||||
{
|
||||
return tr("Disassembly");
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
RVA readCurrentDisassemblyOffset();
|
||||
RVA readDisassemblyOffset(QTextCursor tc);
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
QString getWindowTitle() const override;
|
||||
|
||||
QList<RVA> breakpoints;
|
||||
@ -84,6 +85,8 @@ private:
|
||||
void connectCursorPositionChanged(bool disconnect);
|
||||
|
||||
void moveCursorRelative(bool up, bool page);
|
||||
|
||||
void jumpToOffsetUnderCursor(const QTextCursor&);
|
||||
};
|
||||
|
||||
class DisassemblyScrollArea : public QAbstractScrollArea
|
||||
|
Loading…
Reference in New Issue
Block a user