Fix #252 - select all lines with the selected offset (#673)

This commit is contained in:
fcasal 2018-09-05 13:47:09 +01:00 committed by xarkes
parent 66dcaea5bb
commit 95a7d5f210

View File

@ -231,7 +231,7 @@ void DisassemblyWidget::refreshDisasm(RVA offset)
break; break;
} }
cursor.insertHtml(line.text); cursor.insertHtml(line.text);
if(Core()->isBreakpoint(breakpoints,line.offset)) { if(Core()->isBreakpoint(breakpoints, line.offset)) {
QTextBlockFormat f; QTextBlockFormat f;
f.setBackground(ConfigColor("gui.breakpoint_background")); f.setBackground(ConfigColor("gui.breakpoint_background"));
cursor.setBlockFormat(f); cursor.setBlockFormat(f);
@ -325,14 +325,6 @@ void DisassemblyWidget::highlightCurrentLine()
QColor highlightWordCurrentLineColor = ConfigColor("gui.background"); QColor highlightWordCurrentLineColor = ConfigColor("gui.background");
highlightWordCurrentLineColor.setAlpha(128); highlightWordCurrentLineColor.setAlpha(128);
// Highlight the current line
QTextEdit::ExtraSelection selection;
selection.format.setBackground(highlightColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = mDisasTextEdit->textCursor();
selection.cursor.clearSelection();
extraSelections.append(selection);
// Highlight the current word // Highlight the current word
QTextCursor cursor = mDisasTextEdit->textCursor(); QTextCursor cursor = mDisasTextEdit->textCursor();
cursor.select(QTextCursor::WordUnderCursor); cursor.select(QTextCursor::WordUnderCursor);
@ -343,10 +335,31 @@ void DisassemblyWidget::highlightCurrentLine()
cursor.movePosition(QTextCursor::EndOfLine); cursor.movePosition(QTextCursor::EndOfLine);
int lineEndPos = cursor.position(); int lineEndPos = cursor.position();
// Highlight the current line
QTextEdit::ExtraSelection highlightSelection;
highlightSelection.cursor = cursor;
highlightSelection.cursor.movePosition(QTextCursor::Start);
while (true) {
RVA lineOffset = readDisassemblyOffset(highlightSelection.cursor);
if (lineOffset == seekable->getOffset()) {
highlightSelection.format.setBackground(highlightColor);
highlightSelection.format.setProperty(QTextFormat::FullWidthSelection, true);
highlightSelection.cursor.clearSelection();
extraSelections.append(highlightSelection);
} else if (lineOffset != RVA_INVALID && lineOffset > seekable->getOffset()) {
break;
}
highlightSelection.cursor.movePosition(QTextCursor::EndOfLine);
if (highlightSelection.cursor.atEnd()) {
break;
}
highlightSelection.cursor.movePosition(QTextCursor::Down);
}
// Highlight all the words in the document same as the current one // Highlight all the words in the document same as the current one
QTextDocument *document = mDisasTextEdit->document(); QTextDocument *document = mDisasTextEdit->document();
QTextEdit::ExtraSelection highlightSelection;
highlightSelection.cursor = cursor; highlightSelection.cursor = cursor;
highlightSelection.cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); highlightSelection.cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);