sourcewnd.cpp (kdbg-3.0.0) | : | sourcewnd.cpp (kdbg-3.0.1) | ||
---|---|---|---|---|
skipping to change at line 446 | skipping to change at line 446 | |||
int wordEnd) | int wordEnd) | |||
{ | { | |||
QString document = plainText.left(wordEnd); | QString document = plainText.left(wordEnd); | |||
QString word = plainText.mid(wordStart, wordEnd - wordStart); | QString word = plainText.mid(wordStart, wordEnd - wordStart); | |||
QRegExp regex = QRegExp("(::)?([A-Za-z_]{1}\\w*\\s*(->|\\.|::)\\s*)*" + w ord + "$"); | QRegExp regex = QRegExp("(::)?([A-Za-z_]{1}\\w*\\s*(->|\\.|::)\\s*)*" + w ord + "$"); | |||
#define IDENTIFIER_MAX_SIZE 256 | #define IDENTIFIER_MAX_SIZE 256 | |||
// cut the document to reduce size of string to scan | // cut the document to reduce size of string to scan | |||
// because of this only identifiefs of length <= IDENTIFIER_MAX_SIZE are sup ported | // because of this only identifiefs of length <= IDENTIFIER_MAX_SIZE are sup ported | |||
if (document.length() > IDENTIFIER_MAX_SIZE) { | if (document.length() > IDENTIFIER_MAX_SIZE) { | |||
document.right(IDENTIFIER_MAX_SIZE); | document = document.right(IDENTIFIER_MAX_SIZE); | |||
} | } | |||
const int index = regex.indexIn(document); | const int index = regex.indexIn(document); | |||
if (index == -1) | if (index == -1) | |||
{ | { | |||
TRACE("No match, returning " + word); | TRACE("No match, returning " + word); | |||
} | } | |||
else | else | |||
{ | { | |||
const int length = regex.matchedLength(); | const int length = regex.matchedLength(); | |||
word = plainText.mid(index, length); | word = document.mid(index, length); | |||
TRACE("Matched, returning " + word); | TRACE("Matched, returning " + word); | |||
} | } | |||
return word; | return word; | |||
} | } | |||
bool SourceWindow::wordAtPoint(const QPoint& p, QString& word, QRect& r) | bool SourceWindow::wordAtPoint(const QPoint& p, QString& word, QRect& r) | |||
{ | { | |||
QTextCursor cursor = cursorForPosition(viewport()->mapFrom(this, p)); | QTextCursor cursor = cursorForPosition(viewport()->mapFrom(this, p)); | |||
if (cursor.isNull()) | if (cursor.isNull()) | |||
skipping to change at line 779 | skipping to change at line 779 | |||
void SourceWindow::setTabWidth(int numChars) | void SourceWindow::setTabWidth(int numChars) | |||
{ | { | |||
if (numChars <= 0) | if (numChars <= 0) | |||
numChars = 8; | numChars = 8; | |||
QFontMetrics fm(document()->defaultFont()); | QFontMetrics fm(document()->defaultFont()); | |||
QString s; | QString s; | |||
int w = fm.width(s.fill('x', numChars)); | int w = fm.width(s.fill('x', numChars)); | |||
setTabStopWidth(w); | setTabStopWidth(w); | |||
} | } | |||
QColor SourceWindow::lineSelectionColor() const | ||||
{ | ||||
QColor c = palette().color(QPalette::Text); | ||||
if (c.lightness() < 100) // Breeze light 24, Breeze dark 240 | ||||
return "#E7E7E7"; | ||||
else | ||||
return "#191919"; | ||||
} | ||||
void SourceWindow::cursorChanged() | void SourceWindow::cursorChanged() | |||
{ | { | |||
QList<QTextEdit::ExtraSelection> extraSelections; | QList<QTextEdit::ExtraSelection> extraSelections; | |||
QTextEdit::ExtraSelection selection; | QTextEdit::ExtraSelection selection; | |||
selection.format.setBackground(QColor("#E7E7E7")); | selection.format.setBackground(lineSelectionColor()); | |||
selection.format.setProperty(QTextFormat::FullWidthSelection, true); | selection.format.setProperty(QTextFormat::FullWidthSelection, true); | |||
selection.cursor = textCursor(); | selection.cursor = textCursor(); | |||
selection.cursor.clearSelection(); | selection.cursor.clearSelection(); | |||
extraSelections.append(selection); | extraSelections.append(selection); | |||
setExtraSelections(extraSelections); | setExtraSelections(extraSelections); | |||
} | } | |||
/* | /* | |||
* Show our own context menu. | * Show our own context menu. | |||
*/ | */ | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 13 lines changed or added |