Changeset View
Changeset View
Standalone View
Standalone View
src/render/katerenderer.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 558 | // qCDebug(LOG_KTE)<<"KateRenderer::paintTextLine"; | |||
---|---|---|---|---|---|
560 | // font data | 560 | // font data | ||
561 | const QFontMetricsF &fm = config()->fontMetrics(); | 561 | const QFontMetricsF &fm = config()->fontMetrics(); | ||
562 | 562 | | |||
563 | int currentViewLine = -1; | 563 | int currentViewLine = -1; | ||
564 | if (cursor && cursor->line() == range->line()) { | 564 | if (cursor && cursor->line() == range->line()) { | ||
565 | currentViewLine = range->viewLineForColumn(cursor->column()); | 565 | currentViewLine = range->viewLineForColumn(cursor->column()); | ||
566 | } | 566 | } | ||
567 | 567 | | |||
568 | bool foobar = (currentViewLine >= 0) ? true : false; | ||||
569 | | ||||
568 | paintTextLineBackground(paint, range, currentViewLine, xStart, xEnd); | 570 | paintTextLineBackground(paint, range, currentViewLine, xStart, xEnd); | ||
569 | 571 | | |||
570 | if (range->layout()) { | 572 | if (range->layout()) { | ||
571 | bool drawSelection = m_view && m_view->selection() && showSelections() && m_view->selectionRange().overlapsLine(range->line()); | 573 | bool drawSelection = m_view && m_view->selection() && showSelections() && m_view->selectionRange().overlapsLine(range->line()); | ||
574 | foobar = foobar || drawSelection; | ||||
575 | | ||||
572 | // Draw selection in block selection mode. We need 2 kinds of selections that QTextLayout::draw can't render: | 576 | // Draw selection in block selection mode. We need 2 kinds of selections that QTextLayout::draw can't render: | ||
573 | // - past-end-of-line selection and | 577 | // - past-end-of-line selection and | ||
574 | // - 0-column-wide selection (used to indicate where text will be typed) | 578 | // - 0-column-wide selection (used to indicate where text will be typed) | ||
575 | if (drawSelection && m_view->blockSelection()) { | 579 | if (drawSelection && m_view->blockSelection()) { | ||
576 | int selectionStartColumn = m_doc->fromVirtualColumn(range->line(), m_doc->toVirtualColumn(m_view->selectionRange().start())); | 580 | int selectionStartColumn = m_doc->fromVirtualColumn(range->line(), m_doc->toVirtualColumn(m_view->selectionRange().start())); | ||
577 | int selectionEndColumn = m_doc->fromVirtualColumn(range->line(), m_doc->toVirtualColumn(m_view->selectionRange().end())); | 581 | int selectionEndColumn = m_doc->fromVirtualColumn(range->line(), m_doc->toVirtualColumn(m_view->selectionRange().end())); | ||
578 | QBrush selectionBrush = config()->selectionColor(); | 582 | QBrush selectionBrush = config()->selectionColor(); | ||
579 | if (selectionStartColumn != selectionEndColumn) { | 583 | if (selectionStartColumn != selectionEndColumn) { | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 707 | while (nbSpaceIndex != -1 && nbSpaceIndex < line.endCol()) { | |||
705 | if (x > xEnd) { | 709 | if (x > xEnd) { | ||
706 | break; | 710 | break; | ||
707 | } | 711 | } | ||
708 | paintNonBreakSpace(paint, x - xStart, y); | 712 | paintNonBreakSpace(paint, x - xStart, y); | ||
709 | nbSpaceIndex = text.indexOf(nbSpaceChar, nbSpaceIndex + 1); | 713 | nbSpaceIndex = text.indexOf(nbSpaceChar, nbSpaceIndex + 1); | ||
710 | } | 714 | } | ||
711 | 715 | | |||
712 | // draw tab stop indicators | 716 | // draw tab stop indicators | ||
713 | if (showTabs()) { | 717 | if (showTabs() || foobar) { | ||
714 | int tabIndex = text.indexOf(tabChar, line.lineLayout().xToCursor(xStart)); | 718 | int tabIndex = text.indexOf(tabChar, line.lineLayout().xToCursor(xStart)); | ||
715 | while (tabIndex != -1 && tabIndex < line.endCol()) { | 719 | while (tabIndex != -1 && tabIndex < line.endCol()) { | ||
716 | int x = line.lineLayout().cursorToX(tabIndex); | 720 | int x = line.lineLayout().cursorToX(tabIndex); | ||
717 | if (x > xEnd) { | 721 | if (x > xEnd) { | ||
718 | break; | 722 | break; | ||
719 | } | 723 | } | ||
720 | paintTabstop(paint, x - xStart + spaceWidth() / 2.0, y); | 724 | paintTabstop(paint, x - xStart + spaceWidth() / 2.0, y); | ||
721 | tabIndex = text.indexOf(tabChar, tabIndex + 1); | 725 | tabIndex = text.indexOf(tabChar, tabIndex + 1); | ||
722 | } | 726 | } | ||
723 | } | 727 | } | ||
724 | 728 | | |||
725 | // draw trailing spaces | 729 | // draw trailing spaces | ||
726 | if (showTrailingSpaces()) { | 730 | if (showTrailingSpaces() || foobar) { | ||
727 | int spaceIndex = line.endCol() - 1; | 731 | int spaceIndex = line.endCol() - 1; | ||
728 | int trailingPos = range->textLine()->lastChar(); | 732 | int trailingPos = range->textLine()->lastChar(); | ||
729 | if (trailingPos < 0) { | 733 | if (trailingPos < 0) { | ||
730 | trailingPos = 0; | 734 | trailingPos = 0; | ||
731 | } | 735 | } | ||
732 | if (spaceIndex >= trailingPos) { | 736 | if (spaceIndex >= trailingPos) { | ||
733 | while (spaceIndex >= line.startCol() && text.at(spaceIndex).isSpace()) { | 737 | while (spaceIndex >= line.startCol() && text.at(spaceIndex).isSpace()) { | ||
734 | if (text.at(spaceIndex) != QLatin1Char('\t') || !showTabs()) { | 738 | if (text.at(spaceIndex) != QLatin1Char('\t') || !showTabs()) { | ||
735 | if (range->layout()->textOption().alignment() == Qt::AlignRight) { // Draw on left for RTL lines | 739 | if (range->layout()->textOption().alignment() == Qt::AlignRight) { // Draw on left for RTL lines | ||
736 | paintTrailingSpace(paint, line.lineLayout().cursorToX(spaceIndex) - xStart - spaceWidth() / 2.0, y); | 740 | paintTrailingSpace(paint, line.lineLayout().cursorToX(spaceIndex) - xStart - spaceWidth() / 2.0, y); | ||
737 | } else { | 741 | } else { | ||
738 | paintTrailingSpace(paint, line.lineLayout().cursorToX(spaceIndex) - xStart + spaceWidth() / 2.0, y); | 742 | paintTrailingSpace(paint, line.lineLayout().cursorToX(spaceIndex) - xStart + spaceWidth() / 2.0, y); | ||
739 | } | 743 | } | ||
740 | } | 744 | } | ||
741 | --spaceIndex; | 745 | --spaceIndex; | ||
742 | } | 746 | } | ||
743 | } | 747 | } | ||
744 | } | 748 | } | ||
745 | 749 | | |||
746 | if (showNonPrintableSpaces()) { | 750 | if (showNonPrintableSpaces() || foobar) { | ||
747 | const int y = lineHeight() * i + fm.ascent(); | 751 | const int y = lineHeight() * i + fm.ascent(); | ||
748 | 752 | | |||
749 | static const QRegularExpression nonPrintableSpacesRegExp(QStringLiteral("[\\x{2000}-\\x{200F}\\x{2028}-\\x{202F}\\x{205F}-\\x{2064}\\x{206A}-\\x{206F}]")); | 753 | static const QRegularExpression nonPrintableSpacesRegExp(QStringLiteral("[\\x{2000}-\\x{200F}\\x{2028}-\\x{202F}\\x{205F}-\\x{2064}\\x{206A}-\\x{206F}]")); | ||
750 | QRegularExpressionMatchIterator i = nonPrintableSpacesRegExp.globalMatch(text, line.lineLayout().xToCursor(xStart)); | 754 | QRegularExpressionMatchIterator i = nonPrintableSpacesRegExp.globalMatch(text, line.lineLayout().xToCursor(xStart)); | ||
751 | 755 | | |||
752 | while (i.hasNext()) { | 756 | while (i.hasNext()) { | ||
753 | const int charIndex = i.next().capturedStart(); | 757 | const int charIndex = i.next().capturedStart(); | ||
754 | 758 | | |||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |