KDE 4.9 PyKDE API Reference

- KDE's Python API

# MovingCursor Class Reference

`from PyKDE4.ktexteditor import *`

Namespace: KTextEditor

## Detailed Description

Abstract class:
  This class can be used as a base class for new classes, but can not be instantiated directly.

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, MovingCursor%s may not be copied, as they need to maintain a connection to the associated Document.

Create a new MovingCursor like this:

     // Retrieve the MovingInterface
     KTextEditor.MovingInterface* moving =
         qobject_cast<KTextEditor.MovingInterface*>( yourDocument );

     if ( moving ) {
         KTextEditor.MovingCursor* cursor = moving->newMovingCursor();
     }

When finished with a MovingCursor, simply delete it. If the document the cursor belong to is deleted, it will get deleted automatically.

\sa Cursor, Range, MovingRange and MovingInterface.

Author:
  Christoph Cullmann <cullmann@kde.org>

Since:
  4.5

## Enumerations
InsertBehavior | { StayOnInsert, MoveOnInsert }
WrapBehavior | { Wrap, NoWrap }
## Methods
| __init__ (self)
| __init__ (self, KTextEditor.MovingCursor a0)
bool | atEndOfDocument (self)
bool | atEndOfLine (self)
bool | atStartOfDocument (self)
bool | atStartOfLine (self)
int | column (self)
KTextEditor.Document | document (self)
bool | gotoNextLine (self)
bool | gotoPreviousLine (self)
KTextEditor.MovingCursor.InsertBehavior | insertBehavior (self)
bool | isValid (self)
bool | isValidTextPosition (self)
int | line (self)
bool | move (self, int chars, KTextEditor.MovingCursor.WrapBehavior wrapBehavior=KTextEditor.MovingCursor.Wrap)
KTextEditor.MovingRange | range (self)
| setColumn (self, int column)
| setInsertBehavior (self, KTextEditor.MovingCursor.InsertBehavior insertBehavior)
| setLine (self, int line)
| setPosition (self, KTextEditor.Cursor position)
| setPosition (self, int line, int column)
KTextEditor.Cursor | toCursor (self)

## Method Documentation

__init__ | ( |  | self ) |

no copy constructor, don't allow this to be copied.

__init__ | ( | self, |
|  | KTextEditor.MovingCursor | a0
| ) |  |  |

no copy constructor, don't allow this to be copied.

bool atEndOfDocument | ( |  | self ) |

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.

bool atEndOfLine | ( |  | self ) |

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.

bool atStartOfDocument | ( |  | self ) |

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.

bool atStartOfLine | ( |  | self ) |

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.

int column | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Retrieve the column on which this cursor is situated.

Returns:
  column number, where 0 is the first column.

KTextEditor.Document document | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Gets the document to which this cursor is bound.

Returns:
  a pointer to the document

bool gotoNextLine | ( |  | self ) |

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

bool gotoPreviousLine | ( |  | self ) |

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

KTextEditor.MovingCursor.InsertBehavior insertBehavior | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Get current insert behavior.

Returns:
  current insert behavior

bool isValid | ( |  | self ) |

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

bool isValidTextPosition | ( |  | self ) |

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

int line | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Retrieve the line on which this cursor is situated.

Returns:
  line number, where 0 is the first line.

bool move | ( | self, |
|  | int | chars,
|  | KTextEditor.MovingCursor.WrapBehavior | wrapBehavior=KTextEditor.MovingCursor.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

KTextEditor.MovingRange range | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Get range this cursor belongs to, if any

Returns:
  range this pointer is part of, else 0

setColumn | ( | self, |
|  | int | column
| ) |  |  |

Set the cursor column to column.

Parameters:

  | column | new cursor column

setInsertBehavior | ( | self, |
|  | KTextEditor.MovingCursor.InsertBehavior | insertBehavior
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Set insert behavior.

Parameters:

  | insertBehavior | new insert behavior

setLine | ( | self, |
|  | int | line
| ) |  |  |

Set the cursor line to line.

Parameters:

  | line | new cursor line

setPosition | ( | self, |
|  | KTextEditor.Cursor | position
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Set the cursor position to line and column.

Parameters:

  | line | new cursor line

Parameters:

  | column | new cursor column

setPosition | ( | self, |
|  | int | line,
|  | int | column
| ) |  |  |

Set the cursor position to line and column.

Parameters:

  | line | new cursor line

Parameters:

  | column | new cursor column

KTextEditor.Cursor toCursor | ( |  | self ) |

Convert this clever cursor into a dumb one. Even if this cursor belongs to a range, the created one not.

Returns:
  normal cursor

## Enumeration Documentation

InsertBehavior

Insert behavior of this cursor, should it stay if text is insert at its position or should it move.

Enumerator:

  DoNotExpand = 0 |
  ExpandLeft = 0x1 |
  ExpandRight = 0x2 |

WrapBehavior

Wrap behavior for end of line treatement used in move().

Enumerator:

  Wrap = 0x0 |
  NoWrap = 0x1 |