• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • Kate
  • TextBlock
Public Member Functions | List of all members
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 lines () const
 
void markModifiedLinesAsSaved ()
 
void mergeBlock (TextBlock *targetBlock)
 
QList< QSet< TextRange * > > rangesForLine (int line) const
 
void removeCursor (Kate::TextCursor *cursor)
 
void removeRange (TextRange *range)
 
void removeText (const KTextEditor::Range &range, QString &removedText)
 
void setStartLine (int startLine)
 
TextBlock * splitBlock (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 42 of file katetextblock.h.

Constructor & Destructor Documentation

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

Construct an empty text block.

Parameters
bufferparent text buffer
startLinestart line of this block

Definition at line 26 of file katetextblock.cpp.

Kate::TextBlock::~TextBlock ( )

Destruct the text block.

Definition at line 34 of file katetextblock.cpp.

Member Function Documentation

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

Append a new line with given text.

Parameters
textOfLinetext of the line to append

Definition at line 67 of file katetextblock.cpp.

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

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.

Parameters
lineline to check intersection
Returns
set of ranges

Definition at line 215 of file katetextblock.h.

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.

Parameters
targetBlockempty target block for cursors

Definition at line 556 of file katetextblock.cpp.

void Kate::TextBlock::clearLines ( )

Clear the lines.

Definition at line 72 of file katetextblock.cpp.

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

Is the given range contained in this block?

Parameters
rangerange to check for
Returns
contained in this blocks mapping?

Definition at line 175 of file katetextblock.h.

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

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

Parameters
blockIndexindex of this block in buffer

Definition at line 472 of file katetextblock.cpp.

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 544 of file katetextblock.cpp.

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

Insert cursor into this block.

Parameters
cursorcursor to insert

Definition at line 188 of file katetextblock.h.

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

Insert text at given cursor position.

Parameters
positionposition where to insert text
texttext to insert

notify the text history

cursor and range handling below

Definition at line 347 of file katetextblock.cpp.

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

Retrieve a text line.

Parameters
linewanted line number
Returns
text line

Definition at line 52 of file katetextblock.cpp.

int Kate::TextBlock::lines ( ) const
inline

Number of lines in this block.

Returns
number of lines

Definition at line 90 of file katetextblock.h.

void Kate::TextBlock::markModifiedLinesAsSaved ( )

Flag all modified text lines as saved on disk.

Definition at line 574 of file katetextblock.cpp.

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

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

Parameters
targetBlockblock to merge with

Definition at line 519 of file katetextblock.cpp.

QList<QSet<TextRange*> > Kate::TextBlock::rangesForLine ( int  line) const
inline

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

Parameters
lineline to check intersection
Returns
list of sets of possible candidate ranges

Definition at line 166 of file katetextblock.h.

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

Remove cursor from this block.

Parameters
cursorcursor to remove

Definition at line 194 of file katetextblock.h.

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

Remove a range from this block.

Parameters
rangerange to remove

uncached range? remove it and be done

must be only uncached!

cached range?

must be only cached!

query the range from cache, must be there

remove it and be done

else: range was not for this block, just do nothing, removeRange should be "safe" to use

Definition at line 647 of file katetextblock.cpp.

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

Remove text at given range.

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

notify the text history

cursor and range handling below

Definition at line 409 of file katetextblock.cpp.

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

Set start line of this block.

Parameters
startLinenew start line of this block

Definition at line 43 of file katetextblock.cpp.

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.

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

Definition at line 480 of file katetextblock.cpp.

int Kate::TextBlock::startLine ( ) const
inline

Start line of this block.

Returns
start line of this block

Definition at line 60 of file katetextblock.h.

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

Retrieve text of block.

Parameters
textfor this block, lines separated by '
'

Definition at line 77 of file katetextblock.cpp.

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

Unwrap given line.

Parameters
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

fix all start lines we need to do this NOW, else the range update will FAIL! bug 313759

notify the text history in advance

cursor and range handling below

fix all start lines we need to do this NOW, else the range update will FAIL! bug 313759

notify the text history in advance

cursor and range handling below

Definition at line 189 of file katetextblock.cpp.

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.

Parameters
rangerange to update

get some simple facts about our nice range

perhaps remove range and be done

The range is still a single-line range, and is still cached to the correct line.

The range is still a multi-line range, and is already in the correct set.

remove, if already there!

simple case: multi-line range

The range cannot be cached per line, as it spans multiple lines

The range is contained by a single line, put it into the line-cache

enlarge cache if needed

insert into mapping

Definition at line 584 of file katetextblock.cpp.

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

Wrap line at given cursor position.

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

fix all start lines we need to do this NOW, else the range update will FAIL! bug 313759

notify the text history

cursor and range handling below

Definition at line 89 of file katetextblock.cpp.


The documentation for this class was generated from the following files:
  • katetextblock.h
  • katetextblock.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:57:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal