mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +00:00
Add highlight to hexdump (#1862)
This commit is contained in:
parent
8ce4700223
commit
a39700f016
@ -4,6 +4,7 @@
|
|||||||
#include "common/Helpers.h"
|
#include "common/Helpers.h"
|
||||||
#include "common/Configuration.h"
|
#include "common/Configuration.h"
|
||||||
#include "common/TempConfig.h"
|
#include "common/TempConfig.h"
|
||||||
|
#include "common/SyntaxHighlighter.h"
|
||||||
#include "core/MainWindow.h"
|
#include "core/MainWindow.h"
|
||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@ -36,7 +37,9 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
|
|||||||
QIcon closeIcon = QIcon(":/img/icons/delete.svg");
|
QIcon closeIcon = QIcon(":/img/icons/delete.svg");
|
||||||
closeButton->setIcon(closeIcon);
|
closeButton->setIcon(closeIcon);
|
||||||
closeButton->setAutoRaise(true);
|
closeButton->setAutoRaise(true);
|
||||||
|
|
||||||
ui->hexSideTab_2->setCornerWidget(closeButton);
|
ui->hexSideTab_2->setCornerWidget(closeButton);
|
||||||
|
syntaxHighLighter = Config()->createSyntaxHighlighter(ui->hexDisasTextEdit->document());
|
||||||
|
|
||||||
ui->openSideViewB->hide(); // hide button at startup since side view is visible
|
ui->openSideViewB->hide(); // hide button at startup since side view is visible
|
||||||
|
|
||||||
@ -215,6 +218,8 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
|
|||||||
// Get selected combos
|
// Get selected combos
|
||||||
QString arch = ui->parseArchComboBox->currentText();
|
QString arch = ui->parseArchComboBox->currentText();
|
||||||
QString bits = ui->parseBitsComboBox->currentText();
|
QString bits = ui->parseBitsComboBox->currentText();
|
||||||
|
QString selectedCommand = "";
|
||||||
|
QString commandResult = "";
|
||||||
bool bigEndian = ui->parseEndianComboBox->currentIndex() == 1;
|
bool bigEndian = ui->parseEndianComboBox->currentIndex() == 1;
|
||||||
|
|
||||||
TempConfig tempConfig;
|
TempConfig tempConfig;
|
||||||
@ -225,41 +230,40 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
|
|||||||
|
|
||||||
switch (ui->parseTypeComboBox->currentIndex()) {
|
switch (ui->parseTypeComboBox->currentIndex()) {
|
||||||
case 0: // Disassembly
|
case 0: // Disassembly
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pda " + argument));
|
selectedCommand = "pda";
|
||||||
break;
|
break;
|
||||||
case 1: // String
|
case 1: // String
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcs " + argument));
|
selectedCommand = "pcs";
|
||||||
break;
|
break;
|
||||||
case 2: // Assembler
|
case 2: // Assembler
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pca " + argument));
|
selectedCommand = "pca";
|
||||||
break;
|
break;
|
||||||
case 3: // C byte array
|
case 3: // C byte array
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pc " + argument));
|
selectedCommand = "pc";
|
||||||
break;
|
break;
|
||||||
case 4: // C half-word
|
case 4: // C half-word
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pch " + argument));
|
selectedCommand = "pch";
|
||||||
break;
|
break;
|
||||||
case 5: // C word
|
case 5: // C word
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcw " + argument));
|
selectedCommand = "pcw";
|
||||||
break;
|
break;
|
||||||
case 6: // C dword
|
case 6: // C dword
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcd " + argument));
|
selectedCommand = "pcd";
|
||||||
break;
|
break;
|
||||||
case 7: // Python
|
case 7: // Python
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcp " + argument));
|
selectedCommand = "pcp";
|
||||||
break;
|
break;
|
||||||
case 8: // JSON
|
case 8: // JSON
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcj " + argument));
|
selectedCommand = "pcj";
|
||||||
break;
|
break;
|
||||||
case 9: // JavaScript
|
case 9: // JavaScript
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcJ " + argument));
|
selectedCommand = "pcJ";
|
||||||
break;
|
break;
|
||||||
case 10: // Yara
|
case 10: // Yara
|
||||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcy " + argument));
|
selectedCommand = "pcy";
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
ui->hexDisasTextEdit->setPlainText("");
|
|
||||||
}
|
}
|
||||||
|
ui->hexDisasTextEdit->setPlainText(selectedCommand != "" ? Core()->cmd(selectedCommand + " " + argument) : "");
|
||||||
} else {
|
} else {
|
||||||
// Fill the information tab hashes and entropy
|
// Fill the information tab hashes and entropy
|
||||||
ui->bytesMD5->setText(Core()->cmd("ph md5 " + argument).trimmed());
|
ui->bytesMD5->setText(Core()->cmd("ph md5 " + argument).trimmed());
|
||||||
|
@ -25,6 +25,7 @@ class HexdumpWidget;
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RefreshDeferrer;
|
class RefreshDeferrer;
|
||||||
|
class QSyntaxHighlighter;
|
||||||
|
|
||||||
class HexdumpWidget : public MemoryDockWidget
|
class HexdumpWidget : public MemoryDockWidget
|
||||||
{
|
{
|
||||||
@ -48,6 +49,7 @@ private:
|
|||||||
bool sent_seek = false;
|
bool sent_seek = false;
|
||||||
|
|
||||||
RefreshDeferrer *refreshDeferrer;
|
RefreshDeferrer *refreshDeferrer;
|
||||||
|
QSyntaxHighlighter *syntaxHighLighter;
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
void refresh(RVA addr);
|
void refresh(RVA addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user