Added colors to DisassemblyWidget

This commit is contained in:
xarkes 2017-10-22 12:21:44 +02:00
parent 3c6f735832
commit d2c50a803c
10 changed files with 40 additions and 28 deletions

@ -1 +1 @@
Subproject commit 3b2b592506809d4dcfed7c7cff29dd8fa2c2e9d1
Subproject commit 7e063d0b47878f0e9992fcef8756e6a3e29bdba9

View File

@ -60,7 +60,6 @@
#include "widgets/ConsoleWidget.h"
#include "dialogs/OptionsDialog.h"
#include "widgets/EntrypointWidget.h"
#include "widgets/DisassemblerGraphView.h"
#include "dialogs/SaveProjectDialog.h"
// graphics
@ -204,8 +203,8 @@ void MainWindow::initUI()
graphDock = new QDockWidget(tr("Graph"), this);
graphDock->setObjectName("Graph");
graphDock->setAllowedAreas(Qt::AllDockWidgetAreas);
DisassemblerGraphView *gv = new DisassemblerGraphView(graphDock);
graphDock->setWidget(gv);
graphView = new DisassemblerGraphView(graphDock);
graphDock->setWidget(graphView);
dockWidgets.push_back(graphDock);
// Add Sections dock panel

View File

@ -1,15 +1,18 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QList>
#include <memory>
#include "cutter.h" // only needed for ut64
#include "widgets/DisassemblyWidget.h"
#include "widgets/DisassemblerGraphView.h"
#include "widgets/SidebarWidget.h"
#include "widgets/HexdumpWidget.h"
#include "cutter.h" // only needed for ut64
#include "utils/Configuration.h"
#include <QMainWindow>
#include <QList>
class CutterCore;
class DockWidget;
class Omnibar;
@ -34,6 +37,7 @@ class QAction;
class SectionsDock;
class ConsoleWidget;
class EntrypointWidget;
class DisassemblerGraphView;
class QDockWidget;
@ -186,6 +190,7 @@ private:
SidebarWidget *sidebarDock;
HexdumpWidget *hexdumpDock;
QDockWidget *graphDock;
DisassemblerGraphView *graphView;
QDockWidget *asmDock;
QDockWidget *calcDock;
Omnibar *omnibar;

View File

@ -755,7 +755,6 @@ void CutterCore::getOpcodes()
void CutterCore::setSettings()
{
setConfig("scr.color", false);
setConfig("scr.interactive", false);
setConfig("asm.lines", false);
// Intredazting...
@ -805,10 +804,9 @@ void CutterCore::setSettings()
//setConfig("http.root","/usr/local/radare2/osx/share/radare2/1.1.0-git/www");
//setConfig("bin.rawstr", "true");
// Graph colors and design
cmd("ec graph.true rgb:88FF88");
cmd("ec graph.false rgb:FF6666");
cmd("ec graph.trufae rgb:4183D7");
// Colors
setConfig("scr.color", false);
setConfig("scr.truecolor", true);
}
QList<RVA> CutterCore::getSeekHistory()

View File

@ -209,13 +209,16 @@ public:
void analyze(int level, QList<QString> advanced);
// Seek functions
bool graphDisplay = false;
void seek(QString addr);
void seek(ut64 offset);
void seekPrev();
void seekNext();
RVA getOffset();
// Graph - Disassembly view priority
bool graphPriority = true;
bool graphDisplay = false;
ut64 math(const QString &expr);
QString itoa(ut64 num, int rdx = 16);

View File

@ -18,15 +18,15 @@ Configuration* Configuration::instance()
void Configuration::loadDefaultColors()
{
//Core()->cmd("eco behelit");
Core()->cmd("eco smyck");
Core()->cmd("eco cutter");
QJsonObject colors = Core()->cmdj("ecj").object();
for (auto color : colors.keys()) {
QJsonArray rgb = colors[color].toArray();
QColor col = QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
s.setValue("colors." + color, col);
}
//s.setValue("colors.gui.alt_background", QColor(255, 255, 255));
s.setValue("colors.gui.background", QColor(255, 255, 245));
s.setValue("colors.gui.alt_background", QColor(245, 250, 255));
}
const QFont Configuration::getFont() const

View File

@ -1643,11 +1643,9 @@ void DisassemblerGraphView::on_seekChanged(RVA addr)
Q_UNUSED(addr);
loadCurrentGraph();
Function f = this->analysis.functions[this->function];
if (f.blocks.size() > 0) {
Core()->graphDisplay = true;
Core()->graphDisplay = f.blocks.size() > 0;
if (Core()->graphDisplay && Core()->graphPriority) {
this->parentWidget()->raise();
} else {
Core()->graphDisplay = false;
}
this->renderFunction(this->analysis.functions[this->function]);
}
@ -1811,6 +1809,7 @@ void DisassemblerGraphView::followDisassemblerSlot()
void DisassemblerGraphView::colorsUpdatedSlot()
{
disassemblyBackgroundColor = ConfigColor("gui.background");
mDisabledBreakpointColor = disassemblyBackgroundColor;
graphNodeColor = ConfigColor("gui.border");
backgroundColor = ConfigColor("gui.alt_background");
disassemblySelectionColor = ConfigColor("gui.highlight");

View File

@ -288,7 +288,6 @@ public slots:
void seekPrev();
private:
MainWindow* main;
QString status;
Analysis analysis;
duint function;

View File

@ -34,7 +34,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) :
connect(mDisasTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showDisasContextMenu(const QPoint &)));
// x or X to show XRefs
// x to show XRefs
QShortcut *shortcut_x = new QShortcut(QKeySequence(Qt::Key_X), mDisasTextEdit);
shortcut_x->setContext(Qt::WidgetShortcut);
connect(shortcut_x, SIGNAL(activated()), this, SLOT(showXrefsDialog()));
@ -52,6 +52,11 @@ DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) :
this->setWindowTitle(title);
}
QWidget* DisassemblyWidget::getTextWidget()
{
return mDisasTextEdit;
}
void DisassemblyWidget::highlightCurrentLine()
{
QList<QTextEdit::ExtraSelection> extraSelections;
@ -159,7 +164,7 @@ bool DisassemblyWidget::loadMoreDisassembly()
if (offset != RVA_INVALID)
{
CutterCore::getInstance()->seek(offset);
//CutterCore::getInstance()->seek(offset);
QString raw = CutterCore::getInstance()->cmd("pd 200");
QString txt = raw.section("\n", 1, -1);
//this->disasTextEdit->appendPlainText(" ;\n ; New content here\n ;\n " + txt.trimmed());
@ -227,11 +232,14 @@ void DisassemblyWidget::refreshDisasm()
disconnect(mDisasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
disconnect(mDisasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_mDisasTextEdit_cursorPositionChanged()));
QString disas = CutterCore::getInstance()->cmd("pd 200");
Core()->setConfig("scr.html", true);
Core()->setConfig("scr.color", true);
QString disas = Core()->cmd("pd 100");
Core()->setConfig("scr.html", false);
Core()->setConfig("scr.color", false);
mDisasTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
mDisasTextEdit->setPlainText(disas.trimmed());
mDisasTextEdit->setHtml(disas);
auto cursor = mDisasTextEdit->textCursor();
cursor.setPosition(0);
@ -251,7 +259,7 @@ void DisassemblyWidget::refreshDisasm()
connect(mDisasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_mDisasTextEdit_cursorPositionChanged()));
//this->on_mDisasTextEdit_cursorPositionChanged();
this->highlightDisasms();
//this->highlightDisasms();
}
void DisassemblyWidget::on_mDisasTextEdit_cursorPositionChanged()
@ -356,7 +364,7 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)
void DisassemblyWidget::on_seekChanged(RVA offset)
{
Q_UNUSED(offset);
if (!Core()->graphDisplay) {
if (!Core()->graphDisplay || !Core()->graphPriority) {
this->raise();
}
refreshDisasm();

View File

@ -12,6 +12,7 @@ class DisassemblyWidget : public QDockWidget
public:
explicit DisassemblyWidget(QWidget *parent = nullptr);
explicit DisassemblyWidget(const QString &title, QWidget *parent = nullptr);
QWidget* getTextWidget();
signals: