mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-02 02:05:26 +00:00
Use anj for rename X used here
This commit is contained in:
parent
baea88d744
commit
f4e7880152
@ -167,11 +167,20 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
|
|
||||||
|
|
||||||
// only show "rename X used here" if there is something to rename
|
// only show "rename X used here" if there is something to rename
|
||||||
QString thingUsedHere = Core()->cmd("an @ " + QString::number(offset)).trimmed();
|
QJsonArray thingUsedHereArray = Core()->cmdj("anj @ " + QString::number(offset)).array();
|
||||||
if (!thingUsedHere.isEmpty())
|
if (!thingUsedHereArray.isEmpty())
|
||||||
{
|
{
|
||||||
actionRenameUsedHere.setVisible(true);
|
actionRenameUsedHere.setVisible(true);
|
||||||
actionRenameUsedHere.setText(tr("Rename \"%1\" (used here)").arg(thingUsedHere));
|
QJsonObject thingUsedHere = thingUsedHereArray.first().toObject();
|
||||||
|
if (thingUsedHere["type"] == "address")
|
||||||
|
{
|
||||||
|
RVA offset = thingUsedHere["offset"].toVariant().toULongLong();
|
||||||
|
actionRenameUsedHere.setText(tr("Add flag at %1 (used here)").arg(RAddressString(offset)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actionRenameUsedHere.setText(tr("Rename \"%1\" (used here)").arg(thingUsedHere["name"].toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -294,18 +303,37 @@ void DisassemblyContextMenu::on_actionRename_triggered()
|
|||||||
|
|
||||||
void DisassemblyContextMenu::on_actionRenameUsedHere_triggered()
|
void DisassemblyContextMenu::on_actionRenameUsedHere_triggered()
|
||||||
{
|
{
|
||||||
QString thingUsedHere = Core()->cmd("an @ " + QString::number(offset)).trimmed();
|
QJsonArray array = Core()->cmdj("anj @ " + QString::number(offset)).array();
|
||||||
if (thingUsedHere.isEmpty())
|
if (array.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject thingUsedHere = array.first().toObject();
|
||||||
|
QString type = thingUsedHere.value("type").toString();
|
||||||
|
|
||||||
RenameDialog *dialog = new RenameDialog(this);
|
RenameDialog *dialog = new RenameDialog(this);
|
||||||
dialog->setWindowTitle(tr("Rename %1").arg(thingUsedHere));
|
|
||||||
dialog->setName(thingUsedHere);
|
if (type == "address")
|
||||||
if (dialog->exec()) {
|
{
|
||||||
QString new_name = dialog->getName();
|
RVA offset = thingUsedHere["offset"].toVariant().toULongLong();
|
||||||
Core()->cmd("an " + new_name.trimmed() + " @ " + QString::number(offset));
|
dialog->setWindowTitle(tr("Add flag at %1").arg(RAddressString(offset)));
|
||||||
|
dialog->setName("label." + QString::number(offset, 16));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString oldName = thingUsedHere.value("name").toString();
|
||||||
|
dialog->setWindowTitle(tr("Rename %1").arg(oldName));
|
||||||
|
dialog->setName(oldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dialog->exec())
|
||||||
|
{
|
||||||
|
QString newName = dialog->getName().trimmed();
|
||||||
|
if (!newName.isEmpty())
|
||||||
|
{
|
||||||
|
Core()->cmd("an " + newName + " @ " + QString::number(offset));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user