KTextEditor
#include <movingcursor.h>
Public Types | |
enum | InsertBehavior { StayOnInsert = 0x0, MoveOnInsert = 0x1 } |
enum | WrapBehavior { Wrap = 0x0, NoWrap = 0x1 } |
Public Member Functions | |
virtual | ~MovingCursor () |
bool | atEndOfDocument () const |
bool | atEndOfLine () const |
bool | atStartOfDocument () const |
bool | atStartOfLine () const |
virtual int | column () const =0 |
virtual Document * | document () const =0 |
bool | gotoNextLine () |
bool | gotoPreviousLine () |
virtual InsertBehavior | insertBehavior () const =0 |
bool | isValid () const |
bool | isValidTextPosition () const |
virtual int | line () const =0 |
bool | move (int chars, WrapBehavior wrapBehavior=Wrap) |
operator const Cursor () const | |
virtual MovingRange * | range () const =0 |
void | setColumn (int column) |
virtual void | setInsertBehavior (InsertBehavior insertBehavior)=0 |
void | setLine (int line) |
virtual void | setPosition (const KTextEditor::Cursor &position)=0 |
void | setPosition (int line, int column) |
const Cursor | toCursor () const |
Protected Member Functions | |
MovingCursor () | |
Friends | |
bool | operator!= (const MovingCursor &c1, const MovingCursor &c2) |
bool | operator< (const MovingCursor &c1, const MovingCursor &c2) |
QDebug | operator<< (QDebug s, const MovingCursor *cursor) |
QDebug | operator<< (QDebug s, const MovingCursor &cursor) |
bool | operator<= (const MovingCursor &c1, const MovingCursor &c2) |
bool | operator== (const MovingCursor &c1, const MovingCursor &c2) |
bool | operator> (const MovingCursor &c1, const MovingCursor &c2) |
bool | operator>= (const MovingCursor &c1, const MovingCursor &c2) |
Detailed Description
A Cursor which is bound to a specific Document, and maintains its position.
A MovingCursor is an extension of the basic Cursor class. It maintains its position in the document. As a result of this, MovingCursors may not be copied, as they need to maintain a connection to the associated Document.
Create a new MovingCursor like this:
When finished with a MovingCursor, simply delete it. If the document the cursor belong to is deleted, it will get deleted automatically.
- See also
- Cursor, Range, MovingRange and MovingInterface.
- Since
- 4.5
Definition at line 66 of file movingcursor.h.
Member Enumeration Documentation
Insert behavior of this cursor, should it stay if text is insert at its position or should it move.
Enumerator | |
---|---|
StayOnInsert |
stay on insert |
MoveOnInsert |
move on insert |
Definition at line 76 of file movingcursor.h.
Wrap behavior for end of line treatement used in move().
Enumerator | |
---|---|
Wrap |
wrap at end of line |
NoWrap |
do not wrap at end of line |
Definition at line 84 of file movingcursor.h.
Constructor & Destructor Documentation
|
virtual |
Destruct the moving cursor.
Definition at line 34 of file movingcursor.cpp.
|
protected |
For inherited class only.
Definition at line 30 of file movingcursor.cpp.
Member Function Documentation
bool MovingCursor::atEndOfDocument | ( | ) | const |
Determine if this cursor is located at the end of the last line in the document.
- Returns
- true if the cursor is at the end of the document, otherwise false.
Definition at line 64 of file movingcursor.cpp.
bool MovingCursor::atEndOfLine | ( | ) | const |
Determine if this cursor is located at the end of the current line.
- Returns
- true if the cursor is situated at the end of the line, otherwise false.
Definition at line 60 of file movingcursor.cpp.
bool MovingCursor::atStartOfDocument | ( | ) | const |
Determine if this cursor is located at line 0 and column 0.
- Returns
- true if the cursor is at start of the document, otherwise false.
Definition at line 68 of file movingcursor.cpp.
bool MovingCursor::atStartOfLine | ( | ) | const |
Determine if this cursor is located at column 0 of a valid text line.
- Returns
- true if cursor is a valid text position and column()=0, otherwise false.
Definition at line 56 of file movingcursor.cpp.
|
pure virtual |
Retrieve the column on which this cursor is situated.
- Returns
- column number, where 0 is the first column.
|
pure virtual |
Gets the document to which this cursor is bound.
- Returns
- a pointer to the document
bool MovingCursor::gotoNextLine | ( | ) |
Moves the cursor to the next line and sets the column to 0.
If the cursor position is already in the last line of the document, the cursor position remains unchanged and the return value is false.
- Returns
- true on success, otherwise false
Definition at line 72 of file movingcursor.cpp.
bool MovingCursor::gotoPreviousLine | ( | ) |
Moves the cursor to the previous line and sets the column to 0.
If the cursor position is already in line 0, the cursor position remains unchanged and the return value is false.
- Returns
- true on success, otherwise false
Definition at line 84 of file movingcursor.cpp.
|
pure virtual |
Get current insert behavior.
- Returns
- current insert behavior
|
inline |
Returns whether the current position of this cursor is a valid position, i.e.
whether line() >= 0 and column() >= 0.
- Returns
- true , if the cursor position is valid, otherwise false
Definition at line 171 of file movingcursor.h.
|
inline |
Check whether the current position of this cursor is a valid text position.
- Returns
- true , if the cursor is a valid text position , otherwise false
Definition at line 180 of file movingcursor.h.
|
pure virtual |
Retrieve the line on which this cursor is situated.
- Returns
- line number, where 0 is the first line.
bool MovingCursor::move | ( | int | chars, |
WrapBehavior | wrapBehavior = Wrap |
||
) |
Moves the cursor chars
character forward or backwards.
If wrapBehavior equals WrapBehavior::Wrap, the cursor is automatically wrapped to the next line at the end of a line.
When moving backwards, the WrapBehavior does not have any effect.
- Note
- If the cursor could not be moved the amount of chars requested, the cursor is not moved at all!
- Returns
- true on success, otherwise false
Definition at line 96 of file movingcursor.cpp.
|
inline |
Convert this clever cursor into a dumb one.
Equal to toCursor, allowing to use implicit conversion. Even if this cursor belongs to a range, the created one not.
- Returns
- normal cursor
Definition at line 278 of file movingcursor.h.
|
pure virtual |
Get range this cursor belongs to, if any.
- Returns
- range this pointer is part of, else 0
void MovingCursor::setColumn | ( | int | column | ) |
Set the cursor column to column.
- Parameters
-
column new cursor column
Definition at line 50 of file movingcursor.cpp.
|
pure virtual |
Set insert behavior.
- Parameters
-
insertBehavior new insert behavior
void MovingCursor::setLine | ( | int | line | ) |
Set the cursor line to line.
- Parameters
-
line new cursor line
Definition at line 44 of file movingcursor.cpp.
|
pure virtual |
Set the current cursor position to position.
- Parameters
-
position new cursor position
void MovingCursor::setPosition | ( | int | line, |
int | column | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Set the cursor position to line and column.
- Parameters
-
line new cursor line column new cursor column
Definition at line 38 of file movingcursor.cpp.
|
inline |
Convert this clever cursor into a dumb one.
Even if this cursor belongs to a range, the created one not.
- Returns
- normal cursor
Definition at line 271 of file movingcursor.h.
Friends And Related Function Documentation
|
friend |
Inequality operator.
- Parameters
-
c1 first cursor to compare c2 second cursor to compare
- Returns
- true, if c1's and c2's line and column are not equal.
Definition at line 302 of file movingcursor.h.
|
friend |
Less than operator.
- Parameters
-
c1 first cursor to compare c2 second cursor to compare
- Returns
- true, if c1's position is greater than or equal to c2's position, otherwise false.
Definition at line 332 of file movingcursor.h.
|
friend |
kDebug() stream operator.
Writes this cursor to the debug output in a nicely formatted way.
- Parameters
-
s debug stream cursor cursor to print
- Returns
- debug stream
Definition at line 351 of file movingcursor.h.
|
friend |
kDebug() stream operator.
Writes this cursor to the debug output in a nicely formatted way.
- Parameters
-
s debug stream cursor cursor to print
- Returns
- debug stream
Definition at line 365 of file movingcursor.h.
|
friend |
Less than or equal to operator.
- Parameters
-
c1 first cursor to compare c2 second cursor to compare
- Returns
- true, if c1's position is lesser than or equal to c2's position, otherwise false.
Definition at line 342 of file movingcursor.h.
|
friend |
Equality operator.
- Note
- comparison between two invalid cursors is undefined. comparison between an invalid and a valid cursor will always be false.
- Parameters
-
c1 first cursor to compare c2 second cursor to compare
- Returns
- true, if c1's and c2's line and column are equal.
Definition at line 293 of file movingcursor.h.
|
friend |
Greater than operator.
- Parameters
-
c1 first cursor to compare c2 second cursor to compare
- Returns
- true, if c1's position is greater than c2's position, otherwise false.
Definition at line 312 of file movingcursor.h.
|
friend |
Greater than or equal to operator.
- Parameters
-
c1 first cursor to compare c2 second cursor to compare
- Returns
- true, if c1's position is greater than or equal to c2's position, otherwise false.
Definition at line 322 of file movingcursor.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.