Changeset View
Changeset View
Standalone View
Standalone View
src/render/katerenderer.cpp
Show First 20 Lines • Show All 539 Lines • ▼ Show 20 Line(s) | |||||
540 | { | 540 | { | ||
541 | if (attribute.hasProperty(SelectedForeground)) { | 541 | if (attribute.hasProperty(SelectedForeground)) { | ||
542 | target.format.setForeground(attribute.selectedForeground()); | 542 | target.format.setForeground(attribute.selectedForeground()); | ||
543 | } | 543 | } | ||
544 | if (attribute.hasProperty(SelectedBackground)) { | 544 | if (attribute.hasProperty(SelectedBackground)) { | ||
545 | target.format.setBackground(attribute.selectedBackground()); | 545 | target.format.setBackground(attribute.selectedBackground()); | ||
546 | } | 546 | } | ||
547 | } | 547 | } | ||
548 | 548 | | |||
549 | /* | | |||
550 | The ultimate line painting function. | | |||
551 | Currently missing features: | | |||
552 | - draw indent lines | | |||
553 | */ | | |||
554 | void KateRenderer::paintTextLine(QPainter &paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor *cursor, PaintTextLineFlags flags) | 549 | void KateRenderer::paintTextLine(QPainter &paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor *cursor, PaintTextLineFlags flags) | ||
loh.tar: Hm... | |||||
555 | { | 550 | { | ||
556 | Q_ASSERT(range->isValid()); | 551 | Q_ASSERT(range->isValid()); | ||
557 | 552 | | |||
558 | // qCDebug(LOG_KTE)<<"KateRenderer::paintTextLine"; | 553 | // qCDebug(LOG_KTE)<<"KateRenderer::paintTextLine"; | ||
559 | 554 | | |||
560 | // font data | 555 | // font data | ||
561 | const QFontMetricsF &fm = config()->fontMetrics(); | 556 | const QFontMetricsF &fm = config()->fontMetrics(); | ||
562 | 557 | | |||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 642 | if (fr.start + fr.length > line.endCol()) { | |||
651 | } | 646 | } | ||
652 | 647 | | |||
653 | break; | 648 | break; | ||
654 | } | 649 | } | ||
655 | 650 | | |||
656 | it.next(); | 651 | it.next(); | ||
657 | } | 652 | } | ||
658 | 653 | | |||
659 | // Draw selection or background color outside of areas where text is rendered | 654 | // Draw selection or background color outside of areas where text is rendered | ||
loh.tar: What? How about "Don't paint accessories when paint to a printer" | |||||
660 | if (!m_printerFriendly) { | 655 | if (!m_printerFriendly) { | ||
661 | bool draw = false; | 656 | bool draw = false; | ||
662 | QBrush drawBrush; | 657 | QBrush drawBrush; | ||
663 | if (m_view && m_view->selection() && !m_view->blockSelection() && m_view->lineEndSelected(line.end(true))) { | 658 | if (m_view && m_view->selection() && !m_view->blockSelection() && m_view->lineEndSelected(line.end(true))) { | ||
664 | draw = true; | 659 | draw = true; | ||
665 | drawBrush = config()->selectionColor(); | 660 | drawBrush = config()->selectionColor(); | ||
666 | } else if (backgroundBrushSet && !m_view->blockSelection()) { | 661 | } else if (backgroundBrushSet && !m_view->blockSelection()) { | ||
667 | draw = true; | 662 | draw = true; | ||
Show All 11 Lines | 673 | if (range->layout()->textOption().alignment() == Qt::AlignRight) { | |||
679 | fillStartX = 0; | 674 | fillStartX = 0; | ||
680 | } | 675 | } | ||
681 | 676 | | |||
682 | if (width > 0) { | 677 | if (width > 0) { | ||
683 | QRect area(fillStartX, fillStartY, width, height); | 678 | QRect area(fillStartX, fillStartY, width, height); | ||
684 | paint.fillRect(area, drawBrush); | 679 | paint.fillRect(area, drawBrush); | ||
685 | } | 680 | } | ||
686 | } | 681 | } | ||
687 | } | 682 | | ||
688 | // Draw indent lines | 683 | // Draw indent lines | ||
689 | if (showIndentLines() && i == 0) { | 684 | if (showIndentLines() && i == 0) { | ||
690 | const qreal w = spaceWidth(); | 685 | const qreal w = spaceWidth(); | ||
691 | const int lastIndentColumn = range->textLine()->indentDepth(m_tabWidth); | 686 | const int lastIndentColumn = range->textLine()->indentDepth(m_tabWidth); | ||
692 | 687 | | |||
693 | for (int x = m_indentWidth; x < lastIndentColumn; x += m_indentWidth) { | 688 | for (int x = m_indentWidth; x < lastIndentColumn; x += m_indentWidth) { | ||
694 | paintIndentMarker(paint, x * w + 1 - xStart, range->line()); | 689 | paintIndentMarker(paint, x * w + 1 - xStart, range->line()); | ||
695 | } | 690 | } | ||
696 | } | 691 | } | ||
692 | } | ||||
697 | 693 | | |||
698 | // draw an open box to mark non-breaking spaces | 694 | // draw an open box to mark non-breaking spaces | ||
699 | const QString &text = range->textLine()->string(); | 695 | const QString &text = range->textLine()->string(); | ||
700 | int y = lineHeight() * i + fm.ascent() - fm.strikeOutPos(); | 696 | int y = lineHeight() * i + fm.ascent() - fm.strikeOutPos(); | ||
701 | int nbSpaceIndex = text.indexOf(nbSpaceChar, line.lineLayout().xToCursor(xStart)); | 697 | int nbSpaceIndex = text.indexOf(nbSpaceChar, line.lineLayout().xToCursor(xStart)); | ||
702 | 698 | | |||
703 | while (nbSpaceIndex != -1 && nbSpaceIndex < line.endCol()) { | 699 | while (nbSpaceIndex != -1 && nbSpaceIndex < line.endCol()) { | ||
704 | int x = line.lineLayout().cursorToX(nbSpaceIndex); | 700 | int x = line.lineLayout().cursorToX(nbSpaceIndex); | ||
▲ Show 20 Lines • Show All 509 Lines • Show Last 20 Lines |
Hm...