1
0
Fork 0

GUI: resolved issue #229 (automatic comments have a different color)

This commit is contained in:
Mr. eXoDia 2014-12-26 14:43:20 +01:00
parent 842469eff4
commit 0bccbd0c0d
5 changed files with 52 additions and 9 deletions

View File

@ -380,13 +380,28 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(rvaToVa(mInstBuffer.at(rowOffset).rva), comment))
{
painter->setPen(ConfigColor("DisassemblyCommentColor"));
int width = getCharWidth() * QString(comment).length() + 4;
QString commentText;
QColor penColor;
QColor backgroundColor;
if(comment[0] == '\1') //automatic comment
{
penColor = ConfigColor("DisassemblyAutoCommentColor");
backgroundColor = ConfigColor("DisassemblyAutoCommentBackgroundColor");
commentText = QString(comment + 1);
}
else //user comment
{
penColor = ConfigColor("DisassemblyCommentColor");
backgroundColor = ConfigColor("DisassemblyCommentBackgroundColor");
commentText = comment;
}
painter->setPen(penColor);
int width = getCharWidth() * commentText.length() + 4;
if(width > w)
width = w;
if(width)
painter->fillRect(QRect(x + 2, y, width, h), QBrush(ConfigColor("DisassemblyCommentBackgroundColor"))); //fill bookmark color
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, QString(comment));
painter->fillRect(QRect(x + 2, y, width, h), QBrush(backgroundColor)); //fill comment color
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, commentText);
}
}
break;

View File

@ -428,6 +428,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend("Hardware Breakpoints", "DisassemblyHardwareBreakpointColor", "DisassemblyHardwareBreakpointBackgroundColor");
colorInfoListAppend("Bookmarks", "DisassemblyBookmarkColor", "DisassemblyBookmarkBackgroundColor");
colorInfoListAppend("Comments", "DisassemblyCommentColor", "DisassemblyCommentBackgroundColor");
colorInfoListAppend("Automatic Comments", "DisassemblyAutoCommentColor", "DisassemblyAutoCommentBackgroundColor");
colorInfoListAppend("Labels", "DisassemblyLabelColor", "DisassemblyLabelBackgroundColor");
colorInfoListAppend("Addresses", "DisassemblyAddressColor", "DisassemblyAddressBackgroundColor");
colorInfoListAppend("Selected Addresses", "DisassemblySelectedAddressColor", "DisassemblySelectedAddressBackgroundColor");

View File

@ -97,7 +97,12 @@ void BreakpointsView::reloadData()
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
mHardBPTable->setCellContent(wI, 4, comment);
{
if(comment[0] == '\1') //automatic comment
mHardBPTable->setCellContent(wI, 4, QString(comment + 1));
else
mHardBPTable->setCellContent(wI, 4, comment);
}
}
mHardBPTable->reloadData();
if(wBPList.count)
@ -129,7 +134,12 @@ void BreakpointsView::reloadData()
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
mSoftBPTable->setCellContent(wI, 4, comment);
{
if(comment[0] == '\1') //automatic comment
mSoftBPTable->setCellContent(wI, 4, QString(comment + 1));
else
mSoftBPTable->setCellContent(wI, 4, comment);
}
}
mSoftBPTable->reloadData();
if(wBPList.count)
@ -161,7 +171,12 @@ void BreakpointsView::reloadData()
char comment[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt(wBPList.bp[wI].addr, comment))
mMemBPTable->setCellContent(wI, 4, comment);
{
if(comment[0] == '\1') //automatic comment
mMemBPTable->setCellContent(wI, 4, QString(comment + 1));
else
mMemBPTable->setCellContent(wI, 4, comment);
}
}
mMemBPTable->reloadData();
if(wBPList.count)

View File

@ -708,7 +708,12 @@ void CPUDisassembly::setComment()
QString addr_text = QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char comment_text[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt((duint)wVA, comment_text))
mLineEdit.setText(QString(comment_text));
{
if(comment_text[0] == '\1') //automatic comment
mLineEdit.setText(QString(comment_text + 1));
else
mLineEdit.setText(QString(comment_text));
}
mLineEdit.setWindowTitle("Add comment at " + addr_text);
if(mLineEdit.exec() != QDialog::Accepted)
return;
@ -1160,7 +1165,12 @@ void CPUDisassembly::copySelection(bool copyBytes)
char comment[MAX_COMMENT_SIZE] = "";
QString fullComment;
if(DbgGetCommentAt(cur_addr, comment))
fullComment = " ;" + QString(comment);
{
if(comment[0] == '\1') //automatic comment
fullComment = " ;" + QString(comment + 1);
else
fullComment = " ;" + QString(comment);
}
clipboard += address.leftJustified(addressLen, QChar(' '), true);
if(copyBytes)
clipboard += " | " + bytes.leftJustified(bytesLen, QChar(' '), true);

View File

@ -39,6 +39,8 @@ Configuration::Configuration() : QObject()
defaultColors.insert("DisassemblyModifiedBytesColor", QColor("#FF0000"));
defaultColors.insert("DisassemblyCommentColor", QColor("#000000"));
defaultColors.insert("DisassemblyCommentBackgroundColor", Qt::transparent);
defaultColors.insert("DisassemblyAutoCommentColor", QColor("#808080"));
defaultColors.insert("DisassemblyAutoCommentBackgroundColor", Qt::transparent);
defaultColors.insert("SideBarCipLabelColor", QColor("#FFFFFF"));
defaultColors.insert("SideBarCipLabelBackgroundColor", QColor("#4040FF"));