mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Implement Seek to start/end of function Shortcuts (#1589)
* fix ctrl+'+' to zoom in` * Add '^' and '$' shortcuts
This commit is contained in:
parent
53756f29d2
commit
c141eb34cc
@ -826,6 +826,47 @@ RAnalFunction *CutterCore::functionAt(ut64 addr)
|
|||||||
return r_anal_get_fcn_in(core_->anal, addr, 0);
|
return r_anal_get_fcn_in(core_->anal, addr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief finds the start address of a function in a given address
|
||||||
|
* @param addr - an address which belongs to a function
|
||||||
|
* @returns if function exists, return its start address. Otherwise return RVA_INVALID
|
||||||
|
*/
|
||||||
|
RVA CutterCore::getFunctionStart(RVA addr)
|
||||||
|
{
|
||||||
|
CORE_LOCK();
|
||||||
|
RAnalFunction *fcn = Core()->functionAt(addr);
|
||||||
|
return fcn ? fcn->addr : RVA_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief finds the end address of a function in a given address
|
||||||
|
* @param addr - an address which belongs to a function
|
||||||
|
* @returns if function exists, return its end address. Otherwise return RVA_INVALID
|
||||||
|
*/
|
||||||
|
RVA CutterCore::getFunctionEnd(RVA addr)
|
||||||
|
{
|
||||||
|
CORE_LOCK();
|
||||||
|
RAnalFunction *fcn = Core()->functionAt(addr);
|
||||||
|
return fcn ? fcn->addr : RVA_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief finds the last instruction of a function in a given address
|
||||||
|
* @param addr - an address which belongs to a function
|
||||||
|
* @returns if function exists, return the address of its last instruction. Otherwise return RVA_INVALID
|
||||||
|
*/
|
||||||
|
RVA CutterCore::getLastFunctionInstruction(RVA addr)
|
||||||
|
{
|
||||||
|
CORE_LOCK();
|
||||||
|
RAnalFunction *fcn = Core()->functionAt(addr);
|
||||||
|
if (!fcn) {
|
||||||
|
return RVA_INVALID;
|
||||||
|
}
|
||||||
|
RAnalBlock *lastBB = (RAnalBlock *)r_list_last(fcn->bbs);
|
||||||
|
return lastBB ? lastBB->addr + r_anal_bb_offset_inst(lastBB, lastBB->ninstr-1) : RVA_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
QString CutterCore::cmdFunctionAt(QString addr)
|
QString CutterCore::cmdFunctionAt(QString addr)
|
||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
|
@ -77,6 +77,9 @@ public:
|
|||||||
void delFunction(RVA addr);
|
void delFunction(RVA addr);
|
||||||
void renameFlag(QString old_name, QString new_name);
|
void renameFlag(QString old_name, QString new_name);
|
||||||
RAnalFunction *functionAt(ut64 addr);
|
RAnalFunction *functionAt(ut64 addr);
|
||||||
|
RVA getFunctionStart(RVA addr);
|
||||||
|
RVA getFunctionEnd(RVA addr);
|
||||||
|
RVA getLastFunctionInstruction(RVA addr);
|
||||||
QString cmdFunctionAt(QString addr);
|
QString cmdFunctionAt(QString addr);
|
||||||
QString cmdFunctionAt(RVA addr);
|
QString cmdFunctionAt(RVA addr);
|
||||||
QString createFunctionAt(RVA addr, QString name);
|
QString createFunctionAt(RVA addr, QString name);
|
||||||
|
@ -140,6 +140,10 @@ void MainWindow::initUI()
|
|||||||
connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
||||||
QShortcut *seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
|
QShortcut *seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
|
||||||
connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
||||||
|
QShortcut *seek_to_func_end_shortcut = new QShortcut(QKeySequence(Qt::Key_Dollar), this);
|
||||||
|
connect(seek_to_func_end_shortcut, SIGNAL(activated()), SLOT(seekToFunctionLastInstruction()));
|
||||||
|
QShortcut *seek_to_func_start_shortcut = new QShortcut(QKeySequence(Qt::Key_AsciiCircum), this);
|
||||||
|
connect(seek_to_func_start_shortcut, SIGNAL(activated()), SLOT(seekToFunctionStart()));
|
||||||
|
|
||||||
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
|
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
|
||||||
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
|
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
|
||||||
@ -1141,6 +1145,15 @@ void MainWindow::on_actionGrouped_dock_dragging_triggered(bool checked)
|
|||||||
setDockOptions(options);
|
setDockOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::seekToFunctionLastInstruction()
|
||||||
|
{
|
||||||
|
Core()->seek(Core()->getLastFunctionInstruction(Core()->getOffset()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::seekToFunctionStart()
|
||||||
|
{
|
||||||
|
Core()->seek(Core()->getFunctionStart(Core()->getOffset()));
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::projectSaved(bool successfully, const QString &name)
|
void MainWindow::projectSaved(bool successfully, const QString &name)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,8 @@ public slots:
|
|||||||
void finalizeOpen();
|
void finalizeOpen();
|
||||||
|
|
||||||
void refreshAll();
|
void refreshAll();
|
||||||
|
void seekToFunctionLastInstruction();
|
||||||
|
void seekToFunctionStart();
|
||||||
void setPanelLock();
|
void setPanelLock();
|
||||||
void setTabLocation();
|
void setTabLocation();
|
||||||
|
|
||||||
|
@ -182,7 +182,11 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
|||||||
ADD_ACTION(QKeySequence::MoveToPreviousPage, Qt::WidgetWithChildrenShortcut, [this]() {
|
ADD_ACTION(QKeySequence::MoveToPreviousPage, Qt::WidgetWithChildrenShortcut, [this]() {
|
||||||
moveCursorRelative(true, true);
|
moveCursorRelative(true, true);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Plus sign in num-bar considered "Qt::Key_Equal"
|
||||||
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Equal), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomIn)
|
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Equal), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomIn)
|
||||||
|
// Plus sign in numpad
|
||||||
|
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Plus), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomIn)
|
||||||
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Minus), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomOut)
|
ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Minus), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomOut)
|
||||||
#undef ADD_ACTION
|
#undef ADD_ACTION
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user