edbee - Qt Editor Library
|
This is the base and abstract class of a text document A TextDocument is the model part of the editor. More...
#include <textdocument.h>
Signals | |
void | textAboutToBeChanged (edbee::TextBufferChange change) |
void | textChanged (edbee::TextBufferChange change) |
void | persistedChanged (bool persisted) |
This signal is emitted if the persisted state is changed. More... | |
void | languageGrammarChanged () |
This signal is emitted if the grammar has been changed. More... | |
void | lastScopedOffsetChanged (int previousOffset, int lastScopedOffset) |
this signal is emitted if the scoped range has been changed More... | |
Public Member Functions | |
TextDocument (QObject *parent=0) | |
Constructs the textdocument. More... | |
virtual | ~TextDocument () |
Destroys the textdocument. More... | |
virtual TextBuffer * | buffer () const =0 |
This method should return the active textbuffer Warning you should NEVER directly modify the textbuffer unless you're absolutely sure what you're doing! More... | |
virtual void | setLineDataFieldsPerLine (int count) |
This method can be used to change the number of reserved fields by the document Increasing the amount will result in a realoc Decreasting the fieldcount reults in the lost of the 'old' fields At least the 'PredefinedFieldCount' amont of fields are required. More... | |
virtual TextLineDataManager * | lineDataManager ()=0 |
this method can be used to give a 'custom' line data item to a given line More... | |
virtual void | giveLineData (int line, int field, TextLineData *dataItem) |
This method gives a given data item to a text line. More... | |
virtual TextLineData * | getLineData (int line, int field) |
Returns the line specific data at the given line. More... | |
virtual TextDocumentScopes * | scopes ()=0 |
Should return the document-scopes of this document. More... | |
virtual TextCodec * | encoding ()=0 |
This method should return the current encoding. More... | |
virtual void | setEncoding (TextCodec *codec)=0 |
virtual const LineEnding * | lineEnding ()=0 |
This method should return the current line ending. More... | |
virtual void | setLineEnding (const LineEnding *lineENding)=0 |
virtual TextLexer * | textLexer ()=0 |
Should return the current document lexer. More... | |
virtual TextGrammar * | languageGrammar ()=0 |
This method should return the current language grammar. More... | |
virtual void | setLanguageGrammar (TextGrammar *grammar)=0 |
Changes the language grammar. This method should emit a grammarChanged signal (if the grammar is changed) More... | |
virtual TextUndoStack * | textUndoStack ()=0 |
this method should return a reference to the undo stack More... | |
virtual void | beginUndoGroup (ChangeGroup *group) |
Starts an undo group. More... | |
virtual void | endUndoGroup (int coalesceId, bool flatten=false) |
Ends the current undo group. More... | |
virtual void | endUndoGroupAndDiscard () |
Ends the undo group and discards all recorded information Warning it does NOT undo all made changes!!! More... | |
virtual bool | isUndoCollectionEnabled () |
this method return true if the undo stack is enabled More... | |
virtual void | setUndoCollectionEnabled (bool enabled) |
Enables or disables the collection of undo commands. More... | |
virtual bool | isUndoRunning () |
This method should return true if the current change is the cause of an undo operation. More... | |
virtual bool | isRedoRunning () |
Checks if currently an undo operation is running. More... | |
virtual bool | isUndoOrRedoRunning () |
Is it an undo or redo (which means all commands area already available) More... | |
virtual bool | isPersisted () |
Checks if the document is in a persited state. More... | |
virtual void | setPersisted (bool enabled=true) |
Calc this method to mark current state as persisted. More... | |
virtual TextEditorConfig * | config () const =0 |
this method should return the config More... | |
virtual void | setDocumentFilter (TextDocumentFilter *filter) |
Sets the document filter without tranfering the ownership. More... | |
virtual void | giveDocumentFilter (TextDocumentFilter *filter) |
this method sets the document filter You can give a 0 pointer to delte the old filter! More... | |
virtual TextDocumentFilter * | documentFilter () |
This method returns the document filter. More... | |
void | beginChanges (TextEditorController *controller) |
Start the changes. More... | |
void | replaceRangeSet (TextRangeSet &rangeSet, const QString &text) |
Replaces the given rangeset. More... | |
void | replaceRangeSet (TextRangeSet &rangeSet, const QStringList &texts) |
replaces the given rangeset More... | |
void | giveSelection (TextEditorController *controller, TextRangeSet *rangeSet) |
sets the selectioin for the current rangeset The selection may never be empty More... | |
void | endChanges (int coalesceId) |
Change * | executeAndGiveChange (Change *change, int coalesceId) |
call this method to execute a change. The change is first passed to the filter so the documentFilter can handle the processing of the change When not filter is active the 'execute' method is called on the change More... | |
virtual Change * | giveChangeWithoutFilter (Change *change, int coalesceId)=0 |
void | append (const QString &text, int coalesceId=0) |
Appends the given text to the document. More... | |
void | replace (int offset, int length, const QString &text, int coalesceId=0) |
Appends the given text. More... | |
void | setText (const QString &text) |
Changes the compelte document text. More... | |
void | rawAppendBegin () |
begins the raw append modes. In raw append mode data is directly streamed to the textdocument-buffer. No undo-data is collected and no events are fired More... | |
void | rawAppendEnd () |
When then raw appending is done. The events are fired that the document has been changed The undo-collection is enabled again. More... | |
void | rawAppend (QChar c) |
Appends a single char in raw append mode. More... | |
void | rawAppend (const QChar *chars, int length) |
Appends an array of characters. More... | |
int | length () |
Returns the length of the document in characters default implementation is to forward this call to the textbuffer. More... | |
int | lineCount () |
Returns the number of lines. More... | |
QChar | charAt (int idx) |
Returns the character at the given position. More... | |
QChar | charAtOrNull (int idx) |
returns the char at the given index if the index is valid else the null character is returned More... | |
int | offsetFromLine (int line) |
Retrieves the character-offset of the given line. More... | |
int | lineFromOffset (int offset) |
returns the line number which contains the given offset More... | |
int | columnFromOffsetAndLine (int offset, int line=-1) |
return the column position for the given offset and line More... | |
int | offsetFromLineAndColumn (int line, int column) |
Returns the character offset of the given line and column. More... | |
int | lineLength (int line) |
Returns the length of the given line. More... | |
int | lineLengthWithoutNewline (int line) |
returns the length of the given lilne without the newline More... | |
QString | text () |
Returns the document text as a QString. More... | |
QString | textPart (int offset, int length) |
Returns the given part of the text. More... | |
QString | lineWithoutNewline (int line) |
Returns the given line without the trailing character. More... | |
QString | line (int line) |
line the line number to retrieve More... | |
This is the base and abstract class of a text document A TextDocument is the model part of the editor.
It's the main owner of the following objects:
edbee::TextDocument::TextDocument | ( | QObject * | parent = 0 | ) |
Constructs the textdocument.
|
virtual |
Destroys the textdocument.
void edbee::TextDocument::append | ( | const QString & | text, |
int | coalesceId = 0 |
||
) |
Appends the given text to the document.
text | the text to append |
coalesceId | (default 0) the coalesceId to use. Whe using the same number changes could be merged to one change. CoalesceId of 0 means no merging |
void edbee::TextDocument::beginChanges | ( | TextEditorController * | controller | ) |
Start the changes.
|
virtual |
Starts an undo group.
group | the textchange group that groups the undo operations |
|
pure virtual |
This method should return the active textbuffer Warning you should NEVER directly modify the textbuffer unless you're absolutely sure what you're doing!
Implemented in edbee::CharTextDocument.
QChar edbee::TextDocument::charAt | ( | int | idx | ) |
Returns the character at the given position.
QChar edbee::TextDocument::charAtOrNull | ( | int | idx | ) |
returns the char at the given index if the index is valid else the null character is returned
idx | the index to retrieve |
int edbee::TextDocument::columnFromOffsetAndLine | ( | int | offset, |
int | line = -1 |
||
) |
return the column position for the given offset and line
offset | the offset position |
line | the line number which contains this offset. (When -1 the line number is calculated) |
|
pure virtual |
this method should return the config
Implemented in edbee::CharTextDocument.
|
virtual |
This method returns the document filter.
|
pure virtual |
This method should return the current encoding.
Implemented in edbee::CharTextDocument.
void edbee::TextDocument::endChanges | ( | int | coalesceId | ) |
|
virtual |
Ends the current undo group.
coalesceId | the coalesceId |
flatten | should the operation be flatten (flattens undo-group trees) |
|
virtual |
Ends the undo group and discards all recorded information Warning it does NOT undo all made changes!!!
call this method to execute a change. The change is first passed to the filter so the documentFilter can handle the processing of the change When not filter is active the 'execute' method is called on the change
WARNING, you should never Access the change pointer given to this method It's possible the change gets deleted
This method should return the effective text-change (or 0 if no text-change has been stored)
|
virtual |
Returns the line specific data at the given line.
line | the line number to retrieve the line data for |
field | the field to retrieve the data for |
|
pure virtual |
Implemented in edbee::CharTextDocument.
|
virtual |
this method sets the document filter You can give a 0 pointer to delte the old filter!
|
virtual |
This method gives a given data item to a text line.
void edbee::TextDocument::giveSelection | ( | TextEditorController * | controller, |
TextRangeSet * | rangeSet | ||
) |
sets the selectioin for the current rangeset The selection may never be empty
controller | the controller to given the selection for |
rangeSet | the rangeset with the new selection |
|
virtual |
Checks if the document is in a persited state.
|
virtual |
Checks if currently an undo operation is running.
|
virtual |
this method return true if the undo stack is enabled
|
virtual |
Is it an undo or redo (which means all commands area already available)
|
virtual |
This method should return true if the current change is the cause of an undo operation.
|
pure virtual |
This method should return the current language grammar.
Implemented in edbee::CharTextDocument.
|
signal |
This signal is emitted if the grammar has been changed.
|
signal |
this signal is emitted if the scoped range has been changed
int edbee::TextDocument::length | ( | ) |
Returns the length of the document in characters default implementation is to forward this call to the textbuffer.
QString edbee::TextDocument::line | ( | int | line | ) |
line the line number to retrieve
int edbee::TextDocument::lineCount | ( | ) |
Returns the number of lines.
|
pure virtual |
this method can be used to give a 'custom' line data item to a given line
Implemented in edbee::CharTextDocument.
|
pure virtual |
This method should return the current line ending.
Implemented in edbee::CharTextDocument.
int edbee::TextDocument::lineFromOffset | ( | int | offset | ) |
returns the line number which contains the given offset
offset | the character offset |
int edbee::TextDocument::lineLength | ( | int | line | ) |
Returns the length of the given line.
line | the line number |
int edbee::TextDocument::lineLengthWithoutNewline | ( | int | line | ) |
returns the length of the given lilne without the newline
line | the line number |
QString edbee::TextDocument::lineWithoutNewline | ( | int | line | ) |
Returns the given line without the trailing
character.
line | the line number to retrieve the data for |
int edbee::TextDocument::offsetFromLine | ( | int | line | ) |
Retrieves the character-offset of the given line.
line | the line number (0-based) to retrieve the offset for |
int edbee::TextDocument::offsetFromLineAndColumn | ( | int | line, |
int | column | ||
) |
Returns the character offset of the given line and column.
line | the line number |
column | the column position |
|
signal |
This signal is emitted if the persisted state is changed.
void edbee::TextDocument::rawAppend | ( | QChar | c | ) |
Appends a single char in raw append mode.
void edbee::TextDocument::rawAppend | ( | const QChar * | chars, |
int | length | ||
) |
Appends an array of characters.
void edbee::TextDocument::rawAppendBegin | ( | ) |
begins the raw append modes. In raw append mode data is directly streamed to the textdocument-buffer. No undo-data is collected and no events are fired
void edbee::TextDocument::rawAppendEnd | ( | ) |
When then raw appending is done. The events are fired that the document has been changed The undo-collection is enabled again.
void edbee::TextDocument::replace | ( | int | offset, |
int | length, | ||
const QString & | text, | ||
int | coalesceId = 0 |
||
) |
Appends the given text.
text | the text to append |
coalesceId | (default 0) the coalesceId to use. Whe using the same number changes could be merged to one change. CoalesceId of 0 means no merging |
void edbee::TextDocument::replaceRangeSet | ( | TextRangeSet & | rangeSet, |
const QString & | text | ||
) |
Replaces the given rangeset.
void edbee::TextDocument::replaceRangeSet | ( | TextRangeSet & | rangeSet, |
const QStringList & | texts | ||
) |
replaces the given rangeset
|
pure virtual |
Should return the document-scopes of this document.
Implemented in edbee::CharTextDocument.
|
virtual |
Sets the document filter without tranfering the ownership.
|
pure virtual |
Implemented in edbee::CharTextDocument.
|
pure virtual |
Changes the language grammar. This method should emit a grammarChanged signal (if the grammar is changed)
Implemented in edbee::CharTextDocument.
|
virtual |
This method can be used to change the number of reserved fields by the document Increasing the amount will result in a realoc Decreasting the fieldcount reults in the lost of the 'old' fields At least the 'PredefinedFieldCount' amont of fields are required.
This method can be used to change the number of reserved fields by the document Increasing the amount will result in a realoc Decreasting the fieldcount reults in the lost of the 'old' fields At least the 'PredefinedFieldCount' amont of fields are required This method EMPTIES the undo-stack. So after this call all undo history is gone!
|
pure virtual |
Implemented in edbee::CharTextDocument.
|
virtual |
Calc this method to mark current state as persisted.
void edbee::TextDocument::setText | ( | const QString & | text | ) |
Changes the compelte document text.
text | the new document text |
|
virtual |
Enables or disables the collection of undo commands.
QString edbee::TextDocument::text | ( | ) |
Returns the document text as a QString.
|
signal |
|
signal |
|
pure virtual |
Should return the current document lexer.
Implemented in edbee::CharTextDocument.
QString edbee::TextDocument::textPart | ( | int | offset, |
int | length | ||
) |
Returns the given part of the text.
offset | the character offset in the document |
length | the length of the part in characters |
|
pure virtual |
this method should return a reference to the undo stack
Implemented in edbee::CharTextDocument.