QCodeEdit
2.2
|
A cursor to navigate within documents and edit them. More...
Public Member Functions | |
Q_DECLARE_FLAGS (MoveMode, MoveFlag) | |
QDocumentCursorHandle * | handle () const |
QDocumentCursor (QDocument *doc) | |
QDocumentCursor (const QDocumentCursor &cursor) | |
QDocumentCursor (QDocument *doc, int line, int column=0) | |
QDocumentCursor (QDocumentCursorHandle *handle=0) | |
QDocumentCursor | clone () const |
QDocumentCursor & | operator= (const QDocumentCursor &c) |
bool | operator== (const QDocumentCursor &c) const |
comparision operator | |
bool | operator!= (const QDocumentCursor &c) const |
comparision operator | |
bool | operator< (const QDocumentCursor &c) const |
comparision operator | |
bool | operator> (const QDocumentCursor &c) const |
comparision operator | |
bool | operator<= (const QDocumentCursor &c) const |
comparision operator | |
bool | operator>= (const QDocumentCursor &c) const |
comparision operator | |
bool | isNull () const |
comparision operator | |
bool | isValid () const |
comparision operator | |
bool | atEnd () const |
bool | atStart () const |
bool | atBlockEnd () const |
bool | atBlockStart () const |
bool | atLineEnd () const |
bool | atLineStart () const |
bool | hasSelection () const |
bool | isSilent () const |
void | setSilent (bool y) |
Set whether the cursor is silent. | |
bool | isAutoUpdated () const |
void | setAutoUpdated (bool y) |
Set whether the cursor is aut updated. | |
int | position () const |
int | lineNumber () const |
int | columnNumber () const |
int | anchorLineNumber () const |
int | anchorColumnNumber () const |
int | visualColumnNumber () const |
void | setColumnNumber (int c, MoveMode m=MoveAnchor) |
Set the text column of the cursor. | |
int | wrappedLineOffset () const |
int | anchorWrappedLineOffset () const |
QPoint | documentPosition () const |
QPoint | anchorDocumentPosition () const |
QPolygon | documentRegion () const |
QDocumentLine | line () const |
QDocumentLine | anchorLine () const |
void | shift (int offset) |
Shift cursor position (text column) by a number of columns (characters) | |
void | setPosition (int pos, MoveMode m=MoveAnchor) |
Set the text position of the cursor (within the whole document) | |
bool | movePosition (int offset, MoveOperation op=NextCharacter, MoveMode m=MoveAnchor) |
Moves the cursor position. | |
void | moveTo (int line, int column) |
Jump to another cursor position. | |
void | moveTo (const QDocumentCursor &c) |
Jump to the position of another cursor. | |
void | moveTo (const QDocumentLine &l, int column) |
Jump to another cursor position. | |
void | eraseLine () |
erase the whole line the cursor is on, newline included | |
void | insertLine (bool keepAnchor=false) |
insert a new line at the cursor position | |
void | insertText (const QString &s, bool keepAnchor=false) |
insert some text at the cursor position | |
QDocumentCursor | selectionStart () const |
QDocumentCursor | selectionEnd () const |
QString | selectedText () const |
void | clearSelection () |
clear the selection | |
void | removeSelectedText () |
Remove the selected text. | |
void | replaceSelectedText (const QString &text) |
Replace the selected text. | |
void | select (SelectionType t) |
Select something. | |
void | setSelectionBoundary (const QDocumentCursor &c) |
Set the selection boundary. | |
bool | isWithinSelection (const QDocumentCursor &c) const |
QChar | nextChar () const |
QChar | previousChar () const |
void | deleteChar () |
Delete the character at the position immediately after the cursor. | |
void | deletePreviousChar () |
Delete the character at the position immediately before the cursor. | |
void | beginEditBlock () |
Begin an edit block. | |
void | endEditBlock () |
End an edit block. | |
void | refreshColumnMemory () |
Refresh the column memory of the cursor. | |
bool | hasColumnMemory () const |
void | setColumnMemory (bool y) |
Set whether the cursor use column memory. | |
QDocumentSelection | selection () const |
QDocument * | document () const |
A cursor to navigate within documents and edit them.
QDocumentCursor is a central class of the public API.
It is the best (as in fastest and easiest) way to iterate over the content of a document.
It is also the only class that allows to perform editing operations.
A cursor position is defined by a line number and a text position within the line.
Every cursor can have one or two cursor positions. In the later case, they delimit a selection. The first position set (before selecting) is referred to as the "anchor" and the other (if it is different from the anchor) is the actual cursor position.
When the cursor does not have a selection, querying informations about the anchor has the same result as querying informations about the cursor position.
Informations you can get about both the anchor and the posiotion :
The visual line to which a given cursor resides can be obtained as follows :
int QDocumentCursor::anchorColumnNumber | ( | ) | const |
Referenced by anchorWrappedLineOffset(), QDocumentSearch::next(), and QDocumentSearch::setOption().
QPoint QDocumentCursor::anchorDocumentPosition | ( | ) | const |
QDocumentLine QDocumentCursor::anchorLine | ( | ) | const |
Referenced by anchorWrappedLineOffset().
int QDocumentCursor::anchorLineNumber | ( | ) | const |
int QDocumentCursor::anchorWrappedLineOffset | ( | ) | const |
References anchorColumnNumber(), anchorLine(), and QDocumentLine::wrappedLineForCursor().
bool QDocumentCursor::atBlockEnd | ( | ) | const |
bool QDocumentCursor::atBlockStart | ( | ) | const |
bool QDocumentCursor::atEnd | ( | ) | const |
Referenced by QEditor::commentSelection(), QEditor::indentSelection(), and QEditor::pageDown().
bool QDocumentCursor::atLineEnd | ( | ) | const |
bool QDocumentCursor::atLineStart | ( | ) | const |
bool QDocumentCursor::atStart | ( | ) | const |
Referenced by QEditor::pageUp().
void QDocumentCursor::beginEditBlock | ( | ) |
Begin an edit block.
Edit blocks are command groups. All the commands in an edit block are executed in a row when the edit block is ended with endEditBlock().
Edit blocks are considered as a single command as far as the undo/redo stack is concerned.
Edit blocks can be nested but that isn't of much use
Referenced by QEditor::commentSelection(), QEditor::indentSelection(), and QDocumentSearch::next().
int QDocumentCursor::columnNumber | ( | ) | const |
Referenced by QEditor::getCursorPosition(), QNFADefinition::indent(), QEditor::insertFromMimeData(), QEditor::insertText(), QNFADefinition::match(), QDocumentSearch::next(), QDocumentSearch::setOption(), QNFADefinition::unindent(), and wrappedLineOffset().
QDocument * QDocumentCursor::document | ( | ) | const |
Referenced by QNFADefinition::match(), QDocumentSearch::next(), and QNFADefinition::unindent().
QPoint QDocumentCursor::documentPosition | ( | ) | const |
Document position and viewport position are two terms used interchangeably. The only difference is the former refers to model perception (QDocument) whereas the later refers to view perception (QEditor)
Referenced by QEditor::ensureCursorVisible(), and QEditor::isCursorVisible().
bool QDocumentCursor::hasColumnMemory | ( | ) | const |
The column memory is a feature that allow a cursor to remember its biggest column number so that moving back and forth (with movePosition()) on lines of different width does not result in the column to change.
bool QDocumentCursor::hasSelection | ( | ) | const |
Referenced by QEditor::commentSelection(), QEditor::copy(), QEditor::createMimeDataFromSelection(), QEditor::cursorRect(), QEditor::emitCursorPositionChanged(), QEditor::indentSelection(), QEditor::insertFromMimeData(), QEditor::insertText(), QDocumentSearch::next(), selection(), QEditor::selectionRect(), QDocumentSearch::setScope(), QEditor::uncommentSelection(), and QEditor::unindentSelection().
void QDocumentCursor::insertText | ( | const QString & | s, |
bool | keepAnchor = false |
||
) |
insert some text at the cursor position
Selected text will be removed before insertion happens.
Referenced by QEditor::commentSelection(), QEditor::indentSelection(), QEditor::insertText(), and QDocumentSearch::next().
bool QDocumentCursor::isAutoUpdated | ( | ) | const |
An auto updated cursor will remain on the actual line it points to when the document is modified.
bool QDocumentCursor::isSilent | ( | ) | const |
bool QDocumentCursor::isWithinSelection | ( | const QDocumentCursor & | c | ) | const |
Referenced by QEditor::moveKeyEvent(), and QEditor::setCursor().
QDocumentLine QDocumentCursor::line | ( | ) | const |
Referenced by QNFADefinition::indent(), QEditor::insertText(), isNull(), isValid(), QNFADefinition::match(), QDocumentSearch::next(), QNFADefinition::unindent(), QEditor::unindentSelection(), and wrappedLineOffset().
int QDocumentCursor::lineNumber | ( | ) | const |
Referenced by QEditor::commentSelection(), QEditor::cursorRect(), QGotoLinePanel::editorChange(), QEditor::getCursorPosition(), QEditor::indentSelection(), QNFADefinition::match(), QEditor::moveKeyEvent(), QDocumentSearch::next(), QDocumentSearch::setOption(), and QNFADefinition::unindent().
bool QDocumentCursor::movePosition | ( | int | offset, |
MoveOperation | op = NextCharacter , |
||
MoveMode | m = MoveAnchor |
||
) |
Moves the cursor position.
offset | number of times the selected move will be done |
op | movement type |
m | movement mode (whether to select) |
Referenced by QEditor::addPlaceHolder(), QEditor::commentSelection(), QCodeCompletionEngine::complete(), QEditor::indentSelection(), QEditor::moveKeyEvent(), QDocumentSearch::next(), QEditor::pageDown(), QEditor::pageUp(), QEditor::selectAll(), and QCodeCompletionEngine::textEdited().
void QDocumentCursor::moveTo | ( | int | line, |
int | column | ||
) |
Jump to another cursor position.
line | target line number |
colum | target text column |
void QDocumentCursor::moveTo | ( | const QDocumentCursor & | c | ) |
Jump to the position of another cursor.
c | target cursor |
void QDocumentCursor::moveTo | ( | const QDocumentLine & | l, |
int | column | ||
) |
Jump to another cursor position.
l | target line |
column | target text column |
References QDocumentLine::lineNumber().
QChar QDocumentCursor::nextChar | ( | ) | const |
bool QDocumentCursor::operator!= | ( | const QDocumentCursor & | c | ) | const |
comparision operator
bool QDocumentCursor::operator< | ( | const QDocumentCursor & | c | ) | const |
comparision operator
bool QDocumentCursor::operator<= | ( | const QDocumentCursor & | c | ) | const |
comparision operator
bool QDocumentCursor::operator== | ( | const QDocumentCursor & | c | ) | const |
comparision operator
bool QDocumentCursor::operator> | ( | const QDocumentCursor & | c | ) | const |
comparision operator
bool QDocumentCursor::operator>= | ( | const QDocumentCursor & | c | ) | const |
comparision operator
int QDocumentCursor::position | ( | ) | const |
QChar QDocumentCursor::previousChar | ( | ) | const |
void QDocumentCursor::refreshColumnMemory | ( | ) |
Refresh the column memory of the cursor.
This set the current column memory to the current column position.
Referenced by QEditor::setFlag().
void QDocumentCursor::replaceSelectedText | ( | const QString & | text | ) |
Replace the selected text.
This method differs from insertText() in two ways :
QString QDocumentCursor::selectedText | ( | ) | const |
Referenced by QCodeCompletionEngine::complete(), QEditor::createMimeDataFromSelection(), and QCodeCompletionEngine::textEdited().
QDocumentSelection QDocumentCursor::selection | ( | ) | const |
References hasSelection(), and isNull().
Referenced by QEditor::commentSelection(), QEditor::indentSelection(), QDocumentSearch::next(), QEditor::selectionRect(), QEditor::uncommentSelection(), and QEditor::unindentSelection().
QDocumentCursor QDocumentCursor::selectionEnd | ( | ) | const |
Selection end is the position of the selection that is nearest to document end.
Referenced by QDocumentSearch::next().
QDocumentCursor QDocumentCursor::selectionStart | ( | ) | const |
Selection start is the position of the selection that is nearest to document start.
Referenced by QDocumentSearch::next().
void QDocumentCursor::setColumnNumber | ( | int | c, |
MoveMode | m = MoveAnchor |
||
) |
Set the text column of the cursor.
c | text column to set |
m | move mode (determines whether text will be selected) |
Referenced by QEditor::insertFromMimeData(), and QDocumentSearch::next().
void QDocumentCursor::setPosition | ( | int | pos, |
MoveMode | m = MoveAnchor |
||
) |
Set the text position of the cursor (within the whole document)
Remark made about position() applies.
void QDocumentCursor::setSelectionBoundary | ( | const QDocumentCursor & | c | ) |
Set the selection boundary.
Select text between the current cursor anchor and the one of c.
int QDocumentCursor::visualColumnNumber | ( | ) | const |
int QDocumentCursor::wrappedLineOffset | ( | ) | const |
Wrapped line are "sublines" of logical lines.
References columnNumber(), line(), and QDocumentLine::wrappedLineForCursor().