Kate
Kate::TextBuffer Class Reference
Class representing a text buffer. More...
#include <katetextbuffer.h>

Detailed Description
Class representing a text buffer.
The interface is line based, internally the text will be stored in blocks of text lines.
Definition at line 47 of file katetextbuffer.h.
Member Enumeration Documentation
End of line mode.
Definition at line 57 of file katetextbuffer.h.
Constructor & Destructor Documentation
| builddir build BUILD kdelibs kate buffer katetextbuffer cpp Kate::TextBuffer::TextBuffer | ( | KTextEditor::Document * | parent = 0, |
| int | blockSize = 64 |
||
| ) |
Construct an empty text buffer.
Empty means one empty line in one block.
- Parameters:
-
parent parent qobject blockSize block size in lines the buffer should try to hold, default 64 lines
Definition at line 35 of file katetextbuffer.cpp.
| Kate::TextBuffer::~TextBuffer | ( | ) | [virtual] |
Destruct the text buffer Virtual, we allow inheritance.
Definition at line 62 of file katetextbuffer.cpp.
Member Function Documentation
| void Kate::TextBuffer::clear | ( | ) | [virtual] |
Clears the buffer, reverts to initial empty state.
Empty means one empty line in one block. Virtual, can be overwritten.
Reimplemented in KateBuffer.
Definition at line 98 of file katetextbuffer.cpp.
| void Kate::TextBuffer::cleared | ( | ) | [signal] |
| void Kate::TextBuffer::debugPrint | ( | const QString & | title | ) | const |
Debug output, print whole buffer content with line numbers and line length.
- Parameters:
-
title title for this output
Definition at line 464 of file katetextbuffer.cpp.
| KTextEditor::Document* Kate::TextBuffer::document | ( | ) | const [inline] |
Gets the document to which this buffer is bound.
- Returns:
- a pointer to the document
Definition at line 398 of file katetextbuffer.h.
| bool Kate::TextBuffer::editingChangedBuffer | ( | ) | const [inline] |
Query information from the last editing transaction: was the content of the buffer changed? This is checked by comparing the editingLastRevision() with the current revision().
- Returns:
- content of buffer was changed in last transaction?
Definition at line 245 of file katetextbuffer.h.
| bool Kate::TextBuffer::editingChangedNumberOfLines | ( | ) | const [inline] |
Query information from the last editing transaction: was the number of lines of the buffer changed? This is checked by comparing the editingLastLines() with the current lines().
- Returns:
- content of buffer was changed in last transaction?
Definition at line 252 of file katetextbuffer.h.
| void Kate::TextBuffer::editingFinished | ( | ) | [signal] |
Editing transaction has finished.
| int Kate::TextBuffer::editingLastLines | ( | ) | const [inline] |
Query the number of lines of this buffer before the ongoing editing transactions.
- Returns:
- number of lines of buffer before current editing transaction altered it
Definition at line 238 of file katetextbuffer.h.
| qint64 Kate::TextBuffer::editingLastRevision | ( | ) | const [inline] |
Query the revsion of this buffer before the ongoing editing transactions.
- Returns:
- revision of buffer before current editing transaction altered it
Definition at line 232 of file katetextbuffer.h.
| int Kate::TextBuffer::editingMaximalLineChanged | ( | ) | const [inline] |
Get maximal line number changed by last editing transaction.
- Returns:
- maximal line number changed by last editing transaction, or -1, if none changed
Definition at line 264 of file katetextbuffer.h.
| int Kate::TextBuffer::editingMinimalLineChanged | ( | ) | const [inline] |
Get minimal line number changed by last editing transaction.
- Returns:
- maximal line number changed by last editing transaction, or -1, if none changed
Definition at line 258 of file katetextbuffer.h.
| void Kate::TextBuffer::editingStarted | ( | ) | [signal] |
Editing transaction has started.
| int Kate::TextBuffer::editingTransactions | ( | ) | const [inline] |
Query the number of editing transactions running atm.
- Returns:
- number of running transactions
Definition at line 226 of file katetextbuffer.h.
| KEncodingProber::ProberType Kate::TextBuffer::encodingProberType | ( | ) | const [inline] |
Get encoding prober type for this buffer.
- Returns:
- currently in use prober type of this buffer
Definition at line 95 of file katetextbuffer.h.
| EndOfLineMode Kate::TextBuffer::endOfLineMode | ( | ) | const [inline] |
| QTextCodec* Kate::TextBuffer::fallbackTextCodec | ( | ) | const [inline] |
Get fallback codec for this buffer.
- Returns:
- currently in use fallback codec of this buffer
Definition at line 107 of file katetextbuffer.h.
| bool Kate::TextBuffer::finishEditing | ( | ) | [virtual] |
Finish an editing transaction.
Only allowed to be called if editing transaction is started.
- Returns:
- returns true, if this finished last running transaction Virtual, can be overwritten.
Definition at line 183 of file katetextbuffer.cpp.
| bool Kate::TextBuffer::generateByteOrderMark | ( | ) | const [inline] |
Generate byte order mark on save?
- Returns:
- should BOM be generated?
Definition at line 133 of file katetextbuffer.h.
| TextHistory& Kate::TextBuffer::history | ( | ) | [inline] |
TextHistory of this buffer.
- Returns:
- text history for this buffer
Definition at line 299 of file katetextbuffer.h.
| void Kate::TextBuffer::insertText | ( | const KTextEditor::Cursor & | position, |
| const QString & | text | ||
| ) | [virtual] |
Insert text at given cursor position.
Does nothing if text is empty, beside some consistency checks.
- Parameters:
-
position position where to insert text text text to insert Virtual, can be overwritten.
Definition at line 290 of file katetextbuffer.cpp.
| void Kate::TextBuffer::invalidateRanges | ( | ) |
Invalidate all ranges in this buffer.
Definition at line 90 of file katetextbuffer.cpp.
| TextLine Kate::TextBuffer::line | ( | int | line | ) | const |
Retrieve a text line.
- Parameters:
-
line wanted line number
- Returns:
- text line
Definition at line 140 of file katetextbuffer.cpp.
| int Kate::TextBuffer::lines | ( | ) | const [inline] |
Lines currently stored in this buffer.
This is never 0, even clear will let one empty line remain.
Definition at line 184 of file katetextbuffer.h.
| void Kate::TextBuffer::lineUnwrapped | ( | int | line | ) | [signal] |
A line got unwrapped.
- Parameters:
-
line line where the unwrap occured
| void Kate::TextBuffer::lineWrapped | ( | const KTextEditor::Cursor & | position | ) | [signal] |
A line got wrapped.
- Parameters:
-
position position where the wrap occured
Load the given file.
This will first clear the buffer and then load the file. Even on error during loading the buffer will still be cleared. Before calling this, setTextCodec must have been used to set codec!
- Parameters:
-
filename file to open encodingErrors were there problems occured while decoding the file?
- Returns:
- success, the file got loaded, perhaps with encoding errors Virtual, can be overwritten.
first: clear buffer in any case!
check if this is a normal file or not, else exit
construct the file loader for the given file, with correct prober type
triple play, maximal three loading rounds 0) use the given encoding, be done, if no encoding errors happen 1) use BOM to decided if unicode or if that fails, use encoding prober, if no encoding errors happen, be done 2) use fallback encoding, be done, if no encoding errors happen 3) use again given encoding, be done in any case
kill all blocks beside first one
remove lines in first block
try to open file, with given encoding in round 0 + 3 use the given encoding from user in round 1 use 0, to trigger detection in round 2 use fallback
Definition at line 474 of file katetextbuffer.cpp.
Buffer loaded successfully a file.
- Parameters:
-
filename file which was loaded encodingErrors were there problems occured while decoding the file?
Check if the given range pointer is still valid.
- Returns:
- range pointer still belongs to range for this buffer
Definition at line 419 of file katetextbuffer.h.
| QList< TextRange * > Kate::TextBuffer::rangesForLine | ( | int | line, |
| KTextEditor::View * | view, | ||
| bool | rangesWithAttributeOnly | ||
| ) | const |
Return the ranges which affect the given line.
- Parameters:
-
line line to look at view only return ranges associated with given view rangesWithAttributeOnly only return ranges which have a attribute set
- Returns:
- list of ranges affecting this line
we want only ranges with attributes, but this one has none
we want ranges for no view, but this one's attribute is only valid for views
the range's attribute is not valid for this view
if line is in the range, ok
Definition at line 729 of file katetextbuffer.cpp.
| void Kate::TextBuffer::removeText | ( | const KTextEditor::Range & | range | ) | [virtual] |
Remove text at given range.
Does nothing if range is empty, beside some consistency checks.
- Parameters:
-
range range of text to remove, must be on one line only. Virtual, can be overwritten.
Definition at line 319 of file katetextbuffer.cpp.
| bool Kate::TextBuffer::removeTrailingSpaces | ( | ) | const [inline] |
Should trailing spaces be removed on load/save.
- Returns:
- should trailing spaces be removed on load/save?
Definition at line 158 of file katetextbuffer.h.
| qint64 Kate::TextBuffer::revision | ( | ) | const [inline] |
Revision of this buffer.
Is set to 0 on construction, clear() (load will trigger clear()). Is incremented on each change to the buffer.
- Returns:
- current revision
Definition at line 191 of file katetextbuffer.h.
Save the current buffer content to the given file.
Before calling this, setTextCodec and setFallbackTextCodec must have been used to set codec!
- Parameters:
-
filename file to save
- Returns:
- success Virtual, can be overwritten.
construct correct filter device and try to open
construct stream + disable Unicode headers
Definition at line 611 of file katetextbuffer.cpp.
| void Kate::TextBuffer::saved | ( | const QString & | filename | ) | [signal] |
Buffer saved successfully a file.
- Parameters:
-
filename file which was saved
| void Kate::TextBuffer::setEncodingProberType | ( | KEncodingProber::ProberType | proberType | ) | [inline] |
Set encoding prober type for this buffer to use for load.
- Parameters:
-
proberType prober type to use for encoding
Definition at line 89 of file katetextbuffer.h.
| void Kate::TextBuffer::setEndOfLineMode | ( | EndOfLineMode | endOfLineMode | ) | [inline] |
Set end of line mode for this buffer, not allowed to be set to unknown.
Loading might overwrite this setting, if there is a eol found inside the file.
- Parameters:
-
endOfLineMode new eol mode
Definition at line 140 of file katetextbuffer.h.
| void Kate::TextBuffer::setFallbackTextCodec | ( | QTextCodec * | codec | ) | [inline] |
Set fallback codec for this buffer to use for load.
- Parameters:
-
codec fallback QTextCodec to use for encoding
Definition at line 101 of file katetextbuffer.h.
| void Kate::TextBuffer::setGenerateByteOrderMark | ( | bool | generateByteOrderMark | ) | [inline] |
Generate byte order mark on save.
Loading might overwrite this setting, if there is a BOM found inside the file.
- Parameters:
-
generateByteOrderMark should BOM be generated?
Definition at line 127 of file katetextbuffer.h.
| void Kate::TextBuffer::setRemoveTrailingSpaces | ( | bool | removeTrailingSpaces | ) | [inline] |
Specify if the buffer should remove trailing spaces while loading/saving files.
- Parameters:
-
removeTrailingSpaces should trailing spaces be removed on load/save?
Definition at line 152 of file katetextbuffer.h.
| void Kate::TextBuffer::setTextCodec | ( | QTextCodec * | codec | ) | [inline] |
Set codec for this buffer to use for load/save.
Loading might overwrite this, if it encounters problems and finds a better codec.
- Parameters:
-
codec QTextCodec to use for encoding
Definition at line 114 of file katetextbuffer.h.
| bool Kate::TextBuffer::startEditing | ( | ) | [virtual] |
Start an editing transaction, the wrapLine/unwrapLine/insertText and removeText functions are only to be allowed to be called inside a editing transaction.
Editing transactions can stack. The number startEdit and endEdit calls must match.
- Returns:
- returns true, if no transaction was already running Virtual, can be overwritten.
Definition at line 161 of file katetextbuffer.cpp.
| QString Kate::TextBuffer::text | ( | ) | const |
Retrieve text of complete buffer.
- Returns:
- text for this buffer, lines separated by '
'
Definition at line 149 of file katetextbuffer.cpp.
| QTextCodec* Kate::TextBuffer::textCodec | ( | ) | const [inline] |
Get codec for this buffer.
- Returns:
- currently in use codec of this buffer
Definition at line 120 of file katetextbuffer.h.
| void Kate::TextBuffer::textInserted | ( | const KTextEditor::Cursor & | position, |
| const QString & | text | ||
| ) | [signal] |
Text got inserted.
- Parameters:
-
position position where the insertion occured text inserted text
| void Kate::TextBuffer::textRemoved | ( | const KTextEditor::Range & | range, |
| const QString & | text | ||
| ) | [signal] |
Text got removed.
- Parameters:
-
range range where the removal occured text removed text
| void Kate::TextBuffer::unwrapLine | ( | int | line | ) | [virtual] |
Unwrap given line.
- Parameters:
-
line line to unwrap Virtual, can be overwritten.
Reimplemented in KateBuffer.
Definition at line 244 of file katetextbuffer.cpp.
| void Kate::TextBuffer::wrapLine | ( | const KTextEditor::Cursor & | position | ) | [virtual] |
Wrap line at given cursor position.
- Parameters:
-
position line/column as cursor where to wrap Virtual, can be overwritten.
Reimplemented in KateBuffer.
Definition at line 208 of file katetextbuffer.cpp.
The documentation for this class was generated from the following files:
KDE 4.6 API Reference