QCodeEdit
2.2
|
A class storing a document. More...
Classes | |
struct | PaintContext |
Signals | |
void | cleanChanged (bool m) |
void | undoAvailable (bool y) |
void | redoAvailable (bool y) |
void | formatsChanged () |
void | contentsChanged () |
void | formatsChange (int line, int lines) |
void | contentsChange (int line, int lines) |
void | widthChanged (int width) |
void | heightChanged (int height) |
void | sizeChanged (const QSize &s) |
void | lineCountChanged (int n) |
void | visualLineCountChanged (int n) |
void | lineDeleted (QDocumentLineHandle *h) |
void | markChanged (QDocumentLineHandle *l, int m, bool on) |
void | lineEndingChanged (int lineEnding) |
Public Member Functions | |
QDocumentPrivate * | impl () |
void | markViewDirty () |
Friends | |
class | QMatcher |
class | QDocumentPrivate |
class | QDocumentCommand |
QDocument (QObject *p=0) | |
ctor | |
virtual | ~QDocument () |
dtor | |
QString | text (int mode) const |
QString | text (bool removeTrailing=false, bool preserveIndent=true) const |
void | setText (const QString &s) |
Set the content of the document. | |
void | startChunkLoading () |
Start a chunk loading. More... | |
void | stopChunkLoading () |
Stop chunk loading. More... | |
void | addChunk (const QString &txt) |
Add a chunk of text to the document. | |
LineEnding | lineEnding () const |
LineEnding | originalLineEnding () const |
void | setLineEnding (LineEnding le) |
Set the line ending policy of the document. | |
QDateTime | lastModified () const |
void | setLastModified (const QDateTime &d) |
set the date/time of the last modification of the document More... | |
bool | canUndo () const |
bool | canRedo () const |
int | width () const |
int | height () const |
int | widthConstraint () const |
int | lines () const |
int | lineCount () const |
int | visualLines () const |
int | visualLineCount () const |
int | visualLineNumber (int textLineNumber) const |
Convert a text (logical) line number int a visual line number. More... | |
int | textLineNumber (int visualLineNumber) const |
Convert a visual line number int a text (logical) line number. More... | |
int | y (int line) const |
int | lineNumber (int ypos, int *wrap=0) const |
int | y (const QDocumentLine &l) const |
QRect | lineRect (int line) const |
QRect | lineRect (const QDocumentLine &l) const |
QDocumentCursor * | editCursor () const |
Set the edit cursor. More... | |
void | setEditCursor (QDocumentCursor *c) |
Set the edit cursor. More... | |
QLanguageDefinition * | languageDefinition () const |
void | setLanguageDefinition (QLanguageDefinition *l) |
Set the language definition. | |
int | maxMarksPerLine () const |
int | findNextMark (int id, int from=0, int until=-1) const |
Find the next mark of a given type. More... | |
int | findPreviousMark (int id, int from=-1, int until=0) const |
Find the previous mark of a given type. More... | |
QDocumentLine | lineAt (const QPoint &p) const |
void | cursorForDocumentPosition (const QPoint &p, int &line, int &column) const |
Convert a document (or viewport) (x, y) position to a (line, column) cursor position. More... | |
QDocumentCursor | cursorAt (const QPoint &p) const |
QDocumentLine | line (int line) const |
QDocumentLine | line (QDocumentConstIterator iterator) const |
QDocumentCursor | cursor (int line, int column=0) const |
QDocumentLine | findLine (int &position) const |
bool | isLineModified (const QDocumentLine &l) const |
bool | hasLineEverBeenModified (const QDocumentLine &l) const |
virtual void | draw (QPainter *p, PaintContext &cxt) |
Draw the contents of the document. More... | |
void | execute (QDocumentCommand *cmd) |
Execute a document command (editing operation) | |
QDocumentConstIterator | begin () const |
QDocumentConstIterator | end () const |
QDocumentConstIterator | iterator (int ln) const |
QDocumentConstIterator | iterator (const QDocumentLine &l) const |
void | beginMacro () |
Begin a macro. More... | |
void | endMacro () |
End a macro. | |
QFormatScheme * | formatScheme () const |
void | setFormatScheme (QFormatScheme *f) |
Set the format scheme used by the document. | |
int | getNextGroupId () |
Get an available group id for matches. | |
void | releaseGroupId (int groupId) |
void | clearMatches (int groupId) |
Clear matches. | |
void | flushMatches (int groupId) |
void | addMatch (int groupId, int line, int pos, int len, int format) |
Highlight the matched sequences. More... | |
bool | isClean () const |
static QFont | font () |
static void | setFont (const QFont &f) |
Set the font of ALL documents. More... | |
static const QFontMetrics & | fontMetrics () |
static LineEnding | defaultLineEnding () |
static void | setDefaultLineEnding (LineEnding le) |
Set the default line ending policy. More... | |
static int | tabStop () |
static void | setTabStop (int n) |
Set the default tab stop common to all documents. More... | |
static WhiteSpaceMode | showSpaces () |
static void | setShowSpaces (WhiteSpaceMode y) |
Set the whitespace display mode. | |
static QFormatScheme * | defaultFormatScheme () |
static void | setDefaultFormatScheme (QFormatScheme *f) |
Set the default format scheme. More... | |
static QFormatScheme * | formatFactory () |
Compatibility alias for defaultFormatScheme() More... | |
static void | setFormatFactory (QFormatScheme *f) |
Compatibility alias for setDefaultFormatScheme() More... | |
static int | screenLength (const QChar *d, int l, int tabStop) |
static QString | screenable (const QChar *d, int l, int tabStop) |
void | clear () |
Clear the content of the document. | |
void | undo () |
Undo the last editing operation. | |
void | redo () |
Redo the last undone editing operation. | |
void | setClean () |
Set the document to clean state. More... | |
void | highlight () |
Update the formatting of the whole document This function is only useful when changing the language definition of a non-empty document. Make sure you do not call it more often than needed. | |
void | print (QPrinter *p) |
Print the content of the document. More... | |
void | clearWidthConstraint () |
Clear the width constraint, if any. | |
void | setWidthConstraint (int width) |
Set a new width constraint. More... | |
A class storing a document.
QCE uses an architecture very similar to that of QTextEdit/QTextDocument which closely ressembles model/view. The document holds all the textual and formatting data. It offers some (mostly indirect) ways of modifying its content and is usable without any GUI.
In QCE, a document is merely a list of QDocumentLine objects on which some extra formatting can be applied and which can be wrapped/hidden in various ways.
The document model has been designed with three goals in mind :
QDocument supports Bidi by using QTextLayout on lines that require it and prefers custom rendering in other cases to achieve the above goals.
All the actual text editing is done through QDocumentCursor objects.
void QDocument::addMatch | ( | int | gid, |
int | line, | ||
int | pos, | ||
int | len, | ||
int | format | ||
) |
Highlight the matched sequences.
References QDocumentPrivate::addMatch(), and line().
Referenced by QDocumentSearch::setOption().
QDocumentConstIterator QDocument::begin | ( | ) | const |
Referenced by iterator().
void QDocument::beginMacro | ( | ) |
Begin a macro.
Macro in QDocument map directly to macro in the underlying undo stack
Referenced by QEditor::commentSelection(), QEditor::cut(), QEditor::indentSelection(), QEditor::insertFromMimeData(), QEditor::uncommentSelection(), QEditor::unindentSelection(), and QEditor::write().
bool QDocument::canRedo | ( | ) | const |
Referenced by QEditor::canRedo().
bool QDocument::canUndo | ( | ) | const |
Referenced by QEditor::canUndo().
QDocumentCursor QDocument::cursor | ( | int | line, |
int | column = 0 |
||
) | const |
line | target line number (text line) |
column | target text column |
References line().
QDocumentCursor QDocument::cursorAt | ( | const QPoint & | p | ) | const |
References cursorForDocumentPosition().
Referenced by QEditor::cursorForPosition().
void QDocument::cursorForDocumentPosition | ( | const QPoint & | p, |
int & | line, | ||
int & | column | ||
) | const |
Convert a document (or viewport) (x, y) position to a (line, column) cursor position.
p | document position |
line | where the line number will be stored |
column | where the column (text position within line) will be stored |
References line(), and lineNumber().
Referenced by cursorAt().
|
static |
Referenced by formatFactory().
|
static |
Referenced by QEditConfig::cancel().
|
virtual |
Draw the contents of the document.
p | painter to use |
cxt | paint context (specifies what part of the document to draw, among other things) |
Referenced by print().
QDocumentCursor * QDocument::editCursor | ( | ) | const |
Set the edit cursor.
Archaic concept designed for use in QEditor (is it still used???)
QDocumentConstIterator QDocument::end | ( | ) | const |
Referenced by iterator().
QDocumentLine QDocument::findLine | ( | int & | position | ) | const |
int QDocument::findNextMark | ( | int | id, |
int | from = 0 , |
||
int | until = -1 |
||
) | const |
Find the next mark of a given type.
id | mark identifier to find |
from | line from which to start search |
until | line until which to search |
from and until can be negatives, in which case they indicate positions from the end of the document (i.e -1 is last line, -2 the line before last line and so on).
If until is inferior to from and no matching mark is found in the [from, end] range then the [0, until] range will also be searched.
int QDocument::findPreviousMark | ( | int | id, |
int | from = -1 , |
||
int | until = 0 |
||
) | const |
Find the previous mark of a given type.
id | mark identifier to find |
from | line from which to start search |
until | line until which to search |
from and until can be negatives, in which case they indicate positions from the end of the document (i.e -1 is last line, -2 the line before last line and so on).
If until is superior to from and no matching mark is found in the [0, from] range then the [until, end] range will also be searched (both range being searched backward, of course).
void QDocument::flushMatches | ( | int | gid | ) |
\
Referenced by QNFADefinition::clearMatches(), QNFADefinition::match(), and QDocumentSearch::setOption().
|
static |
This font is also used to do calculations (such as converting (line, column) cursor position to (x, y) document position (or the inverse transformation))
Referenced by QEditConfig::cancel(), QFoldPanel::paint(), and QEditor::zoom().
|
static |
Referenced by QEditor::ensureCursorVisible(), QEditor::ensureVisible(), QEditor::isCursorVisible(), QEditor::pageDown(), and QEditor::pageUp().
|
static |
Compatibility alias for defaultFormatScheme()
References defaultFormatScheme().
Referenced by QDocumentSearch::setOption().
QFormatScheme * QDocument::formatScheme | ( | ) | const |
Referenced by QFormatConfig::apply(), QNFADefinition::match(), and QDocumentSearch::setOption().
bool QDocument::hasLineEverBeenModified | ( | const QDocumentLine & | l | ) | const |
int QDocument::height | ( | ) | const |
Referenced by QEditor::load(), and QEditor::setText().
bool QDocument::isClean | ( | ) | const |
This is undo stak terminology. A clean document is one whose undo stack is at the same index it was upon last save/load. In other words : clean = !modified
Referenced by QEditor::isContentModified().
bool QDocument::isLineModified | ( | const QDocumentLine & | l | ) | const |
QDocumentConstIterator QDocument::iterator | ( | int | ln | ) | const |
References begin().
Referenced by line(), and setClean().
QDocumentConstIterator QDocument::iterator | ( | const QDocumentLine & | l | ) | const |
QLanguageDefinition * QDocument::languageDefinition | ( | ) | const |
QDateTime QDocument::lastModified | ( | ) | const |
If the document has not been modified since its load the date/time of last modification (as reported by QFileInfo) will be returned.
QDocumentLine QDocument::line | ( | int | line | ) | const |
line | Text line to acces |
Referenced by QLineMarksInfoCenter::addLineMark(), addMatch(), QNFADefinition::blockFlags(), QNFADefinition::collapse(), cursor(), cursorForDocumentPosition(), QNFADefinition::expand(), lineAt(), lineRect(), QFoldPanel::mousePressEvent(), QDocumentInsertCommand::QDocumentInsertCommand(), QLineMarksInfoCenter::removeLineMark(), text(), QEditor::text(), QLineMarksInfoCenter::toggleLineMark(), QNFADefinition::tokenize(), QNFADefinition::unindent(), and QDocumentCommand::updateTarget().
QDocumentLine QDocument::line | ( | QDocumentConstIterator | iterator | ) | const |
References iterator().
QDocumentLine QDocument::lineAt | ( | const QPoint & | p | ) | const |
References line(), and lineNumber().
Referenced by QEditor::lineAtPosition().
int QDocument::lineCount | ( | ) | const |
The number of visual lines may differ from that of text lines as soon as line wrapping and/or folding are enabled.
Referenced by QGotoLinePanel::editorChange(), print(), setText(), and stopChunkLoading().
QDocument::LineEnding QDocument::lineEnding | ( | ) | const |
The line ending policy determines how line endings are used when saving the document (which includes fetching the document's text()).
It can either be conservative (auto detect upon loading and do not modify when saving later on) or enforce a particular line ending (either local line ending or a specific value).
Referenced by setText(), and stopChunkLoading().
int QDocument::lineNumber | ( | int | ypos, |
int * | wrap = 0 |
||
) | const |
ypos | Y document coordinate of the target |
wrap | if not null, will be set to the wrap offset (position of the visual line among the sublines of the wrapped text line). |
Referenced by cursorForDocumentPosition(), and lineAt().
QRect QDocument::lineRect | ( | int | line | ) | const |
line | textual line number |
References line(), width(), and y().
Referenced by QEditor::lineRect(), and QEditor::selectionRect().
QRect QDocument::lineRect | ( | const QDocumentLine & | l | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int QDocument::lines | ( | ) | const |
The number of visual lines may differ from that of text lines as soon as line wrapping and/or folding are enabled.
Referenced by QLineNumberPanel::editorChange(), highlight(), print(), and QDocumentCommand::updateTarget().
int QDocument::maxMarksPerLine | ( | ) | const |
This is meant for the line mark panel to smartly adapt its size.
QDocument::LineEnding QDocument::originalLineEnding | ( | ) | const |
This should only ever take the the Window of Linux value if a document has been loaded. If no content has been loaded it will fall back to Local.
Referenced by QEditor::load(), and setLineEnding().
|
slot |
Print the content of the document.
pr | printer to use |
References draw(), lineCount(), lines(), and width().
Referenced by QEditor::print().
|
slot |
Set the document to clean state.
This method does not go back to clean state but tell the stack that the current state is to be considered as the clean state.
References iterator().
Referenced by QEditor::save().
|
static |
Set the default format scheme.
Referenced by setFormatFactory().
|
static |
Set the default line ending policy.
References setLineEnding().
Referenced by QEditConfig::apply().
void QDocument::setEditCursor | ( | QDocumentCursor * | c | ) |
Set the edit cursor.
|
static |
Set the font of ALL documents.
Referenced by QEditConfig::apply(), QEditConfig::loadKeys(), QDocument(), and QEditor::zoom().
|
static |
void QDocument::setLastModified | ( | const QDateTime & | d | ) |
set the date/time of the last modification of the document
You should not need to use that EVER. It is only provided for use in QEditor (and possibly in some panels).
Referenced by QEditor::load().
|
static |
Set the default tab stop common to all documents.
Referenced by QEditConfig::apply().
|
slot |
Set a new width constraint.
width | maximum width to allow |
Passing a value inferior (or equal) to zero clear the width constraint, if any.
References width().
Referenced by QEditor::setDefaultFlags(), QEditor::setFlag(), and QEditor::setPanelMargins().
|
static |
Referenced by QEditConfig::cancel().
void QDocument::startChunkLoading | ( | ) |
Start a chunk loading.
It is possible to load document contents in one piece or by chunks. To achieve the later you have to proceed as follows :
Referenced by QEditor::load().
void QDocument::stopChunkLoading | ( | ) |
Stop chunk loading.
References lineCount(), lineEnding(), and setLineEnding().
Referenced by QEditor::load().
|
static |
Referenced by QEditConfig::cancel(), QEditor::indentSelection(), and QEditor::insertText().
QString QDocument::text | ( | int | mode | ) | const |
mode | extra processing to perform on text |
References line().
Referenced by QEditor::save(), text(), and QEditor::text().
QString QDocument::text | ( | bool | removeTrailing = false , |
bool | preserveIndent = true |
||
) | const |
removeTrailing | whether to remove trailing whitespaces |
preserveIndent | whether to keep trailing whitespaces when they are indent |
References text().
int QDocument::textLineNumber | ( | int | visualLineNumber | ) | const |
Convert a visual line number int a text (logical) line number.
References visualLineNumber().
Referenced by visualLineNumber().
int QDocument::visualLineCount | ( | ) | const |
int QDocument::visualLineNumber | ( | int | textLineNumber | ) | const |
Convert a text (logical) line number int a visual line number.
References textLineNumber().
Referenced by textLineNumber().
int QDocument::visualLines | ( | ) | const |
int QDocument::width | ( | ) | const |
The width of the document is that of longest text line.
Referenced by lineRect(), QEditor::load(), print(), QEditor::setText(), and setWidthConstraint().
int QDocument::widthConstraint | ( | ) | const |
Setting a width constraint on a document achieves line wrapping.
Referenced by QDocumentLineHandle::updateWrap().
int QDocument::y | ( | int | ln | ) | const |
ln | textual line number |
Referenced by QEditor::ensureVisible(), lineRect(), QEditor::selectionRect(), and y().
int QDocument::y | ( | const QDocumentLine & | l | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
l | line object |
References QDocumentLine::lineNumber(), and y().