GUI: change the way highlighting works
This commit is contained in:
parent
0f37a07114
commit
ca6166d100
|
|
@ -261,13 +261,26 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
|
|||
//create rich text list
|
||||
RichTextPainter::CustomRichText_t curRichText;
|
||||
curRichText.flags = RichTextPainter::FlagColor;
|
||||
curRichText.textColor = getCellColor(rowBase + rowOffset, col);
|
||||
curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor");
|
||||
QColor textColor = getCellColor(rowBase + rowOffset, col);
|
||||
QColor textBackgroundColor = Qt::transparent;
|
||||
QColor highlightColor = ConfigColor("SearchListViewHighlightColor");
|
||||
QColor highlightBackgroundColor = ConfigColor("SearchListViewHighlightBackgroundColor");
|
||||
curRichText.textColor = textColor;
|
||||
curRichText.underline = false;
|
||||
RichTextPainter::List richText;
|
||||
foreach(QString str, split)
|
||||
{
|
||||
curRichText.text = str;
|
||||
curRichText.highlight = !str.compare(mHighlightText, Qt::CaseInsensitive);
|
||||
if(!str.compare(mHighlightText, Qt::CaseInsensitive))
|
||||
{
|
||||
curRichText.textColor = highlightColor;
|
||||
curRichText.textBackground = highlightBackgroundColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
curRichText.textColor = textColor;
|
||||
curRichText.textBackground = textBackgroundColor;
|
||||
}
|
||||
richText.push_back(curRichText);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
|
|||
|
||||
if(mHighlightingMode)
|
||||
{
|
||||
QPen pen(mInstructionHighlightColor);
|
||||
QPen pen(Qt::red);
|
||||
pen.setWidth(2);
|
||||
painter->setPen(pen);
|
||||
QRect rect = viewport()->rect();
|
||||
|
|
@ -1653,17 +1653,17 @@ RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr, boo
|
|||
auto isReal = realBytes[i].second;
|
||||
RichTextPainter::CustomRichText_t & curByte = richBytes.at(i);
|
||||
DBGRELOCATIONINFO relocInfo;
|
||||
curByte.highlightColor = mDisassemblyRelocationUnderlineColor;
|
||||
curByte.underlineColor = mDisassemblyRelocationUnderlineColor;
|
||||
if(DbgFunctions()->ModRelocationAtAddr(byteAddr, &relocInfo))
|
||||
{
|
||||
bool prevInSameReloc = relocInfo.rva < byteAddr - DbgFunctions()->ModBaseFromAddr(byteAddr);
|
||||
curByte.highlight = isReal;
|
||||
curByte.highlightConnectPrev = i > 0 && prevInSameReloc;
|
||||
curByte.underline = isReal;
|
||||
curByte.underlineConnectPrev = i > 0 && prevInSameReloc;
|
||||
}
|
||||
else
|
||||
{
|
||||
curByte.highlight = false;
|
||||
curByte.highlightConnectPrev = false;
|
||||
curByte.underline = false;
|
||||
curByte.underlineConnectPrev = false;
|
||||
}
|
||||
|
||||
DBGPATCHINFO patchInfo;
|
||||
|
|
@ -1701,10 +1701,10 @@ RichTextPainter::List Disassembly::getRichBytes(const Instruction_t & instr, boo
|
|||
RichTextPainter::CustomRichText_t curByte;
|
||||
curByte.textColor = mBytesColor;
|
||||
curByte.textBackground = mBytesBackgroundColor;
|
||||
curByte.highlightColor = mDisassemblyRelocationUnderlineColor;
|
||||
curByte.highlightWidth = 1;
|
||||
curByte.underlineColor = mDisassemblyRelocationUnderlineColor;
|
||||
curByte.underlineWidth = 1;
|
||||
curByte.flags = RichTextPainter::FlagAll;
|
||||
curByte.highlight = false;
|
||||
curByte.underline = false;
|
||||
curByte.textColor = mBytesColor;
|
||||
curByte.textBackground = mBytesBackgroundColor;
|
||||
curByte.text = "...";
|
||||
|
|
|
|||
|
|
@ -761,16 +761,16 @@ bool HexDump::isSelected(dsint rva) const
|
|||
void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & richText)
|
||||
{
|
||||
RichTextPainter::CustomRichText_t curData;
|
||||
curData.highlight = false;
|
||||
curData.underline = false;
|
||||
curData.flags = RichTextPainter::FlagAll;
|
||||
curData.textColor = mTextColor;
|
||||
curData.textBackground = Qt::transparent;
|
||||
curData.highlightColor = Qt::transparent;
|
||||
curData.underlineColor = Qt::transparent;
|
||||
|
||||
RichTextPainter::CustomRichText_t spaceData;
|
||||
spaceData.highlight = false;
|
||||
spaceData.underline = false;
|
||||
spaceData.flags = RichTextPainter::FlagNone;
|
||||
spaceData.highlightColor = Qt::transparent;
|
||||
spaceData.underlineColor = Qt::transparent;
|
||||
|
||||
if(!col) //address
|
||||
{
|
||||
|
|
@ -822,19 +822,19 @@ void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
|
|||
if(wI % sizeof(duint) == 0 && wByteCount == 1 && desc.data.byteMode == HexByte) //pointer underlining
|
||||
{
|
||||
auto ptr = *(duint*)(wData + wI * wByteCount);
|
||||
if(spaceData.highlight = curData.highlight = DbgMemIsValidReadPtr(ptr))
|
||||
if(spaceData.underline = curData.underline = DbgMemIsValidReadPtr(ptr))
|
||||
{
|
||||
auto codePage = DbgFunctions()->MemIsCodePage(ptr, false);
|
||||
auto modbase = DbgFunctions()->ModBaseFromAddr(ptr);
|
||||
if(modbase)
|
||||
{
|
||||
if(DbgFunctions()->ModGetParty(modbase) == 1) //system
|
||||
spaceData.highlightColor = curData.highlightColor = codePage ? mSystemModuleCodePointerHighlightColor : mSystemModuleDataPointerHighlightColor;
|
||||
spaceData.underlineColor = curData.underlineColor = codePage ? mSystemModuleCodePointerHighlightColor : mSystemModuleDataPointerHighlightColor;
|
||||
else //user
|
||||
spaceData.highlightColor = curData.highlightColor = codePage ? mUserModuleCodePointerHighlightColor : mUserModuleDataPointerHighlightColor;
|
||||
spaceData.underlineColor = curData.underlineColor = codePage ? mUserModuleCodePointerHighlightColor : mUserModuleDataPointerHighlightColor;
|
||||
}
|
||||
else
|
||||
spaceData.highlightColor = curData.highlightColor = codePage ? mUnknownCodePointerHighlightColor : mUnknownDataPointerHighlightColor;
|
||||
spaceData.underlineColor = curData.underlineColor = codePage ? mUnknownCodePointerHighlightColor : mUnknownDataPointerHighlightColor;
|
||||
}
|
||||
}
|
||||
richText.push_back(curData);
|
||||
|
|
@ -842,7 +842,7 @@ void HexDump::getColumnRichText(int col, dsint rva, RichTextPainter::List & rich
|
|||
{
|
||||
spaceData.text = QString(' ');
|
||||
if(wI % sizeof(duint) == sizeof(duint) - 1)
|
||||
spaceData.highlight = false;
|
||||
spaceData.underline = false;
|
||||
richText.push_back(spaceData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -387,9 +387,9 @@ void formatOpcodeString(const Instruction_t & inst, RichTextPainter::List & list
|
|||
RichTextPainter::CustomRichText_t curByte;
|
||||
size_t size = inst.dump.size();
|
||||
assert(list.empty()); //List must be empty before use
|
||||
curByte.highlightWidth = 1;
|
||||
curByte.underlineWidth = 1;
|
||||
curByte.flags = RichTextPainter::FlagAll;
|
||||
curByte.highlight = false;
|
||||
curByte.underline = false;
|
||||
list.reserve(size + 5);
|
||||
realBytes.reserve(size + 5);
|
||||
for(size_t i = 0; i < size; i++)
|
||||
|
|
|
|||
|
|
@ -237,19 +237,27 @@ const Zydis & ZydisTokenizer::GetZydis() const
|
|||
void ZydisTokenizer::TokenToRichText(const InstructionToken & instr, RichTextPainter::List & richTextList, const SingleToken* highlightToken)
|
||||
{
|
||||
QColor highlightColor = ConfigColor("InstructionHighlightColor");
|
||||
QColor highlightBackgroundColor = ConfigColor("InstructionHighlightBackgroundColor");
|
||||
for(const auto & token : instr.tokens)
|
||||
{
|
||||
RichTextPainter::CustomRichText_t richText;
|
||||
richText.highlight = TokenEquals(&token, highlightToken);
|
||||
richText.highlightColor = highlightColor;
|
||||
richText.flags = RichTextPainter::FlagNone;
|
||||
richText.text = token.text;
|
||||
richText.underline = false;
|
||||
if(token.type < TokenType::Last)
|
||||
{
|
||||
const auto & tokenColor = colorNamesMap[int(token.type)];
|
||||
richText.flags = tokenColor.flags;
|
||||
richText.textColor = tokenColor.color;
|
||||
richText.textBackground = tokenColor.backgroundColor;
|
||||
if(TokenEquals(&token, highlightToken))
|
||||
{
|
||||
richText.textColor = highlightColor;
|
||||
richText.textBackground = highlightBackgroundColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
richText.textColor = tokenColor.color;
|
||||
richText.textBackground = tokenColor.backgroundColor;
|
||||
}
|
||||
}
|
||||
richTextList.push_back(richText);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ void AppearanceDialog::colorInfoListInit()
|
|||
|
||||
colorInfoListAppend(tr("Instructions:"), "", "");
|
||||
colorInfoListAppend(tr("Text"), "InstructionUncategorizedColor", "InstructionUncategorizedBackgroundColor");
|
||||
colorInfoListAppend(tr("Highlighting"), "InstructionHighlightColor", "");
|
||||
colorInfoListAppend(tr("Highlighting"), "InstructionHighlightColor", "InstructionHighlightBackgroundColor");
|
||||
colorInfoListAppend(tr("Commas"), "InstructionCommaColor", "InstructionCommaBackgroundColor");
|
||||
colorInfoListAppend(tr("Prefixes"), "InstructionPrefixColor", "InstructionPrefixBackgroundColor");
|
||||
colorInfoListAppend(tr("Addresses"), "InstructionAddressColor", "InstructionAddressBackgroundColor");
|
||||
|
|
@ -549,7 +549,7 @@ void AppearanceDialog::colorInfoListInit()
|
|||
colorInfoListAppend(tr("Memory Map Breakpoint"), "MemoryMapBreakpointColor", "MemoryMapBreakpointBackgroundColor");
|
||||
colorInfoListAppend(tr("Memory Map %1").arg(ArchValue(tr("EIP"), tr("RIP"))), "MemoryMapCipColor", "MemoryMapCipBackgroundColor");
|
||||
colorInfoListAppend(tr("Memory Map Section Text"), "MemoryMapSectionTextColor", "");
|
||||
colorInfoListAppend(tr("Search Highlight Color"), "SearchListViewHighlightColor", "");
|
||||
colorInfoListAppend(tr("Search Highlight Color"), "SearchListViewHighlightColor", "SearchListViewHighlightBackgroundColor");
|
||||
colorInfoListAppend(tr("Struct primary background"), "StructBackgroundColor", "");
|
||||
colorInfoListAppend(tr("Struct secondary background"), "StructAlternateBackgroundColor", "");
|
||||
colorInfoListAppend(tr("Log Link Color") + "*", "LogLinkColor", "LogLinkBackgroundColor");
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ void BreakpointsView::updateBreakpointsSlot()
|
|||
auto colored = [&richSummary](QString text, QColor color)
|
||||
{
|
||||
RichTextPainter::CustomRichText_t token;
|
||||
token.highlight = false;
|
||||
token.underline = false;
|
||||
token.flags = RichTextPainter::FlagColor;
|
||||
token.textColor = color;
|
||||
token.text = text;
|
||||
|
|
@ -303,7 +303,7 @@ void BreakpointsView::updateBreakpointsSlot()
|
|||
auto text = [this, &richSummary](QString text)
|
||||
{
|
||||
RichTextPainter::CustomRichText_t token;
|
||||
token.highlight = false;
|
||||
token.underline = false;
|
||||
token.flags = RichTextPainter::FlagColor;
|
||||
token.textColor = this->mTextColor;
|
||||
token.text = text;
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ void CPUStack::getColumnRichText(int col, dsint rva, RichTextPainter::List & ric
|
|||
|
||||
STACK_COMMENT comment;
|
||||
RichTextPainter::CustomRichText_t curData;
|
||||
curData.highlight = false;
|
||||
curData.underline = false;
|
||||
curData.flags = RichTextPainter::FlagColor;
|
||||
curData.textColor = mTextColor;
|
||||
|
||||
|
|
@ -400,7 +400,8 @@ QString CPUStack::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
|
|||
if(col == 0) // paint stack address
|
||||
{
|
||||
QColor background;
|
||||
if(DbgGetLabelAt(wVa, SEG_DEFAULT, nullptr)) //label
|
||||
char labelText[MAX_LABEL_SIZE] = "";
|
||||
if(DbgGetLabelAt(wVa, SEG_DEFAULT, labelText)) //label
|
||||
{
|
||||
if(wVa == mCsp) //CSP
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2004,7 +2004,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
|||
if(showGraphRva)
|
||||
{
|
||||
RichTextPainter::CustomRichText_t rvaText;
|
||||
rvaText.highlight = false;
|
||||
rvaText.underline = false;
|
||||
rvaText.textColor = mAddressColor;
|
||||
rvaText.textBackground = mAddressBackgroundColor;
|
||||
rvaText.text = QString().number(instrTok.rva, 16).toUpper().trimmed() + " ";
|
||||
|
|
@ -2021,7 +2021,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
|||
QString comment;
|
||||
bool autoComment = false;
|
||||
RichTextPainter::CustomRichText_t commentText;
|
||||
commentText.highlight = false;
|
||||
commentText.underline = false;
|
||||
char label[MAX_LABEL_SIZE] = "";
|
||||
if(GetCommentFormat(addr, comment, &autoComment))
|
||||
{
|
||||
|
|
@ -2048,7 +2048,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
|||
if(commentText.text.length())
|
||||
{
|
||||
RichTextPainter::CustomRichText_t spaceText;
|
||||
spaceText.highlight = false;
|
||||
spaceText.underline = false;
|
||||
spaceText.flags = RichTextPainter::FlagNone;
|
||||
spaceText.text = " ";
|
||||
richText.push_back(spaceText);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public:
|
|||
{
|
||||
RichTextPainter::List richText;
|
||||
RichTextPainter::CustomRichText_t rt;
|
||||
rt.highlight = false;
|
||||
rt.underline = false;
|
||||
rt.text = text;
|
||||
rt.textColor = color;
|
||||
rt.textBackground = background;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ QString ScriptView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
|
|||
int xadd = charwidth; //for testing
|
||||
RichTextPainter::List richText;
|
||||
RichTextPainter::CustomRichText_t newRichText;
|
||||
newRichText.highlight = false;
|
||||
newRichText.underline = false;
|
||||
QString command = getCellContent(rowBase + rowOffset, col);
|
||||
|
||||
//handle comments
|
||||
|
|
@ -296,7 +296,7 @@ QString ScriptView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
|
|||
if(comment.length())
|
||||
{
|
||||
RichTextPainter::CustomRichText_t newRichText;
|
||||
newRichText.highlight = false;
|
||||
newRichText.underline = false;
|
||||
newRichText.flags = RichTextPainter::FlagNone;
|
||||
newRichText.text = " ";
|
||||
richText.push_back(newRichText); //space
|
||||
|
|
|
|||
|
|
@ -124,17 +124,17 @@ RichTextPainter::List TraceBrowser::getRichBytes(const Instruction_t & instr) co
|
|||
auto isReal = realBytes[i].second;
|
||||
RichTextPainter::CustomRichText_t & curByte = richBytes.at(i);
|
||||
DBGRELOCATIONINFO relocInfo;
|
||||
curByte.highlightColor = mDisassemblyRelocationUnderlineColor;
|
||||
curByte.underlineColor = mDisassemblyRelocationUnderlineColor;
|
||||
if(DbgIsDebugging() && DbgFunctions()->ModRelocationAtAddr(cur_addr + byteIdx, &relocInfo))
|
||||
{
|
||||
bool prevInSameReloc = relocInfo.rva < cur_addr + byteIdx - DbgFunctions()->ModBaseFromAddr(cur_addr + byteIdx);
|
||||
curByte.highlight = isReal;
|
||||
curByte.highlightConnectPrev = i > 0 && prevInSameReloc;
|
||||
curByte.underline = isReal;
|
||||
curByte.underlineConnectPrev = i > 0 && prevInSameReloc;
|
||||
}
|
||||
else
|
||||
{
|
||||
curByte.highlight = false;
|
||||
curByte.highlightConnectPrev = false;
|
||||
curByte.underline = false;
|
||||
curByte.underlineConnectPrev = false;
|
||||
}
|
||||
|
||||
curByte.textColor = mBytesColor;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
|||
defaultColors.insert("RegistersHighlightReadWriteColor", QColor("#808000"));
|
||||
|
||||
defaultColors.insert("InstructionHighlightColor", QColor("#FF0000"));
|
||||
defaultColors.insert("InstructionHighlightBackgroundColor", Qt::transparent);
|
||||
defaultColors.insert("InstructionCommaColor", QColor("#000000"));
|
||||
defaultColors.insert("InstructionCommaBackgroundColor", Qt::transparent);
|
||||
defaultColors.insert("InstructionPrefixColor", QColor("#000000"));
|
||||
|
|
@ -237,6 +238,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
|||
defaultColors.insert("MemoryMapCipBackgroundColor", QColor("#000000"));
|
||||
defaultColors.insert("MemoryMapSectionTextColor", QColor("#8B671F"));
|
||||
defaultColors.insert("SearchListViewHighlightColor", QColor("#FF0000"));
|
||||
defaultColors.insert("SearchListViewHighlightBackgroundColor", Qt::transparent);
|
||||
defaultColors.insert("StructBackgroundColor", QColor("#FFF8F0"));
|
||||
defaultColors.insert("StructAlternateBackgroundColor", QColor("#DCD9CF"));
|
||||
defaultColors.insert("LogLinkColor", QColor("#00CC00"));
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QFont>
|
||||
#include "Imports.h"
|
||||
|
||||
// TODO: declare AppearanceDialog and SettingsDialog entries here, so that you only have to do it in once place
|
||||
#define Config() (Configuration::instance())
|
||||
#define ConfigColor(x) (Config()->getColor(x))
|
||||
#define ConfigBool(x,y) (Config()->getBool(x,y))
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ void RichTextPainter::paintRichText(QPainter* painter, int x, int y, int w, int
|
|||
break;
|
||||
}
|
||||
painter->drawText(QRect(x + xinc, y, w - xinc, h), Qt::TextBypassShaping, curRichText.text);
|
||||
if(curRichText.highlight && curRichText.highlightColor.alpha())
|
||||
if(curRichText.underline && curRichText.underlineColor.alpha())
|
||||
{
|
||||
highlightPen.setColor(curRichText.highlightColor);
|
||||
highlightPen.setWidth(curRichText.highlightWidth);
|
||||
highlightPen.setColor(curRichText.underlineColor);
|
||||
highlightPen.setWidth(curRichText.underlineWidth);
|
||||
painter->setPen(highlightPen);
|
||||
int highlightOffsetX = curRichText.highlightConnectPrev ? -1 : 1;
|
||||
int highlightOffsetX = curRichText.underlineConnectPrev ? -1 : 1;
|
||||
painter->drawLine(x + xinc + highlightOffsetX, y + h - 1, x + xinc + backgroundWidth - 1, y + h - 1);
|
||||
}
|
||||
xinc += textWidth;
|
||||
|
|
@ -91,10 +91,10 @@ void RichTextPainter::htmlRichText(const List & richText, QString & textHtml, QS
|
|||
textHtml += QString("<span style=\"color:%1\">").arg(curRichText.textColor.name());
|
||||
break;
|
||||
}
|
||||
if(curRichText.highlight) //Underline highlighted token
|
||||
if(curRichText.underline) //Underline highlighted token
|
||||
textHtml += "<u>";
|
||||
textHtml += curRichText.text.toHtmlEscaped();
|
||||
if(curRichText.highlight)
|
||||
if(curRichText.underline)
|
||||
textHtml += "</u>";
|
||||
textHtml += "</span>"; //Close the tag
|
||||
textPlain += curRichText.text;
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ public:
|
|||
QColor textColor;
|
||||
QColor textBackground;
|
||||
CustomRichTextFlags flags;
|
||||
bool highlight;
|
||||
QColor highlightColor;
|
||||
int highlightWidth = 2;
|
||||
bool highlightConnectPrev = false;
|
||||
bool underline;
|
||||
QColor underlineColor;
|
||||
int underlineWidth = 2;
|
||||
bool underlineConnectPrev = false;
|
||||
};
|
||||
|
||||
typedef std::vector<CustomRichText_t> List;
|
||||
|
|
|
|||
Loading…
Reference in New Issue