mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Highlight matching braces in decompiler view (#3285)
This commit is contained in:
parent
aabf442348
commit
e3087e727a
@ -7,6 +7,7 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
QList<QTextEdit::ExtraSelection> createSameWordsSelections(QPlainTextEdit *textEdit,
|
QList<QTextEdit::ExtraSelection> createSameWordsSelections(QPlainTextEdit *textEdit,
|
||||||
const QString &word)
|
const QString &word)
|
||||||
@ -21,6 +22,42 @@ QList<QTextEdit::ExtraSelection> createSameWordsSelections(QPlainTextEdit *textE
|
|||||||
}
|
}
|
||||||
|
|
||||||
highlightSelection.cursor = textEdit->textCursor();
|
highlightSelection.cursor = textEdit->textCursor();
|
||||||
|
|
||||||
|
if (word == "{" || word == "}") {
|
||||||
|
int val;
|
||||||
|
if (word == "{") {
|
||||||
|
val = 0;
|
||||||
|
} else {
|
||||||
|
val = 1;
|
||||||
|
}
|
||||||
|
selections.append(highlightSelection);
|
||||||
|
|
||||||
|
while (!highlightSelection.cursor.isNull() && !highlightSelection.cursor.atEnd()) {
|
||||||
|
if (word == "{") {
|
||||||
|
highlightSelection.cursor =
|
||||||
|
document->find(QRegularExpression("{|}"), highlightSelection.cursor);
|
||||||
|
} else {
|
||||||
|
highlightSelection.cursor =
|
||||||
|
document->find(QRegularExpression("{|}"), highlightSelection.cursor,
|
||||||
|
QTextDocument::FindBackward);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!highlightSelection.cursor.isNull()) {
|
||||||
|
if (highlightSelection.cursor.selectedText() == word) {
|
||||||
|
val++;
|
||||||
|
} else {
|
||||||
|
val--;
|
||||||
|
}
|
||||||
|
if (val == 0) {
|
||||||
|
highlightSelection.format.setBackground(highlightWordColor);
|
||||||
|
selections.append(highlightSelection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selections;
|
||||||
|
}
|
||||||
|
|
||||||
highlightSelection.cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
highlightSelection.cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||||
|
|
||||||
while (!highlightSelection.cursor.isNull() && !highlightSelection.cursor.atEnd()) {
|
while (!highlightSelection.cursor.isNull() && !highlightSelection.cursor.atEnd()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user