Kate
katerenderer.cpp
Go to the documentation of this file.
172 void KateRenderer::paintTextLineBackground(QPainter& paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd)
192 KTextEditor::MarkInterface::MarkTypes markType = (KTextEditor::MarkInterface::MarkTypes)(1<<bit);
234 paint.fillRect(0, lineHeight() * currentViewLine, xEnd - xStart, lineHeight(), currentLineColor);
340 QList<QTextLayout::FormatRange> KateRenderer::decorationsForLine( const Kate::TextLine& textLine, int line, bool selectionsOnly, KateRenderRange* completionHighlight, bool completionSelected ) const
345 QList<Kate::TextRange *> rangesWithAttributes = m_doc->buffer().rangesForLine (line, m_printerFriendly ? 0 : m_view, true);
354 inbuiltHighlight->addRange(new KTextEditor::Range(KTextEditor::Cursor(line, al[i].offset), al[i].length), specificAttribute(al[i].attributeValue));
363 // sort all ranges, we want that the most specific ranges win during rendering, multiple equal ranges are kind of random, still better than old smart rangs behavior ;)
375 if (KTextEditor::Attribute::Ptr attributeMouseIn = attribute->dynamicAttribute (KTextEditor::Attribute::ActivateMouseIn)) {
381 if (KTextEditor::Attribute::Ptr attributeCaretIn = attribute->dynamicAttribute (KTextEditor::Attribute::ActivateCaretIn)) {
398 if ((selectionsOnly && showSelections() && m_view->selection()) || (completionHighlight && completionSelected) || m_view->blockSelection()) {
407 backgroundAttribute->setForeground(attribute(KTextEditor::HighlightInterface::dsNormal)->selectedForeground().color());
411 selectionHighlight->addRange(new KTextEditor::Range(line, 0, line + 1, 0), backgroundAttribute);
414 selectionHighlight->addRange(new KTextEditor::Range(m_doc->rangeOnLine(m_view->selectionRange(), line)), backgroundAttribute);
416 selectionHighlight->addRange(new KTextEditor::Range(m_view->selectionRange()), backgroundAttribute);
425 // Calculate the range which we need to iterate in order to get the highlighting for just this line
432 KTextEditor::Range rangeNeeded = m_view->selectionRange() & KTextEditor::Range(line, 0, line + 1, 0);
491 void KateRenderer::assignSelectionBrushesFromAttribute(QTextLayout::FormatRange& target, const KTextEditor::Attribute& attribute) const
506 void KateRenderer::paintTextLine(QPainter& paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor* cursor)
522 bool drawSelection = m_view->selection() && showSelections() && m_view->selectionRange().overlapsLine(range->line());
523 // Draw selection in block selecton mode. We need 2 kinds of selections that QTextLayout::draw can't render:
527 int selectionStartColumn = m_doc->fromVirtualColumn(range->line(), m_doc->toVirtualColumn(m_view->selectionRange().start()));
528 int selectionEndColumn = m_doc->fromVirtualColumn(range->line(), m_doc->toVirtualColumn(m_view->selectionRange().end()));
533 int selectionStartX = (selectionStartColumn > lastLine.startCol()) ? cursorToX(lastLine, selectionStartColumn, true) : 0;
535 paint.fillRect(QRect(selectionStartX - xStart, (int)lastLine.lineLayout().y(), selectionEndX - selectionStartX, lineHeight()), selectionBrush);
541 paint.fillRect(QRect(selectionX - xStart, (int)selectionLine.lineLayout().y(), selectStickWidth, lineHeight()), selectionBrush);
613 if (m_view->selection() && !m_view->blockSelection() && m_view->lineEndSelected(line.end(true))) {
683 paintTrailingSpace(paint, line.lineLayout().cursorToX(spaceIndex) - xStart + spaceWidth()/2.0, y);
694 paint.fillRect(0, lineHeight(), range->shiftX() - xStart, lineHeight() * (range->viewLineCount() - 1),
696 paint.fillRect(0, lineHeight(), range->shiftX() - xStart, lineHeight() * (range->viewLineCount() - 1),
789 paint.drawLine(0, (lineHeight() * range->viewLineCount()) - 1, xEnd - xStart, (lineHeight() * range->viewLineCount()) - 1);
794 if ((!isPrinterFriendly()) && config()->wordWrapMarker() && QFontInfo(config()->font()).fixedPitch())
912 void KateRenderer::layoutLine(KateLineLayoutPtr lineLayout, int maxwidth, bool cacheLayout) const
1053 int KateRenderer::cursorToX(const KateTextLayout& range, const KTextEditor::Cursor & pos, bool returnPastLine) const
1071 KTextEditor::Cursor KateRenderer::xToCursor(const KateTextLayout & range, int x, bool returnPastLine ) const
qreal width() const
int cursorToX(const KateTextLayout &range, int col, bool returnPastLine=false) const
Returns the x position of cursor col on the line range.
Definition: katerenderer.cpp:1048
void setShowSelections(bool showSelections)
Set whether the view's selections should be shown.
Definition: katerenderer.cpp:135
bool drawCaret() const
Determine whether the caret (text cursor) will be drawn.
Definition: katerenderer.h:115
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
void addRange(KTextEditor::Range *range, KTextEditor::Attribute::Ptr attribute)
Definition: katerenderrange.cpp:96
void setPointSize(int pointSize)
void setStyle(Qt::PenStyle style)
const QColor & selectionColor() const
Definition: kateconfig.cpp:2348
Definition: katerenderer.h:71
void paintTextLineBackground(QPainter &paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd)
Paint the background of a line.
Definition: katerenderer.cpp:172
int xToCursor(qreal x, CursorPosition cpos) const
void advanceTo(const KTextEditor::Cursor &pos)
Definition: katerenderrange.cpp:165
void setFont(const QFont &font)
const KTextEditor::MovingCursor & start() const
Retrieve start cursor of this range, read-only.
Definition: katetextrange.h:119
typedef RenderHints
void fillRect(const QRectF &rectangle, const QBrush &brush)
const T & next()
void setRenderHint(RenderHint hint, bool on)
const QColor & lineMarkerColor(KTextEditor::MarkInterface::MarkTypes type=KTextEditor::MarkInterface::markType01) const
Definition: kateconfig.cpp:2390
RenderHints renderHints() const
void setCaretOverrideColor(const QColor &color)
Set a brush with which to override drawing of the caret.
Definition: katerenderer.cpp:1083
KateRenderer(KateDocument *doc, Kate::TextFolding &folding, KateView *view=0)
Constructor.
Definition: katerenderer.cpp:49
const QFontMetricsF & currentFontMetrics() const
Definition: katerenderer.cpp:810
const T & peekNext() const
KTextEditor::Attribute::Ptr attribute(uint pos) const
This takes an in index, and returns all the attributes for it.
Definition: katerenderer.cpp:79
int lineNumber() const
void save()
void drawLines(const QLineF *lines, int lineCount)
const T & peekNext() const
Definition: katerenderrange.h:66
void setAlpha(int alpha)
void increaseFontSizes()
Change to a different font (soon to be font set?)
Definition: katerenderer.cpp:140
static const QChar nbSpaceChar(0xa0)
const QColor & wordWrapMarkerColor() const
Definition: kateconfig.cpp:2445
void layoutLine(KateLineLayoutPtr line, int maxwidth=-1, bool cacheLayout=false) const
Text width & height calculation functions...
Definition: katerenderer.cpp:912
void drawLine(const QLineF &line)
void setRgb(int r, int g, int b, int a)
qreal width(const QString &text) const
int fromVirtualColumn(int line, int column) const
Definition: katedocument.cpp:2580
int endCol(bool indicateEOL=false) const
Return the end column of this text line.
Definition: katetextlayout.cpp:140
KTextEditor::Cursor xToCursor(const KateTextLayout &range, int x, bool returnPastLine=false) const
Returns the real cursor which is occupied by the specified x value, or that closest to it...
Definition: katerenderer.cpp:1071
void beginLayout()
int size() const
static const QChar tabChar('\t')
void setShowTrailingSpaces(bool showSpaces)
Set whether a mark should be painted for trailing spaces.
Definition: katerenderer.cpp:110
void setLineWidth(qreal width)
void setBold(bool enable)
virtual const KTextEditor::Range & selectionRange() const
Definition: kateview.cpp:2815
int dynWordWrapAlignIndent() const
Definition: kateconfig.cpp:1447
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:50
void setWrapMode(WrapMode mode)
void setShowTabs(bool showTabs)
Set whether a mark should be painted to help identifying tabs.
Definition: katerenderer.cpp:105
int count(const T &value) const
void append(const T &value)
bool isSpace() const
void setPrinterFriendly(bool printerFriendly)
Configure this renderer to paint in a printer-friendly fashion.
Definition: katerenderer.cpp:163
void drawPoint(const QPointF &position)
void setPosition(const QPointF &pos)
Definition: katerenderer.h:72
int viewLine() const
Return the index of this visual line inside the document line (KateLineLayout).
Definition: katetextlayout.cpp:109
layoutDirection
Definition: katerenderer.h:73
int red() const
void setPen(const QColor &color)
QTextLine createLine()
bool getSelectionBounds(int line, int lineLength, int &start, int &end) const
Definition: katerenderer.cpp:830
QList< KTextEditor::Attribute::Ptr > attributes(const QString &schema)
Definition: katehighlight.cpp:2172
KateView * view() const
Returns the view to which this renderer is bound.
Definition: katerenderer.h:103
Definition: katerenderrange.h:47
int removeAll(const T &value)
void setCosmetic(bool cosmetic)
qreal cursorToX(int *cursorPos, Edge edge) const
KTextEditor::Range rangeOnLine(KTextEditor::Range range, int line) const
Definition: katedocument.cpp:319
void setCacheEnabled(bool enable)
static const QChar spaceChar(' ')
Class representing the folding information for a TextBuffer.
Definition: katetextfolding.h:42
Definition: katerenderer.h:70
Direction direction() const
bool hasNext() const
void setFlags(QFlags< QTextOption::Flag > flags)
void setShowIndentationLines(bool on)
Definition: kateconfig.cpp:2738
Definition: kateview.h:77
int green() const
iterator end()
const QColor & highlightedLineColor() const
Definition: kateconfig.cpp:2369
Definition: katedocument.h:74
void updateAttributes()
update the highlighting attributes (for example after an hl change or after hl config changed) ...
Definition: katerenderer.cpp:74
KTextEditor::Attribute::Ptr specificAttribute(int context) const
Definition: katerenderer.cpp:87
void setItalic(bool enable)
bool contains(const T &value) const
void setRenderHints(QFlags< QPainter::RenderHint > hints, bool on)
void restore()
int blue() const
bool empty() const
QList< TextRange * > rangesForLine(int line, KTextEditor::View *view, bool rangesWithAttributeOnly) const
Return the ranges which affect the given line.
Definition: katetextbuffer.cpp:872
const KTextEditor::MovingCursor & end() const
Retrieve end cursor of this range, read-only.
Definition: katetextrange.h:131
Definition: kateconfig.h:618
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
Definition: katetextlayout.h:38
void setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)
KateRenderer::caretStyles caretStyle() const
The style of the caret (text cursor) to be painted.
Definition: katerenderer.h:127
qreal y() const
static bool rangeLessThanForRenderer(const Kate::TextRange *a, const Kate::TextRange *b)
Definition: katerenderer.cpp:320
void setCaretStyle(KateRenderer::caretStyles style)
Set the style of caret to be painted.
Definition: katerenderer.cpp:100
void setTextDirection(Qt::LayoutDirection direction)
const QChar at(int position) const
void paintTextLine(QPainter &paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor *cursor=0L)
This is the ultimate function to perform painting of a text line.
Definition: katerenderer.cpp:506
KTextEditor::Attribute::Ptr generateAttribute() const
Definition: katerenderrange.cpp:189
int count(const T &value) const
KTextEditor::Cursor end(bool indicateEOL=false) const
Return the end position of this text line.
Definition: katetextlayout.cpp:152
int length() const
void setTextOption(const QTextOption &option)
bool showIndentationLines() const
Definition: kateconfig.cpp:2730
bool isValid() const
int toVirtualColumn(int line, int column) const
Definition: katedocument.cpp:2565
const QFontMetricsF & fontMetrics() const
Definition: kateconfig.cpp:2284
KTextEditor::Attribute::Ptr attribute() const
Gets the active Attribute for this range.
Definition: katetextrange.h:173
QList< QTextLayout::FormatRange > decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly=false, KateRenderRange *completionHighlight=0L, bool completionSelected=false) const
The ultimate decoration creation function.
Definition: katerenderer.cpp:340
bool lineEndSelected(const KTextEditor::Cursor &lineEndPos)
Definition: kateview.cpp:2101
void setText(const QString &string)
KTextEditor::Cursor nextBoundary() const
Definition: katerenderrange.cpp:143
void setShowIndentLines(bool showLines)
Set whether a guide should be painted to help identifying indent lines.
Definition: katerenderer.cpp:125
void setAdditionalFormats(const QList< FormatRange > &formatList)
void setDrawCaret(bool drawCaret)
Set whether the caret (text cursor) will be drawn.
Definition: katerenderer.cpp:95
void setAlignment(QFlags< Qt::AlignmentFlag > alignment)
const QPen & pen() const
const T & next()
iterator begin()
Definition: katerenderrange.h:35
void setTabStop(qreal tabStop)
bool isLineRightToLeft(KateLineLayoutPtr lineLayout) const
This is a smaller QString::isRightToLeft().
Definition: katerenderer.cpp:1010
int pointSize() const
void endLayout()
qreal height() const
bool isValid() const
void setDashOffset(qreal offset)
bool hasNext() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.