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 | // check shiftX() as it might be zero where there too little horizontal space for indent fill | ||||
688 | if (showIndentLines() && range->shiftX()>0) { | ||||
686 | const qreal w = spaceWidth(); | 689 | const qreal w = spaceWidth(); | ||
687 | const int lastIndentColumn = range->textLine()->indentDepth(m_tabWidth); | 690 | const int lastIndentColumn = range->textLine()->indentDepth(m_tabWidth); | ||
688 | 691 | | |||
689 | for (int x = m_indentWidth; x < lastIndentColumn; x += m_indentWidth) { | 692 | for (int x = m_indentWidth; x < lastIndentColumn; x += m_indentWidth) { | ||
690 | paintIndentMarker(paint, x * w + 1 - xStart, range->line()); | 693 | paintIndentMarker(paint, x * w + 1 - xStart, lineHeight() * i); | ||
691 | } | 694 | } | ||
692 | } | 695 | } | ||
693 | } | 696 | } | ||
694 | 697 | | |||
695 | // draw an open box to mark non-breaking spaces | 698 | // draw an open box to mark non-breaking spaces | ||
696 | const QString &text = range->textLine()->string(); | 699 | const QString &text = range->textLine()->string(); | ||
697 | int y = lineHeight() * i + fm.ascent() - fm.strikeOutPos(); | 700 | int y = lineHeight() * i + fm.ascent() - fm.strikeOutPos(); | ||
698 | int nbSpaceIndex = text.indexOf(nbSpaceChar, line.lineLayout().xToCursor(xStart)); | 701 | int nbSpaceIndex = text.indexOf(nbSpaceChar, line.lineLayout().xToCursor(xStart)); | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 772 | for (const auto &inlineNoteData : inlineNotes) { | |||
792 | paint.save(); | 795 | paint.save(); | ||
793 | paint.translate(x, y); | 796 | paint.translate(x, y); | ||
794 | inlineNote.provider()->paintInlineNote(inlineNote, paint); | 797 | inlineNote.provider()->paintInlineNote(inlineNote, paint); | ||
795 | paint.restore(); | 798 | paint.restore(); | ||
796 | } | 799 | } | ||
797 | } | 800 | } | ||
798 | 801 | | |||
799 | // draw word-wrap-honor-indent filling | 802 | // draw word-wrap-honor-indent filling | ||
800 | if ((range->viewLineCount() > 1) && range->shiftX() && (range->shiftX() > xStart)) { | 803 | if ((range->viewLineCount() > 1) && (m_view->config()->dynWrapFillLeft() || m_view->config()->dynWrapFillRight()) && range->shiftX() && (range->shiftX() > xStart)) { | ||
804 | const int wdRight = range->shiftXRightOnly(); | ||||
805 | int wdLeft = range->shiftX() - xStart - wdRight; | ||||
806 | int col0 = (m_view->config()->dynWrapFillLeft() ? 0 : wdLeft); | ||||
807 | int wd = (m_view->config()->dynWrapFillLeft() ? wdLeft : 0) + wdRight; | ||||
801 | if (backgroundBrushSet) | 808 | if (backgroundBrushSet) | ||
802 | paint.fillRect(0, lineHeight(), range->shiftX() - xStart, lineHeight() * (range->viewLineCount() - 1), backgroundBrush); | 809 | 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)); | 810 | paint.fillRect(col0, lineHeight(), wd, lineHeight() * (range->viewLineCount() - 1), QBrush(config()->wordWrapMarkerColor(), Qt::Dense4Pattern)); | ||
804 | } | 811 | } | ||
805 | 812 | | |||
806 | // Draw caret | 813 | // Draw caret | ||
807 | if (drawCaret() && cursor && range->includesCursor(*cursor)) { | 814 | if (drawCaret() && cursor && range->includesCursor(*cursor)) { | ||
808 | int caretWidth, lineWidth = 2; | 815 | int caretWidth, lineWidth = 2; | ||
809 | QColor color; | 816 | QColor color; | ||
810 | QTextLine line = range->layout()->lineForTextPosition(qMin(cursor->column(), range->length())); | 817 | QTextLine line = range->layout()->lineForTextPosition(qMin(cursor->column(), range->length())); | ||
811 | 818 | | |||
▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Line(s) | 1006 | { | |||
1068 | } | 1075 | } | ||
1069 | l->setFormats(decorations); | 1076 | l->setFormats(decorations); | ||
1070 | 1077 | | |||
1071 | // Begin layouting | 1078 | // Begin layouting | ||
1072 | l->beginLayout(); | 1079 | l->beginLayout(); | ||
1073 | 1080 | | |||
1074 | int height = 0; | 1081 | int height = 0; | ||
1075 | int shiftX = 0; | 1082 | int shiftX = 0; | ||
1083 | int shiftXRightOnly = 0; | ||||
1076 | 1084 | | |||
1077 | bool needShiftX = (maxwidth != -1) && m_view && (m_view->config()->dynWordWrapAlignIndent() > 0); | 1085 | bool needShiftX = (maxwidth != -1) && m_view && (m_view->config()->dynWordWrapAlignIndent() > 0); | ||
1078 | 1086 | | |||
1079 | forever { | 1087 | forever { | ||
1080 | QTextLine line = l->createLine(); | 1088 | QTextLine line = l->createLine(); | ||
1081 | if (!line.isValid()) { | 1089 | if (!line.isValid()) { | ||
1082 | break; | 1090 | break; | ||
1083 | } | 1091 | } | ||
Show All 14 Lines | 1102 | if (needShiftX && line.width() > 0) { | |||
1098 | 1106 | | |||
1099 | if (pos > 0) { | 1107 | if (pos > 0) { | ||
1100 | shiftX = (int)line.cursorToX(pos); | 1108 | shiftX = (int)line.cursorToX(pos); | ||
1101 | } | 1109 | } | ||
1102 | 1110 | | |||
1103 | // check for too deep shift value and limit if necessary | 1111 | // check for too deep shift value and limit if necessary | ||
1104 | if (shiftX > ((double)maxwidth / 100 * m_view->config()->dynWordWrapAlignIndent())) { | 1112 | if (shiftX > ((double)maxwidth / 100 * m_view->config()->dynWordWrapAlignIndent())) { | ||
1105 | shiftX = 0; | 1113 | shiftX = 0; | ||
1114 | shiftXRightOnly = 0; | ||||
1115 | } else { | ||||
1116 | // extra indentation on subsequent lines for indent marker itself | ||||
1117 | shiftXRightOnly = m_view->config()->dynWrapFillRight() * spaceWidth(); | ||||
1118 | // so far shiftX is only the left part; add right as well here | ||||
1119 | shiftX += shiftXRightOnly; | ||||
1106 | } | 1120 | } | ||
1107 | 1121 | | |||
1108 | // if shiftX > 0, the maxwidth has to adapted | 1122 | // if shiftX > 0, the maxwidth has to adapted | ||
1109 | maxwidth -= shiftX; | 1123 | maxwidth -= shiftX; | ||
1110 | 1124 | | |||
1111 | lineLayout->setShiftX(shiftX); | 1125 | lineLayout->setShiftX(shiftX); | ||
1126 | lineLayout->setShiftXRightOnly(shiftXRightOnly); | ||||
1112 | } | 1127 | } | ||
1113 | 1128 | | |||
1114 | height += lineHeight(); | 1129 | height += lineHeight(); | ||
1115 | } | 1130 | } | ||
1116 | 1131 | | |||
1117 | l->endLayout(); | 1132 | l->endLayout(); | ||
1118 | 1133 | | |||
1119 | lineLayout->setLayout(l); | 1134 | lineLayout->setLayout(l); | ||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |