Public Types | |
| enum | State { None = 0, Hidden = 1, CollapsedBlockStart = 2, CollapsedBlockEnd = 4, LayoutDirty = 16, FormatsApplied = 32 } |
Public Member Functions | |
| Q_DECLARE_FLAGS (States, State) | |
| bool | operator== (const QDocumentLineHandle *h) const |
| bool | operator!= (const QDocumentLineHandle *h) const |
| QString | indentation () const |
| bool | isHidden () const |
| QDocumentLineHandle * | handle () const |
| QDocumentLine (QDocument *doc) | |
| QDocumentLine (const QDocumentLine &line) | |
| QDocumentLine (QDocumentLineHandle *h=0) | |
| bool | isNull () const |
| bool | isValid () const |
| bool | operator== (const QDocumentLine &l) const |
| Comparision operator. | |
| bool | operator!= (const QDocumentLine &l) const |
| Comparision operator. | |
| bool | operator< (const QDocumentLine &l) const |
| Comparision operator. | |
| bool | operator>= (const QDocumentLine &l) const |
| Comparision operator. | |
| bool | operator> (const QDocumentLine &l) const |
| Comparision operator. | |
| bool | operator<= (const QDocumentLine &l) const |
| Comparision operator. | |
| QDocumentLine & | operator++ () |
| Iterate forward over the document. | |
| QDocumentLine & | operator-- () |
| Iterate backward over the document. | |
| void | operator++ (int) |
| Iterate forward over the document. | |
| void | operator-- (int) |
| Iterate backward over the document. | |
| QDocumentLine & | operator= (const QDocumentLine &l) |
| copy operator | |
| int | lineNumber () const |
| int | position () const |
| QString | text () const |
| int | length () const |
| int | lineSpan () const |
| int | firstChar () const |
| Returns the position of the first non-whitespace character. | |
| int | lastChar () const |
| Returns the position of the last non-whitespace character. | |
| int | nextNonSpaceChar (int pos) const |
| int | previousNonSpaceChar (int pos) const |
| Find the position of the previous char that is not a space. | |
| bool | hasFlag (State s) const |
| Check whether a given flag is set to the line. | |
| void | setFlag (State s, bool y=true) |
| Set a flag of the line. | |
| QDocumentLine | next () const |
| QDocumentLine | previous () const |
| QDocument * | document () const |
| int | xToCursor (int x) const |
| Converts a document position (unconstrained viewport) to a cursor position (column). | |
| int | cursorToX (int cpos) const |
| Converts a cursor position (column) to a document position (unconstrained viewport). | |
| int | wrappedLineForCursor (int cpos) const |
| int | documentOffsetToCursor (int x, int y) const |
| Converts a document offset (viewport) to a cursor position (character / text column). | |
| void | cursorToDocumentOffset (int cpos, int &x, int &y) const |
| Converts a cursor position (character / text column) to a document offset (viewport). | |
| QPoint | cursorToDocumentOffset (int cpos) const |
| void | addMark (int id) |
| Toggle a mark on the line. | |
| void | removeMark (int id) |
| Remove a mark from the line. | |
| void | toggleMark (int id) |
| Toggle a mark on the line. | |
| QList< int > | marks () const |
| bool | hasMark (int id) const |
| void | clearOverlays () |
| Clear all overlays applied to the line. | |
| void | addOverlay (const QFormatRange &over) |
| Add an overlay to the line. | |
| void | removeOverlay (const QFormatRange &over) |
| Remove an overlay from the line. | |
| void | setFormats (const QVector< int > &formats) |
| Set the formatting of the line. | |
| const QVector< QParenthesis > & | parentheses () const |
| void | setParentheses (const QVector< QParenthesis > &parentheses) |
| Set the parentheses present on that line. | |
| QNFAMatchContext * | matchContext () |
Friends | |
| class | QDocumentLineHandle |
| class | QDocumentCursorHandle |
In QCodeEdit, documents are stored as a list of lines. A QDocumentLine holds a pointer to the data of one line and gives access to its content.
It is not meant to be used to iterate over the document, though it is possible for conveneience and compatibility reasons. Indeed, QDocumentLine does not now where in the document it is located. It can obtain that information but this is a O(n) operation. Navigation within the document is one of the task devoted to QDocumentCursor which can move around in O(1) (or amortized O(1) in some rare cases).
Lines can be given formatting in various way : "regular" formatting used for highlighting, overlays used mainly to display search matches and similar informations and marks.
| void QDocumentLine::addOverlay | ( | const QFormatRange & | over | ) |
Add an overlay to the line.
Overlays are format range that get applied on top of regular formatting.
They are typically used to display search matches, matching braces, ...
References QDocumentLineHandle::addOverlay().
| QPoint QDocumentLine::cursorToDocumentOffset | ( | int | cpos | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References QDocumentLineHandle::cursorToDocumentOffset().
| void QDocumentLine::cursorToDocumentOffset | ( | int | cpos, | |
| int & | x, | |||
| int & | y | |||
| ) | const |
Converts a cursor position (character / text column) to a document offset (viewport).
The (x, y) coordinates given by this function are relative to the absolute position of the line, which can be obtained from the document.
References QDocumentLineHandle::cursorToDocumentOffset().
| int QDocumentLine::cursorToX | ( | int | cpos | ) | const |
Converts a cursor position (column) to a document position (unconstrained viewport).
References QDocumentLineHandle::cursorToX().
| QDocument * QDocumentLine::document | ( | ) | const |
References QDocumentLineHandle::document().
Referenced by addMark(), marks(), removeMark(), and toggleMark().
| int QDocumentLine::documentOffsetToCursor | ( | int | x, | |
| int | y | |||
| ) | const |
Converts a document offset (viewport) to a cursor position (character / text column).
The (x, y) coordinates given by this function are relative to the absolute position of the line, which can be obtained from the document.
References QDocumentLineHandle::documentOffsetToCursor().
| int QDocumentLine::firstChar | ( | ) | const |
Returns the position of the first non-whitespace character.
References nextNonSpaceChar().
Referenced by QEditor::unindentSelection().
| bool QDocumentLine::hasMark | ( | int | id | ) | const |
| bool QDocumentLine::isNull | ( | ) | const |
| bool QDocumentLine::isValid | ( | ) | const |
References QDocumentLineHandle::document().
Referenced by QLineMarksInfoCenter::addLineMark(), QDocumentCursor::isNull(), QDocumentCursor::isValid(), QLineMarksInfoCenter::removeLineMark(), and QLineMarksInfoCenter::toggleLineMark().
| int QDocumentLine::lastChar | ( | ) | const |
Returns the position of the last non-whitespace character.
References length(), and previousNonSpaceChar().
| int QDocumentLine::length | ( | ) | const |
References QDocumentLineHandle::text().
Referenced by lastChar(), QDocumentInsertCommand::QDocumentInsertCommand(), and QDocumentCommand::updateTarget().
| int QDocumentLine::lineNumber | ( | ) | const |
References QDocumentLineHandle::line().
Referenced by QDocumentCursor::moveTo(), operator<(), operator<=(), operator>(), operator>=(), and QDocument::y().
| int QDocumentLine::lineSpan | ( | ) | const |
References QDocumentLineHandle::document(), and QDocumentLineHandle::m_frontiers.
| QList< int > QDocumentLine::marks | ( | ) | const |
References document(), and QDocument::impl().
Referenced by hasMark().
| QNFAMatchContext * QDocumentLine::matchContext | ( | ) |
Reserved to syntax engines. do not mess with this unless you know what you are doing.
References QDocumentLineHandle::m_context.
| QDocumentLine QDocumentLine::next | ( | ) | const |
References QDocumentLineHandle::next().
Referenced by operator++().
| int QDocumentLine::nextNonSpaceChar | ( | int | pos | ) | const |
Find the position of the next char that is not a space.
| pos | Column of the character which is examined first. |
References QDocumentLineHandle::nextNonSpaceChar().
Referenced by firstChar().
| bool QDocumentLine::operator< | ( | const QDocumentLine & | l | ) | const |
| bool QDocumentLine::operator<= | ( | const QDocumentLine & | l | ) | const |
| QDocumentLine & QDocumentLine::operator= | ( | const QDocumentLine & | l | ) |
copy operator
QDocumentLine objects are just wrappers around the "real" line data. Copies of a QDocumentLine all points to the same underlying data and modifying one affect them all (no implicit sharing).
References QDocumentLineHandle::deref(), m_handle, and QDocumentLineHandle::ref().
Referenced by operator++(), and operator--().
| bool QDocumentLine::operator> | ( | const QDocumentLine & | l | ) | const |
| bool QDocumentLine::operator>= | ( | const QDocumentLine & | l | ) | const |
| const QVector< QParenthesis > & QDocumentLine::parentheses | ( | ) | const |
References QDocumentLineHandle::m_parens.
| int QDocumentLine::position | ( | ) | const |
References QDocumentLineHandle::position().
| QDocumentLine QDocumentLine::previous | ( | ) | const |
References QDocumentLineHandle::previous().
Referenced by operator--().
| int QDocumentLine::previousNonSpaceChar | ( | int | pos | ) | const |
Find the position of the previous char that is not a space.
| pos | Column of the character which is examined first. |
References QDocumentLineHandle::previousNonSpaceChar().
Referenced by lastChar().
| void QDocumentLine::setFlag | ( | State | s, | |
| bool | y = true | |||
| ) |
Set a flag of the line.
References QDocumentLineHandle::setFlag().
| void QDocumentLine::setFormats | ( | const QVector< int > & | formats | ) |
Set the formatting of the line.
References QDocumentLineHandle::setFormats().
| void QDocumentLine::setParentheses | ( | const QVector< QParenthesis > & | parentheses | ) |
Set the parentheses present on that line.
References QDocumentLineHandle::m_parens.
| QString QDocumentLine::text | ( | ) | const |
References QDocumentLineHandle::text().
Referenced by QEditor::insertText(), QDocumentSearch::next(), QDocumentInsertCommand::QDocumentInsertCommand(), and QEditor::text().
| int QDocumentLine::wrappedLineForCursor | ( | int | cpos | ) | const |
| cpos | cursor position, as a text column |
References QDocumentLineHandle::wrappedLineForCursor().
Referenced by QDocumentCursor::anchorWrappedLineOffset(), and QDocumentCursor::wrappedLineOffset().
| int QDocumentLine::xToCursor | ( | int | xpos | ) | const |
Converts a document position (unconstrained viewport) to a cursor position (column).
References QDocumentLineHandle::xToCursor().
1.5.7.1