mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 05:45:27 +00:00
Fix FunctionsWidget Tooltip Colors
This commit is contained in:
parent
ce687db26e
commit
9a02dd24a7
@ -2533,19 +2533,11 @@ QList<DisassemblyLine> CutterCore::disassembleLines(RVA offset, int lines)
|
|||||||
offset)).array();
|
offset)).array();
|
||||||
QList<DisassemblyLine> r;
|
QList<DisassemblyLine> r;
|
||||||
|
|
||||||
for (const QJsonValue &value : array) {
|
for (const QJsonValueRef &value : array) {
|
||||||
QJsonObject object = value.toObject();
|
QJsonObject object = value.toObject();
|
||||||
char *html = r_cons_html_filter(object[RJsonKey::text].toString().toUtf8(), nullptr);
|
|
||||||
if (!html) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisassemblyLine line;
|
DisassemblyLine line;
|
||||||
|
|
||||||
line.offset = object[RJsonKey::offset].toVariant().toULongLong();
|
line.offset = object[RJsonKey::offset].toVariant().toULongLong();
|
||||||
line.text = QString::fromUtf8(html);
|
line.text = ansiEscapeToHtml(object[RJsonKey::text].toString());
|
||||||
free (html);
|
|
||||||
|
|
||||||
r << line;
|
r << line;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2629,3 +2621,14 @@ QList<CutterPlugin *> CutterCore::getCutterPlugins()
|
|||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CutterCore::ansiEscapeToHtml(const QString &text)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *html = r_cons_html_filter(text.toUtf8().constData(), &len);
|
||||||
|
if (!html) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
QString r = QString::fromUtf8(html, len);
|
||||||
|
free(html);
|
||||||
|
return r;
|
||||||
|
}
|
@ -730,6 +730,8 @@ public:
|
|||||||
|
|
||||||
RCoreLocked core() const;
|
RCoreLocked core() const;
|
||||||
|
|
||||||
|
static QString ansiEscapeToHtml(const QString &text);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void refreshAll();
|
void refreshAll();
|
||||||
|
|
||||||
|
@ -290,11 +290,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
|||||||
i.size -= 1;
|
i.size -= 1;
|
||||||
|
|
||||||
QTextDocument textDoc;
|
QTextDocument textDoc;
|
||||||
char *html = r_cons_html_filter(op["text"].toString().toUtf8().constData(), nullptr);
|
textDoc.setHtml(CutterCore::ansiEscapeToHtml(op["text"].toString()));
|
||||||
if (html) {
|
|
||||||
textDoc.setHtml(QString::fromUtf8(html));
|
|
||||||
free (html);
|
|
||||||
}
|
|
||||||
|
|
||||||
i.plainText = textDoc.toPlainText();
|
i.plainText = textDoc.toPlainText();
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
return static_cast<int>(Qt::AlignLeft | Qt::AlignVCenter);
|
return static_cast<int>(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
|
||||||
case Qt::ToolTipRole: {
|
case Qt::ToolTipRole: {
|
||||||
QJsonArray jDisasmEntries;
|
QList<DisassemblyLine> disassemblyLines;
|
||||||
{
|
{
|
||||||
// temporarily simplify the disasm output to get it colorful and simple to read
|
// temporarily simplify the disasm output to get it colorful and simple to read
|
||||||
TempConfig tempConfig;
|
TempConfig tempConfig;
|
||||||
@ -209,21 +209,17 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
.set("asm.lines.fcn", false)
|
.set("asm.lines.fcn", false)
|
||||||
.set("asm.lines.out", false)
|
.set("asm.lines.out", false)
|
||||||
.set("asm.lines.bb", false)
|
.set("asm.lines.bb", false)
|
||||||
.set("asm.bbline", false);
|
.set("asm.bbline", false)
|
||||||
|
.set("asm.stackptr", false);
|
||||||
|
|
||||||
jDisasmEntries = Core()->cmdj(QString("pdJ %1 @ %2")
|
disassemblyLines = Core()->disassembleLines(function.offset, kMaxTooltipDisasmPreviewLines + 1);
|
||||||
.arg(kMaxTooltipDisasmPreviewLines + 1)
|
|
||||||
.arg(function.offset)).array();
|
|
||||||
}
|
}
|
||||||
QStringList disasmPreview;
|
QStringList disasmPreview;
|
||||||
for (const QJsonValue &value : jDisasmEntries) {
|
for (const DisassemblyLine &line : disassemblyLines) {
|
||||||
const QJsonObject &object = value.toObject();
|
if (!function.contains(line.offset)) {
|
||||||
|
|
||||||
const RVA insnOffset = object["offset"].toVariant().toULongLong();
|
|
||||||
if (!function.contains(insnOffset)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
disasmPreview << object["text"].toString();
|
disasmPreview << line.text;
|
||||||
if (disasmPreview.length() >= kMaxTooltipDisasmPreviewLines) {
|
if (disasmPreview.length() >= kMaxTooltipDisasmPreviewLines) {
|
||||||
disasmPreview << "...";
|
disasmPreview << "...";
|
||||||
break;
|
break;
|
||||||
|
@ -213,7 +213,7 @@ void HexdumpWidget::setupScrollSync()
|
|||||||
asciiHexFunc);
|
asciiHexFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexdumpWidget::onSeekChanged(RVA addr)
|
void HexdumpWidget::onSeekChanged(RVA)
|
||||||
{
|
{
|
||||||
if (sent_seek) {
|
if (sent_seek) {
|
||||||
sent_seek = false;
|
sent_seek = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user