Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/source/user-docs/menus/disassembly-context-menu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ Copy
----------------------------------------
**Description:** Copy the selected text.

**Steps:** Right-click on a selected text and choose ``Copy``
**Steps:** Double click to select word or triple click to select line under cursor.

**Shortcut:** :kbd:`Ctrl` + :kbd:`C`
**Shortcut:** :kbd:`Ctrl` + :kbd:`C`

Jump to address
----------------------------------------
**Description** Jump to the address or function

**Steps** Hold :kbd:`Ctrl` and double click

Copy Address
----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion rizin
Submodule rizin updated 213 files
3 changes: 3 additions & 0 deletions src/menus/AddressableItemContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ AddressableItemContextMenu::AddressableItemContextMenu(QWidget *parent, MainWind
: QMenu(parent), mainWindow(mainWindow)
{
actionShowInMenu = new QAction(tr("Show in"), this);
actionCopyWord = new QAction(tr("Copy word"), this);
actionCopyAddress = new QAction(tr("Copy address"), this);
actionShowXrefs = new QAction(tr("Show X-Refs"), this);
actionAddcomment = new QAction(tr("Add comment"), this);

connect(actionCopyWord, &QAction::triggered, this, &AddressableItemContextMenu::onActionCopyWord);

connect(actionCopyAddress, &QAction::triggered, this,
&AddressableItemContextMenu::onActionCopyAddress);
actionCopyAddress->setShortcuts({ Qt::CTRL | Qt::SHIFT | Qt::Key_C });
Expand Down
2 changes: 2 additions & 0 deletions src/menus/AddressableItemContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public slots:
void xrefsTriggered();

private:
void onActionCopyWord();
void onActionCopyAddress();
void onActionShowXrefs();
void onActionAddComment();
Expand All @@ -44,6 +45,7 @@ public slots:
protected:
void setHasTarget(bool hasTarget);
QAction *actionShowInMenu;
QAction *actionCopyWord;
QAction *actionCopyAddress;
QAction *actionShowXrefs;
QAction *actionAddcomment;
Expand Down
30 changes: 22 additions & 8 deletions src/menus/DisassemblyContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "dialogs/EditStringDialog.h"
#include "dialogs/BreakpointsDialog.h"
#include "MainWindow.h"
#include "DisassemblyWidget.h"

#include <QtCore>
#include <QShortcut>
Expand All @@ -23,13 +24,13 @@
DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *mainWindow)
: QMenu(parent),
offset(0),
canCopy(false),
canCopy(true),
mainWindow(mainWindow),
actionEditInstruction(this),
actionNopInstruction(this),
actionJmpReverse(this),
actionEditBytes(this),
actionCopy(this),
actionCopyWord(this),
actionCopyAddr(this),
actionCopyInstrBytes(this),
actionAddComment(this),
Expand Down Expand Up @@ -70,8 +71,11 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main
actionSetToDataQword(this),
showInSubmenu(this)
{
initAction(&actionCopy, tr("Copy"), SLOT(on_actionCopy_triggered()), getCopySequence());
addAction(&actionCopy);
// initAction(&actionCopy, tr("Copy"), SLOT(on_actionCopy_triggered()), getCopySequence());
// addAction(&actionCopy);
//
initAction(&actionCopyWord, tr("Copy word"), SLOT(on_actionCopyWord_triggered()), getCopySequence());
addAction(&actionCopyWord);

initAction(&actionCopyAddr, tr("Copy address"), SLOT(on_actionCopyAddr_triggered()),
getCopyAddressSequence());
Expand Down Expand Up @@ -578,8 +582,8 @@ void DisassemblyContextMenu::aboutToShowSlot()
actionAddComment.setText(tr("Edit Comment"));
}

actionCopy.setVisible(canCopy);
copySeparator->setVisible(canCopy);
// actionCopy.setVisible(canCopy);
// copySeparator->setVisible(canCopy);

// Handle renaming of variable, function, flag, ...
// Note: This might be useless if we consider setCurrentHighlightedWord is always called before
Expand Down Expand Up @@ -792,9 +796,19 @@ void DisassemblyContextMenu::on_actionEditBytes_triggered()
}
}

void DisassemblyContextMenu::on_actionCopy_triggered()
//void DisassemblyContextMenu::on_actionCopy_triggered()
//{
// emit copy();
//}

void DisassemblyContextMenu::on_actionCopyWord_triggered()
{
emit copy();
DisassemblyWidget* disassemblyWidget = dynamic_cast<DisassemblyWidget*>(parentWidget());
if (disassemblyWidget != nullptr) {
const QString& text = disassemblyWidget->getCurrentHighlightedWord();
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(text);
}
}

void DisassemblyContextMenu::on_actionCopyAddr_triggered()
Expand Down
6 changes: 4 additions & 2 deletions src/menus/DisassemblyContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ private slots:
void on_actionEditBytes_triggered();
void showReverseJmpQuery();

void on_actionCopy_triggered();
// void on_actionCopy_triggered();
void on_actionCopyWord_triggered();
void on_actionCopyAddr_triggered();
void on_actionCopyInstrBytes_triggered();
void on_actionAddComment_triggered();
Expand Down Expand Up @@ -110,7 +111,8 @@ private slots:
QAction actionJmpReverse;
QAction actionEditBytes;

QAction actionCopy;
// QAction actionCopy;
QAction actionCopyWord;
QAction *copySeparator;
QAction actionCopyAddr;
QAction actionCopyInstrBytes;
Expand Down
17 changes: 15 additions & 2 deletions src/widgets/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QPainter>
#include <QPainterPath>
#include <QSplitter>
#include <QClipboard>

#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -168,6 +169,8 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main)

ADD_ACTION(Qt::Key_Escape, Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::seekPrev)

ADD_ACTION(Qt::CopyAction, Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::copyHighlightedWord)

ADD_ACTION(Qt::Key_J, Qt::WidgetWithChildrenShortcut,
[this]() { moveCursorRelative(false, false); })
ADD_ACTION(QKeySequence::MoveToNextLine, Qt::WidgetWithChildrenShortcut,
Expand Down Expand Up @@ -661,7 +664,14 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)

void DisassemblyWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Return) {
qDebug() << event->key();
qDebug() << event->modifiers();
if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier)) {
// If there is selected text in the text edit, copy it
if (!mDisasTextEdit->textCursor().selectedText().isEmpty()) {
mDisasTextEdit->copy();
}
} else if (event->key() == Qt::Key_Return) {
const QTextCursor cursor = mDisasTextEdit->textCursor();
jumpToOffsetUnderCursor(cursor);
}
Expand Down Expand Up @@ -786,7 +796,6 @@ void DisassemblyTextEdit::scrollContentsBy(int dx, int dy)
void DisassemblyTextEdit::keyPressEvent(QKeyEvent *event)
{
Q_UNUSED(event)
// QPlainTextEdit::keyPressEvent(event);
}

void DisassemblyTextEdit::mousePressEvent(QMouseEvent *event)
Expand All @@ -803,6 +812,10 @@ void DisassemblyWidget::seekPrev()
Core()->seekPrev();
}

void DisassemblyWidget::copyHighlightedWord() {
qDebug() << "success!";
}

/*********************
* Left panel
*********************/
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/DisassemblyWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class DisassemblyWidget : public MemoryDockWidget
public:
explicit DisassemblyWidget(MainWindow *main);
QWidget *getTextWidget();
const QString& getCurrentHighlightedWord() const { return curHighlightedWord; }

static QString getWidgetType();

Expand Down Expand Up @@ -103,6 +104,7 @@ protected slots:
void moveCursorRelative(bool up, bool page);

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

class DisassemblyScrollArea : public QAbstractScrollArea
Expand Down