mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +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();
|
||||
QList<DisassemblyLine> r;
|
||||
|
||||
for (const QJsonValue &value : array) {
|
||||
for (const QJsonValueRef &value : array) {
|
||||
QJsonObject object = value.toObject();
|
||||
char *html = r_cons_html_filter(object[RJsonKey::text].toString().toUtf8(), nullptr);
|
||||
if (!html) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DisassemblyLine line;
|
||||
|
||||
line.offset = object[RJsonKey::offset].toVariant().toULongLong();
|
||||
line.text = QString::fromUtf8(html);
|
||||
free (html);
|
||||
|
||||
line.text = ansiEscapeToHtml(object[RJsonKey::text].toString());
|
||||
r << line;
|
||||
}
|
||||
|
||||
@ -2629,3 +2621,14 @@ QList<CutterPlugin *> CutterCore::getCutterPlugins()
|
||||
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;
|
||||
|
||||
static QString ansiEscapeToHtml(const QString &text);
|
||||
|
||||
signals:
|
||||
void refreshAll();
|
||||
|
||||
|
@ -290,11 +290,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
||||
i.size -= 1;
|
||||
|
||||
QTextDocument textDoc;
|
||||
char *html = r_cons_html_filter(op["text"].toString().toUtf8().constData(), nullptr);
|
||||
if (html) {
|
||||
textDoc.setHtml(QString::fromUtf8(html));
|
||||
free (html);
|
||||
}
|
||||
textDoc.setHtml(CutterCore::ansiEscapeToHtml(op["text"].toString()));
|
||||
|
||||
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);
|
||||
|
||||
case Qt::ToolTipRole: {
|
||||
QJsonArray jDisasmEntries;
|
||||
QList<DisassemblyLine> disassemblyLines;
|
||||
{
|
||||
// temporarily simplify the disasm output to get it colorful and simple to read
|
||||
TempConfig tempConfig;
|
||||
@ -209,21 +209,17 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
.set("asm.lines.fcn", false)
|
||||
.set("asm.lines.out", 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")
|
||||
.arg(kMaxTooltipDisasmPreviewLines + 1)
|
||||
.arg(function.offset)).array();
|
||||
disassemblyLines = Core()->disassembleLines(function.offset, kMaxTooltipDisasmPreviewLines + 1);
|
||||
}
|
||||
QStringList disasmPreview;
|
||||
for (const QJsonValue &value : jDisasmEntries) {
|
||||
const QJsonObject &object = value.toObject();
|
||||
|
||||
const RVA insnOffset = object["offset"].toVariant().toULongLong();
|
||||
if (!function.contains(insnOffset)) {
|
||||
for (const DisassemblyLine &line : disassemblyLines) {
|
||||
if (!function.contains(line.offset)) {
|
||||
break;
|
||||
}
|
||||
disasmPreview << object["text"].toString();
|
||||
disasmPreview << line.text;
|
||||
if (disasmPreview.length() >= kMaxTooltipDisasmPreviewLines) {
|
||||
disasmPreview << "...";
|
||||
break;
|
||||
|
@ -213,7 +213,7 @@ void HexdumpWidget::setupScrollSync()
|
||||
asciiHexFunc);
|
||||
}
|
||||
|
||||
void HexdumpWidget::onSeekChanged(RVA addr)
|
||||
void HexdumpWidget::onSeekChanged(RVA)
|
||||
{
|
||||
if (sent_seek) {
|
||||
sent_seek = false;
|
||||
|
Loading…
Reference in New Issue
Block a user