Changeset View
Changeset View
Standalone View
Standalone View
src/render/katerenderer.cpp
Show First 20 Lines • Show All 332 Lines • ▼ Show 20 Line(s) | 330 | { | |||
---|---|---|---|---|---|
333 | static const QVector<qreal> dashPattern = QVector<qreal>() << 1 << 1; | 333 | static const QVector<qreal> dashPattern = QVector<qreal>() << 1 << 1; | ||
334 | myPen.setDashPattern(dashPattern); | 334 | myPen.setDashPattern(dashPattern); | ||
335 | if (y % 2) { | 335 | if (y % 2) { | ||
336 | myPen.setDashOffset(1); | 336 | myPen.setDashOffset(1); | ||
337 | } | 337 | } | ||
338 | paint.setPen(myPen); | 338 | paint.setPen(myPen); | ||
339 | 339 | | |||
340 | const int height = fontHeight(); | 340 | const int height = fontHeight(); | ||
341 | const int top = 0; | 341 | const int top = y; | ||
342 | const int bottom = height - 1; | 342 | const int bottom = top + height - 1; | ||
343 | 343 | | |||
344 | QPainter::RenderHints renderHints = paint.renderHints(); | 344 | QPainter::RenderHints renderHints = paint.renderHints(); | ||
345 | paint.setRenderHints(renderHints, false); | 345 | paint.setRenderHints(renderHints, false); | ||
346 | 346 | | |||
347 | paint.drawLine(x + 2, top, x + 2, bottom); | 347 | paint.drawLine(x + 2, top, x + 2, bottom); | ||
348 | 348 | | |||
349 | paint.setRenderHints(renderHints, true); | 349 | paint.setRenderHints(renderHints, true); | ||
350 | 350 | | |||
▲ Show 20 Lines • Show All 326 Lines • ▼ Show 20 Line(s) | 667 | if (draw) { | |||
677 | 677 | | |||
678 | if (width > 0) { | 678 | if (width > 0) { | ||
679 | QRect area(fillStartX, fillStartY, width, height); | 679 | QRect area(fillStartX, fillStartY, width, height); | ||
680 | paint.fillRect(area, drawBrush); | 680 | paint.fillRect(area, drawBrush); | ||
681 | } | 681 | } | ||
682 | } | 682 | } | ||
683 | 683 | | |||
684 | // Draw indent lines | 684 | // Draw indent lines | ||
685 | if (showIndentLines() && i == 0) { | 685 | // do this even for i>=0 where we risk of being overpainted by left indent fill | ||
686 | // (or should this be checked here already?) | ||||
687 | if (showIndentLines()) { | ||||
686 | const qreal w = spaceWidth(); | 688 | const qreal w = spaceWidth(); | ||
687 | const int lastIndentColumn = range->textLine()->indentDepth(m_tabWidth); | 689 | const int lastIndentColumn = range->textLine()->indentDepth(m_tabWidth); | ||
688 | 690 | | |||
689 | for (int x = m_indentWidth; x < lastIndentColumn; x += m_indentWidth) { | 691 | for (int x = m_indentWidth; x < lastIndentColumn; x += m_indentWidth) { | ||
690 | paintIndentMarker(paint, x * w + 1 - xStart, range->line()); | 692 | paintIndentMarker(paint, x * w + 1 - xStart, lineHeight() * i); | ||
691 | } | 693 | } | ||
692 | } | 694 | } | ||
693 | } | 695 | } | ||
694 | 696 | | |||
695 | // draw an open box to mark non-breaking spaces | 697 | // draw an open box to mark non-breaking spaces | ||
696 | const QString &text = range->textLine()->string(); | 698 | const QString &text = range->textLine()->string(); | ||
697 | int y = lineHeight() * i + fm.ascent() - fm.strikeOutPos(); | 699 | int y = lineHeight() * i + fm.ascent() - fm.strikeOutPos(); | ||
698 | int nbSpaceIndex = text.indexOf(nbSpaceChar, line.lineLayout().xToCursor(xStart)); | 700 | int nbSpaceIndex = text.indexOf(nbSpaceChar, line.lineLayout().xToCursor(xStart)); | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 771 | for (const auto &inlineNoteData : inlineNotes) { | |||
792 | paint.save(); | 794 | paint.save(); | ||
793 | paint.translate(x, y); | 795 | paint.translate(x, y); | ||
794 | inlineNote.provider()->paintInlineNote(inlineNote, paint); | 796 | inlineNote.provider()->paintInlineNote(inlineNote, paint); | ||
795 | paint.restore(); | 797 | paint.restore(); | ||
796 | } | 798 | } | ||
797 | } | 799 | } | ||
798 | 800 | | |||
799 | // draw word-wrap-honor-indent filling | 801 | // draw word-wrap-honor-indent filling | ||
800 | if ((range->viewLineCount() > 1) && range->shiftX() && (range->shiftX() > xStart)) { | 802 | if ((range->viewLineCount() > 1) && (m_view->config()->dynWrapFillLeft() || m_view->config()->dynWrapFillRight()) && range->shiftX() && (range->shiftX() > xStart)) { | ||
803 | const int wdRight = range->shiftXRightOnly(); | ||||
804 | int wdLeft = range->shiftX() - xStart - wdRight; | ||||
805 | int col0 = (m_view->config()->dynWrapFillLeft() ? 0 : wdLeft); | ||||
806 | int wd = (m_view->config()->dynWrapFillLeft() ? wdLeft : 0) + wdRight; | ||||
801 | if (backgroundBrushSet) | 807 | if (backgroundBrushSet) | ||
802 | paint.fillRect(0, lineHeight(), range->shiftX() - xStart, lineHeight() * (range->viewLineCount() - 1), backgroundBrush); | 808 | paint.fillRect(col0, lineHeight(), wd, lineHeight() * (range->viewLineCount() - 1), backgroundBrush); | ||
803 | paint.fillRect(0, lineHeight(), range->shiftX() - xStart, lineHeight() * (range->viewLineCount() - 1), QBrush(config()->wordWrapMarkerColor(), Qt::Dense4Pattern)); | 809 | paint.fillRect(col0, lineHeight(), wd, lineHeight() * (range->viewLineCount() - 1), QBrush(config()->wordWrapMarkerColor(), Qt::Dense4Pattern)); | ||
804 | } | 810 | } | ||
805 | 811 | | |||
806 | // Draw caret | 812 | // Draw caret | ||
807 | if (drawCaret() && cursor && range->includesCursor(*cursor)) { | 813 | if (drawCaret() && cursor && range->includesCursor(*cursor)) { | ||
808 | int caretWidth, lineWidth = 2; | 814 | int caretWidth, lineWidth = 2; | ||
809 | QColor color; | 815 | QColor color; | ||
810 | QTextLine line = range->layout()->lineForTextPosition(qMin(cursor->column(), range->length())); | 816 | QTextLine line = range->layout()->lineForTextPosition(qMin(cursor->column(), range->length())); | ||
811 | 817 | | |||
▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Line(s) | 1005 | { | |||
1064 | } | 1070 | } | ||
1065 | l->setFormats(decorations); | 1071 | l->setFormats(decorations); | ||
1066 | 1072 | | |||
1067 | // Begin layouting | 1073 | // Begin layouting | ||
1068 | l->beginLayout(); | 1074 | l->beginLayout(); | ||
1069 | 1075 | | |||
1070 | int height = 0; | 1076 | int height = 0; | ||
1071 | int shiftX = 0; | 1077 | int shiftX = 0; | ||
1078 | int shiftXRightOnly = 0; | ||||
1072 | 1079 | | |||
1073 | bool needShiftX = (maxwidth != -1) && m_view && (m_view->config()->dynWordWrapAlignIndent() > 0); | 1080 | bool needShiftX = (maxwidth != -1) && m_view && (m_view->config()->dynWordWrapAlignIndent() > 0); | ||
1074 | 1081 | | |||
1075 | forever { | 1082 | forever { | ||
1076 | QTextLine line = l->createLine(); | 1083 | QTextLine line = l->createLine(); | ||
1077 | if (!line.isValid()) { | 1084 | if (!line.isValid()) { | ||
1078 | break; | 1085 | break; | ||
1079 | } | 1086 | } | ||
Show All 19 Lines | 1097 | if (needShiftX && line.width() > 0) { | |||
1099 | // check for too deep shift value and limit if necessary | 1106 | // check for too deep shift value and limit if necessary | ||
1100 | if (shiftX > ((double)maxwidth / 100 * m_view->config()->dynWordWrapAlignIndent())) { | 1107 | if (shiftX > ((double)maxwidth / 100 * m_view->config()->dynWordWrapAlignIndent())) { | ||
1101 | shiftX = 0; | 1108 | shiftX = 0; | ||
1102 | } | 1109 | } | ||
1103 | 1110 | | |||
1104 | // if shiftX > 0, the maxwidth has to adapted | 1111 | // if shiftX > 0, the maxwidth has to adapted | ||
1105 | maxwidth -= shiftX; | 1112 | maxwidth -= shiftX; | ||
1106 | 1113 | | |||
1114 | // extra indentation on subsequent lines for indent marker itself | ||||
1115 | shiftXRightOnly=line.cursorToX(m_view->config()->dynWrapFillRight()); | ||||
1116 | | ||||
1117 | // so far shiftX is only the left part; add right as well here | ||||
1118 | shiftX += shiftXRightOnly; | ||||
1119 | | ||||
1107 | lineLayout->setShiftX(shiftX); | 1120 | lineLayout->setShiftX(shiftX); | ||
1121 | lineLayout->setShiftXRightOnly(shiftXRightOnly); | ||||
1108 | } | 1122 | } | ||
1109 | 1123 | | |||
1110 | height += lineHeight(); | 1124 | height += lineHeight(); | ||
1111 | } | 1125 | } | ||
1112 | 1126 | | |||
1113 | l->endLayout(); | 1127 | l->endLayout(); | ||
1114 | 1128 | | |||
1115 | lineLayout->setLayout(l); | 1129 | lineLayout->setLayout(l); | ||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |