Search for usage in LXR

Kate::TextBlock Class Reference

#include <katetextblock.h>

Public Member Functions

 TextBlock (TextBuffer *buffer, int startLine)
 ~TextBlock ()
void appendLine (const QString &textOfLine)
QSet< TextRange * > cachedRangesForLine (int line) const
void clearBlockContent (TextBlock *targetBlock)
void clearLines ()
bool containsRange (TextRange *range) const
void debugPrint (int blockIndex) const
void deleteBlockContent ()
void insertCursor (Kate::TextCursor *cursor)
void insertText (const KTextEditor::Cursor position, const QString &text)
TextLine line (int line) const
int lineLength (int line) const
int lines () const
void markModifiedLinesAsSaved ()
void mergeBlock (TextBlock *targetBlock)
QVector< TextRange * > rangesForLine (int line, KTextEditor::View *view, bool rangesWithAttributeOnly) const
void removeCursor (Kate::TextCursor *cursor)
void removeRange (TextRange *range)
void removeText (KTextEditor::Range range, QString &removedText)
void setStartLine (int startLine)
TextBlocksplitBlock (int fromLine)
int startLine () const
void text (QString &text) const
void unwrapLine (int line, TextBlock *previousBlock, int fixStartLinesStartIndex)
void updateRange (TextRange *range)
void wrapLine (const KTextEditor::Cursor position, int fixStartLinesStartIndex)

Detailed Description

Class representing a text block.

This is used to build up a Kate::TextBuffer. This class should only be used by TextBuffer/Cursor/Range.

Definition at line 40 of file katetextblock.h.

Constructor & Destructor Documentation

◆ TextBlock()

Kate::TextBlock::TextBlock ( TextBuffer buffer,
int  startLine 

Construct an empty text block.

bufferparent text buffer
startLinestart line of this block

Definition at line 15 of file katetextblock.cpp.

◆ ~TextBlock()

Kate::TextBlock::~TextBlock ( )

Destruct the text block.

Definition at line 23 of file katetextblock.cpp.

Member Function Documentation

◆ appendLine()

void Kate::TextBlock::appendLine ( const QString textOfLine)

Append a new line with given text.

textOfLinetext of the line to append

Definition at line 50 of file katetextblock.cpp.

◆ cachedRangesForLine()

QSet<TextRange *> Kate::TextBlock::cachedRangesForLine ( int  line) const

Return all ranges in this block which might intersect the given line and only span one line.

For them an internal fast lookup cache is hold.

lineline to check intersection
set of ranges

Definition at line 238 of file katetextblock.h.

◆ clearBlockContent()

void Kate::TextBlock::clearBlockContent ( TextBlock targetBlock)

Clear the block content, delete all lines, move all cursors not bound to range to given block at 0,0.

This is used by clear() of TextBuffer.

targetBlockempty target block for cursors

Definition at line 602 of file katetextblock.cpp.

◆ clearLines()

void Kate::TextBlock::clearLines ( )

Clear the lines.

Definition at line 55 of file katetextblock.cpp.

◆ containsRange()

bool Kate::TextBlock::containsRange ( TextRange range) const

Is the given range contained in this block?

rangerange to check for
contained in this blocks mapping?

Definition at line 191 of file katetextblock.h.

◆ debugPrint()

void Kate::TextBlock::debugPrint ( int  blockIndex) const

Debug output, print whole block content with line numbers and line length.

blockIndexindex of this block in buffer

Definition at line 489 of file katetextblock.cpp.

◆ deleteBlockContent()

void Kate::TextBlock::deleteBlockContent ( )

Delete the block content, delete all lines and delete all cursors not bound to ranges.

This is used in destructor of TextBuffer, for fast cleanup. Only stuff remaining afterwards are cursors which are part of a range, TextBuffer will delete them itself...

Definition at line 578 of file katetextblock.cpp.

◆ insertCursor()

void Kate::TextBlock::insertCursor ( Kate::TextCursor cursor)

Insert cursor into this block.

cursorcursor to insert

Definition at line 205 of file katetextblock.h.

◆ insertText()

void Kate::TextBlock::insertText ( const KTextEditor::Cursor  position,
const QString text 

Insert text at given cursor position.

positionposition where to insert text
texttext to insert

Definition at line 351 of file katetextblock.cpp.

◆ line()

TextLine Kate::TextBlock::line ( int  line) const

Retrieve a text line.

linewanted line number
text line

Definition at line 41 of file katetextblock.cpp.

◆ lineLength()

int Kate::TextBlock::lineLength ( int  line) const

Retrieve length for line.

linewanted line number
length of line

Definition at line 82 of file katetextblock.h.

◆ lines()

int Kate::TextBlock::lines ( ) const

Number of lines in this block.

number of lines

Definition at line 103 of file katetextblock.h.

◆ markModifiedLinesAsSaved()

void Kate::TextBlock::markModifiedLinesAsSaved ( )

Flag all modified text lines as saved on disk.

Definition at line 659 of file katetextblock.cpp.

◆ mergeBlock()

void Kate::TextBlock::mergeBlock ( TextBlock targetBlock)

Merge this block with given one, the given one must be a direct predecessor.

targetBlockblock to merge with

Definition at line 546 of file katetextblock.cpp.

◆ rangesForLine()

QVector< TextRange * > Kate::TextBlock::rangesForLine ( int  line,
KTextEditor::View view,
bool  rangesWithAttributeOnly 
) const

Return all ranges in this block which might intersect the given line.

lineline to check intersection
viewonly return ranges associated with given view
rangesWithAttributeOnlyranges with attributes only?
list of possible candidate ranges

Definition at line 626 of file katetextblock.cpp.

◆ removeCursor()

void Kate::TextBlock::removeCursor ( Kate::TextCursor cursor)

Remove cursor from this block.

cursorcursor to remove

Definition at line 214 of file katetextblock.h.

◆ removeRange()

void Kate::TextBlock::removeRange ( TextRange range)

Remove a range from this block.

rangerange to remove

Definition at line 718 of file katetextblock.cpp.

◆ removeText()

void Kate::TextBlock::removeText ( KTextEditor::Range  range,
QString removedText 

Remove text at given range.

rangerange of text to remove, must be on one line only.
removedTextwill be filled with removed text

Definition at line 420 of file katetextblock.cpp.

◆ setStartLine()

void Kate::TextBlock::setStartLine ( int  startLine)

Set start line of this block.

startLinenew start line of this block

Definition at line 32 of file katetextblock.cpp.

◆ splitBlock()

TextBlock * Kate::TextBlock::splitBlock ( int  fromLine)

Split given block.

A new block will be created and all lines starting from the given index will be moved to it, together with the cursors belonging to it.

fromLineline from which to split
new block containing the lines + cursors removed from this one

Definition at line 497 of file katetextblock.cpp.

◆ startLine()

int Kate::TextBlock::startLine ( ) const

Start line of this block.

start line of this block

Definition at line 59 of file katetextblock.h.

◆ text()

void Kate::TextBlock::text ( QString text) const

Retrieve text of block.

textfor this block, lines separated by '

Definition at line 60 of file katetextblock.cpp.

◆ unwrapLine()

void Kate::TextBlock::unwrapLine ( int  line,
TextBlock previousBlock,
int  fixStartLinesStartIndex 

Unwrap given line.

lineline to unwrap
previousBlockprevious block, if any, if we unwrap first line in block, we need to have this
fixStartLinesStartIndexstart index to fix start lines, normally this is this block or the previous one

Definition at line 180 of file katetextblock.cpp.

◆ updateRange()

void Kate::TextBlock::updateRange ( TextRange range)

Update a range from this block.

Will move the range to right set, either cached for one-line ranges or not.

rangerange to update

Definition at line 669 of file katetextblock.cpp.

◆ wrapLine()

void Kate::TextBlock::wrapLine ( const KTextEditor::Cursor  position,
int  fixStartLinesStartIndex 

Wrap line at given cursor position.

positionline/column as cursor where to wrap
fixStartLinesStartIndexstart index to fix start lines, normally this is this block

Definition at line 73 of file katetextblock.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 03:52:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.