Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateview.cpp
Show First 20 Lines • Show All 3309 Lines • ▼ Show 20 Line(s) | |||||
3310 | void KTextEditor::ViewPrivate::setAnnotationUniformItemSizes(bool enable) | 3310 | void KTextEditor::ViewPrivate::setAnnotationUniformItemSizes(bool enable) | ||
3311 | { | 3311 | { | ||
3312 | m_viewInternal->m_leftBorder->setAnnotationUniformItemSizes(enable); | 3312 | m_viewInternal->m_leftBorder->setAnnotationUniformItemSizes(enable); | ||
3313 | } | 3313 | } | ||
3314 | 3314 | | |||
3315 | KTextEditor::Range KTextEditor::ViewPrivate::visibleRange() | 3315 | KTextEditor::Range KTextEditor::ViewPrivate::visibleRange() | ||
3316 | { | 3316 | { | ||
3317 | //ensure that the view is up-to-date, otherwise 'endPos()' might fail! | 3317 | //ensure that the view is up-to-date, otherwise 'endPos()' might fail! | ||
3318 | if (!m_viewInternal->endPos().isValid()) { | ||||
3318 | m_viewInternal->updateView(); | 3319 | m_viewInternal->updateView(); | ||
3320 | } | ||||
3319 | return KTextEditor::Range(m_viewInternal->toRealCursor(m_viewInternal->startPos()), | 3321 | return KTextEditor::Range(m_viewInternal->toRealCursor(m_viewInternal->startPos()), | ||
3320 | m_viewInternal->toRealCursor(m_viewInternal->endPos())); | 3322 | m_viewInternal->toRealCursor(m_viewInternal->endPos())); | ||
3321 | } | 3323 | } | ||
3322 | 3324 | | |||
3323 | bool KTextEditor::ViewPrivate::event(QEvent *e) | 3325 | bool KTextEditor::ViewPrivate::event(QEvent *e) | ||
3324 | { | 3326 | { | ||
3325 | switch (e->type()) { | 3327 | switch (e->type()) { | ||
3326 | case QEvent::StyleChange: | 3328 | case QEvent::StyleChange: | ||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Line(s) | 3629 | { | |||
3634 | attr->setBackground(Qt::yellow); | 3636 | attr->setBackground(Qt::yellow); | ||
3635 | 3637 | | |||
3636 | // set correct highlight color from Kate's color schema | 3638 | // set correct highlight color from Kate's color schema | ||
3637 | QColor fgColor = defaultStyleAttribute(KTextEditor::dsNormal)->foreground().color(); | 3639 | QColor fgColor = defaultStyleAttribute(KTextEditor::dsNormal)->foreground().color(); | ||
3638 | QColor bgColor = renderer()->config()->searchHighlightColor(); | 3640 | QColor bgColor = renderer()->config()->searchHighlightColor(); | ||
3639 | attr->setForeground(fgColor); | 3641 | attr->setForeground(fgColor); | ||
3640 | attr->setBackground(bgColor); | 3642 | attr->setBackground(bgColor); | ||
3641 | 3643 | | |||
3642 | KTextEditor::Cursor start(visibleRange().start()); | 3644 | KTextEditor::Range tmpVisibleRange = visibleRange(); | ||
3645 | | ||||
3646 | KTextEditor::Cursor start(tmpVisibleRange.start()); | ||||
3643 | KTextEditor::Range searchRange; | 3647 | KTextEditor::Range searchRange; | ||
3644 | 3648 | | |||
3645 | /** | 3649 | /** | ||
3646 | * only add word boundary if we can find the text then | 3650 | * only add word boundary if we can find the text then | ||
3647 | * fixes $lala hl | 3651 | * fixes $lala hl | ||
3648 | */ | 3652 | */ | ||
3649 | QString regex = QRegExp::escape (m_currentTextForHighlights); | 3653 | QString regex = QRegExp::escape (m_currentTextForHighlights); | ||
3650 | if (QRegExp (QStringLiteral("\\b%1").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | 3654 | if (QRegExp (QStringLiteral("\\b%1").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | ||
3651 | regex = QStringLiteral("\\b%1").arg(regex); | 3655 | regex = QStringLiteral("\\b%1").arg(regex); | ||
3652 | if (QRegExp (QStringLiteral("%1\\b").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | 3656 | if (QRegExp (QStringLiteral("%1\\b").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | ||
3653 | regex = QStringLiteral("%1\\b").arg(regex); | 3657 | regex = QStringLiteral("%1\\b").arg(regex); | ||
3654 | 3658 | | |||
3655 | QVector<KTextEditor::Range> matches; | 3659 | QVector<KTextEditor::Range> matches; | ||
3656 | do { | 3660 | do { | ||
3657 | searchRange.setRange(start, visibleRange().end()); | 3661 | searchRange.setRange(start, tmpVisibleRange.end()); | ||
3658 | 3662 | | |||
3659 | matches = m_doc->searchText(searchRange, regex, KTextEditor::Regex); | 3663 | matches = m_doc->searchText(searchRange, regex, KTextEditor::Regex); | ||
3660 | 3664 | | |||
3661 | if (matches.first().isValid()) { | 3665 | if (matches.first().isValid()) { | ||
3662 | KTextEditor::MovingRange* mr = m_doc->newMovingRange(matches.first()); | 3666 | KTextEditor::MovingRange* mr = m_doc->newMovingRange(matches.first()); | ||
3663 | mr->setAttribute(attr); | 3667 | mr->setAttribute(attr); | ||
3664 | mr->setView(this); | 3668 | mr->setView(this); | ||
3665 | mr->setZDepth(-90000.0); // Set the z-depth to slightly worse than the selection | 3669 | mr->setZDepth(-90000.0); // Set the z-depth to slightly worse than the selection | ||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |