KateRenderer

Search for usage in LXR

#include <katerenderer.h>

Public Types

enum  PaintTextLineFlag { SkipDrawFirstInvisibleLineUnderlined = 0x1 , SkipDrawLineSelection = 0x2 }
 
typedef QFlags< PaintTextLineFlagPaintTextLineFlags
 

Public Member Functions

 KateRenderer (const KateRenderer &)=delete
 
 KateRenderer (KTextEditor::DocumentPrivate *doc, Kate::TextFolding &folding, KTextEditor::ViewPrivate *view=nullptr)
 
const AttributePtrattribute (uint pos) const
 
KTextEditor::caretStyles caretStyle () const
 
KateRendererConfig * config () const
 
const QFontcurrentFont () const
 
const QFontMetricsFcurrentFontMetrics () const
 
int cursorToX (const KateTextLayout &range, const KTextEditor::Cursor pos, bool returnPastLine=false) const
 
int cursorToX (const KateTextLayout &range, int col, bool returnPastLine=false) const
 
QList< QTextLayout::FormatRangedecorationsForLine (const Kate::TextLine &textLine, int line, bool selectionsOnly=false) const
 
void decreaseFontSizes (qreal step=1.0) const
 
KTextEditor::DocumentPrivatedoc () const
 
uint documentHeight () const
 
bool drawCaret () const
 
Kate::TextFoldingfolding () const
 
uint fontHeight () const
 
bool getSelectionBounds (int line, int lineLength, int &start, int &end) const
 
void increaseFontSizes (qreal step=1.0) const
 
bool isPrinterFriendly () const
 
void layoutLine (KateLineLayout *line, int maxwidth=-1, bool cacheLayout=false) const
 
int lineHeight () const
 
KateRendereroperator= (const KateRenderer &)=delete
 
void paintSelection (QPaintDevice *d, int startLine, int xStart, int endLine, int xEnd, int viewWidth, qreal scale=1.0)
 
void paintTextBackground (QPainter &paint, KateLineLayout *layout, const QList< QTextLayout::FormatRange > &selRanges, const QBrush &br, int xStart) const
 
void paintTextLine (QPainter &paint, KateLineLayout *range, int xStart, int xEnd, const QRectF &textClipRect=QRectF(), const KTextEditor::Cursor *cursor=nullptr, PaintTextLineFlags flags=PaintTextLineFlags())
 
void paintTextLineBackground (QPainter &paint, KateLineLayout *layout, int currentViewLine, int xStart, int xEnd)
 
void resetFontSizes () const
 
void setCaretOverrideColor (const QColor &color)
 
void setCaretStyle (KTextEditor::caretStyles style)
 
void setDrawCaret (bool drawCaret)
 
void setIndentWidth (int indentWidth)
 
void setPrinterFriendly (bool printerFriendly)
 
void setShowIndentLines (bool showLines)
 
void setShowNonPrintableSpaces (const bool showNonPrintableSpaces)
 
void setShowSelections (bool showSelections)
 
void setShowSpaces (KateDocumentConfig::WhitespaceRendering showSpaces)
 
void setShowTabs (bool showTabs)
 
void setTabWidth (int tabWidth)
 
bool showIndentLines () const
 
bool showNonPrintableSpaces () const
 
bool showSelections () const
 
KateDocumentConfig::WhitespaceRendering showSpaces () const
 
bool showTabs () const
 
qreal spaceWidth () const
 
AttributePtr specificAttribute (int context) const
 
void updateAttributes ()
 
void updateConfig ()
 
void updateMarkerSize ()
 
KTextEditor::ViewPrivate * view () const
 
KTextEditor::Cursor xToCursor (const KateTextLayout &range, int x, bool returnPastLine=false) const
 

Static Public Member Functions

static bool isLineRightToLeft (QStringView str)
 

Detailed Description

Handles all of the work of rendering the text (used for the views and printing)

Definition at line 55 of file katerenderer.h.

Member Typedef Documentation

◆ PaintTextLineFlags

Member Enumeration Documentation

◆ PaintTextLineFlag

Flags to customize the paintTextLine function behavior.

Enumerator
SkipDrawFirstInvisibleLineUnderlined 

Skip drawing the dashed underline at the start of a folded block of text?

SkipDrawLineSelection 

Skip drawing the line selection This is useful when we are drawing the draggable pixmap for drag event.

Definition at line 333 of file katerenderer.h.

Constructor & Destructor Documentation

◆ KateRenderer()

KateRenderer::KateRenderer ( KTextEditor::DocumentPrivate * doc,
Kate::TextFolding & folding,
KTextEditor::ViewPrivate * view = nullptr )
explicit

Style of Caret.

The caret is displayed as a vertical bar (Line), a filled box (Block), a horizontal bar (Underline), or a half-height filled box (Half). The default is Line.

Line           Block          Underline           Half

_ ######### _ _

__| | #####| |# __| | __| |

/ _' | ##/ _' |# / _' | / _' |

| (_| | #| (#| |# | (_| | #| (#| |

__,_| ##__,_|# __,_| ##__,_|

autotoc_md14

Constructor

Parameters
docdocument to render
foldingfolding information
viewview which is output (0 for example for rendering to print)

Definition at line 42 of file katerenderer.cpp.

Member Function Documentation

◆ attribute()

const KTextEditor::Attribute::Ptr & KateRenderer::attribute ( uint pos) const

This takes an in index, and returns all the attributes for it.

For example, if you have a ktextline, and want the KTextEditor::Attribute for a given position, do:

attribute(myktextline->attribute(position));

Definition at line 73 of file katerenderer.cpp.

◆ caretStyle()

KTextEditor::caretStyles KateRenderer::caretStyle ( ) const
inline

The style of the caret (text cursor) to be painted.

Returns
caretStyle

Definition at line 136 of file katerenderer.h.

◆ config()

KateRendererConfig * KateRenderer::config ( ) const
inline

Definition at line 478 of file katerenderer.h.

◆ currentFont()

const QFont & KateRenderer::currentFont ( ) const
inline

Access currently used font.

Returns
current font

Definition at line 250 of file katerenderer.h.

◆ currentFontMetrics()

const QFontMetricsF & KateRenderer::currentFontMetrics ( ) const
inline

Access currently used font metrics.

Returns
current font metrics

Definition at line 259 of file katerenderer.h.

◆ cursorToX() [1/2]

int KateRenderer::cursorToX ( const KateTextLayout & range,
const KTextEditor::Cursor pos,
bool returnPastLine = false ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1463 of file katerenderer.cpp.

◆ cursorToX() [2/2]

int KateRenderer::cursorToX ( const KateTextLayout & range,
int col,
bool returnPastLine = false ) const

Returns the x position of cursor col on the line range.

Definition at line 1458 of file katerenderer.cpp.

◆ decorationsForLine()

QList< QTextLayout::FormatRange > KateRenderer::decorationsForLine ( const Kate::TextLine & textLine,
int line,
bool selectionsOnly = false ) const

The ultimate decoration creation function.

Parameters
selectionsOnlyreturn decorations for selections and/or dynamic highlighting.

Definition at line 436 of file katerenderer.cpp.

◆ decreaseFontSizes()

void KateRenderer::decreaseFontSizes ( qreal step = 1.0) const

Definition at line 158 of file katerenderer.cpp.

◆ doc()

KTextEditor::DocumentPrivate * KateRenderer::doc ( ) const
inline

Returns the document to which this renderer is bound.

Definition at line 89 of file katerenderer.h.

◆ documentHeight()

uint KateRenderer::documentHeight ( ) const

Definition at line 1149 of file katerenderer.cpp.

◆ drawCaret()

bool KateRenderer::drawCaret ( ) const
inline

Determine whether the caret (text cursor) will be drawn.

Returns
should it be drawn?

Definition at line 121 of file katerenderer.h.

◆ folding()

Kate::TextFolding & KateRenderer::folding ( ) const
inline

Returns the folding info to which this renderer is bound.

Returns
folding info

Definition at line 98 of file katerenderer.h.

◆ fontHeight()

uint KateRenderer::fontHeight ( ) const

Definition at line 1144 of file katerenderer.cpp.

◆ getSelectionBounds()

bool KateRenderer::getSelectionBounds ( int line,
int lineLength,
int & start,
int & end ) const

Definition at line 1159 of file katerenderer.cpp.

◆ increaseFontSizes()

void KateRenderer::increaseFontSizes ( qreal step = 1.0) const

Change to a different font (soon to be font set?)

Definition at line 145 of file katerenderer.cpp.

◆ isLineRightToLeft()

bool KateRenderer::isLineRightToLeft ( QStringView str)
static

This is a smaller QString::isRightToLeft().

It's also marked as internal to kate instead of internal to Qt, so we can modify. This method searches for the first strong character in the paragraph and then returns its direction. In case of a line without any strong characters, the direction is forced to be LTR.

Back in KDE 4.1 this method counted chars, which lead to unwanted side effects. (see https://bugs.kde.org/show_bug.cgi?id=178594). As this function is internal the way it work will probably change between releases. Be warned!

Definition at line 1426 of file katerenderer.cpp.

◆ isPrinterFriendly()

bool KateRenderer::isPrinterFriendly ( ) const
Returns
whether the renderer is configured to paint in a printer-friendly fashion.

Definition at line 167 of file katerenderer.cpp.

◆ layoutLine()

void KateRenderer::layoutLine ( KateLineLayout * line,
int maxwidth = -1,
bool cacheLayout = false ) const

Text width & height calculation functions...

Definition at line 1259 of file katerenderer.cpp.

◆ lineHeight()

int KateRenderer::lineHeight ( ) const

Definition at line 1154 of file katerenderer.cpp.

◆ paintSelection()

void KateRenderer::paintSelection ( QPaintDevice * d,
int startLine,
int xStart,
int endLine,
int xEnd,
int viewWidth,
qreal scale = 1.0 )

Paints a range of text into d.

This function is mainly used to paint the pixmap when dragging text.

Please note that this will not paint the selection background but only the text.

Parameters
dthe paint device
startLinestart line
xStartstart pos on startLine in pixels
endLineend line
xEndend pos on endLine in pixels
scalethe amount of scaling to apply. Default is 1.0, negative values are not supported

Definition at line 1504 of file katerenderer.cpp.

◆ paintTextBackground()

void KateRenderer::paintTextBackground ( QPainter & paint,
KateLineLayout * layout,
const QList< QTextLayout::FormatRange > & selRanges,
const QBrush & br,
int xStart ) const

Definition at line 616 of file katerenderer.cpp.

◆ paintTextLine()

void KateRenderer::paintTextLine ( QPainter & paint,
KateLineLayout * range,
int xStart,
int xEnd,
const QRectF & textClipRect = QRectF(),
const KTextEditor::Cursor * cursor = nullptr,
PaintTextLineFlags flags = PaintTextLineFlags() )

This is the ultimate function to perform painting of a text line.

The text line is painted from the upper limit of (0,0). To move that, apply a transform to your painter.

Parameters
paintpainter to use
rangelayout to use in painting this line
textClipRectclip rect for text to not paint lines outside the visible area.
xStartstarting width in pixels.
xEndending width in pixels.
cursorposition of the caret, if placed on the current line.
flagsflags for customizing the drawing of the line

Definition at line 685 of file katerenderer.cpp.

◆ paintTextLineBackground()

void KateRenderer::paintTextLineBackground ( QPainter & paint,
KateLineLayout * layout,
int currentViewLine,
int xStart,
int xEnd )

Paint the background of a line.

Split off from the main paintTextLine method to make it smaller. As it's being called only once per line it shouldn't noticably affect performance and it helps readability a LOT.

Parameters
paintpainter to use
layoutlayout to use in painting this line
currentViewLineif one of the view lines is the current line, set this to the index; otherwise -1.
xStartstarting width in pixels.
xEndending width in pixels.

Definition at line 181 of file katerenderer.cpp.

◆ resetFontSizes()

void KateRenderer::resetFontSizes ( ) const

Definition at line 152 of file katerenderer.cpp.

◆ setCaretOverrideColor()

void KateRenderer::setCaretOverrideColor ( const QColor & color)

Set a brush with which to override drawing of the caret.

Set to QColor() to clear.

Definition at line 1499 of file katerenderer.cpp.

◆ setCaretStyle()

void KateRenderer::setCaretStyle ( KTextEditor::caretStyles style)

Set the style of caret to be painted.

Parameters
stylestyle to set

Definition at line 96 of file katerenderer.cpp.

◆ setDrawCaret()

void KateRenderer::setDrawCaret ( bool drawCaret)

Set whether the caret (text cursor) will be drawn.

Parameters
drawCaretshould caret be drawn?

Definition at line 91 of file katerenderer.cpp.

◆ setIndentWidth()

void KateRenderer::setIndentWidth ( int indentWidth)

Sets the width of the tab.

Helps performance.

Parameters
indentWidthnew indent width

Definition at line 135 of file katerenderer.cpp.

◆ setPrinterFriendly()

void KateRenderer::setPrinterFriendly ( bool printerFriendly)

Configure this renderer to paint in a printer-friendly fashion.

Sets the other options appropriately if true.

Definition at line 172 of file katerenderer.cpp.

◆ setShowIndentLines()

void KateRenderer::setShowIndentLines ( bool showLines)

Set whether a guide should be painted to help identifying indent lines.

Parameters
showLinesshow the indent lines?

Definition at line 126 of file katerenderer.cpp.

◆ setShowNonPrintableSpaces()

void KateRenderer::setShowNonPrintableSpaces ( const bool showNonPrintableSpaces)

Set whether box should be drawn around non-printable spaces.

Definition at line 111 of file katerenderer.cpp.

◆ setShowSelections()

void KateRenderer::setShowSelections ( bool showSelections)

Set whether the view's selections should be shown.

The default is true.

Parameters
showSelectionsshow the selections?

Definition at line 140 of file katerenderer.cpp.

◆ setShowSpaces()

void KateRenderer::setShowSpaces ( KateDocumentConfig::WhitespaceRendering showSpaces)

Set which spaces should be rendered.

Definition at line 106 of file katerenderer.cpp.

◆ setShowTabs()

void KateRenderer::setShowTabs ( bool showTabs)

Set whether a mark should be painted to help identifying tabs.

Parameters
showTabsshow the tabs?

Definition at line 101 of file katerenderer.cpp.

◆ setTabWidth()

void KateRenderer::setTabWidth ( int tabWidth)

Sets the width of the tab.

Helps performance.

Parameters
tabWidthnew tab width

Definition at line 116 of file katerenderer.cpp.

◆ showIndentLines()

bool KateRenderer::showIndentLines ( ) const
Returns
whether indent lines should be shown
indent lines should be shown

Definition at line 121 of file katerenderer.cpp.

◆ showNonPrintableSpaces()

bool KateRenderer::showNonPrintableSpaces ( ) const
inline
Returns
whether non-printable spaces should be shown

Definition at line 189 of file katerenderer.h.

◆ showSelections()

bool KateRenderer::showSelections ( ) const
inline

Show the view's selection?

Returns
show sels?

Definition at line 227 of file katerenderer.h.

◆ showSpaces()

KateDocumentConfig::WhitespaceRendering KateRenderer::showSpaces ( ) const
inline
Returns
whether which spaces should be rendered

Definition at line 176 of file katerenderer.h.

◆ showTabs()

bool KateRenderer::showTabs ( ) const
inline
Returns
whether tabs should be shown (ie. a small mark drawn to identify a tab)
tabs should be shown

Definition at line 157 of file katerenderer.h.

◆ spaceWidth()

qreal KateRenderer::spaceWidth ( ) const

Definition at line 1254 of file katerenderer.cpp.

◆ specificAttribute()

KTextEditor::Attribute::Ptr KateRenderer::specificAttribute ( int context) const

Definition at line 82 of file katerenderer.cpp.

◆ updateAttributes()

void KateRenderer::updateAttributes ( )

update the highlighting attributes (for example after an hl change or after hl config changed)

Definition at line 68 of file katerenderer.cpp.

◆ updateConfig()

void KateRenderer::updateConfig ( )

Configuration.

Definition at line 1196 of file katerenderer.cpp.

◆ updateMarkerSize()

void KateRenderer::updateMarkerSize ( )

Update marker size shown.

Definition at line 1246 of file katerenderer.cpp.

◆ view()

KTextEditor::ViewPrivate * KateRenderer::view ( ) const
inline

Returns the view to which this renderer is bound.

Definition at line 106 of file katerenderer.h.

◆ xToCursor()

KTextEditor::Cursor KateRenderer::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.

If returnPastLine is true, the column will be extrapolated out with the assumption that the extra characters are spaces.

Definition at line 1482 of file katerenderer.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.