com.intellij.openapi.editor
Interface CaretModel


public interface CaretModel

Provides services for moving the caret and retrieving information about caret position.

See Also:
Editor.getCaretModel()

Method Summary
 void addCaretListener(CaretListener listener)
          Adds a listener for receiving notifications about caret movement.
 LogicalPosition getLogicalPosition()
          Returns the logical position of the caret.
 int getOffset()
          Returns the offset of the caret in the document.
 VisualPosition getVisualPosition()
          Returns the visual position of the caret.
 void moveCaretRelatively(int columnShift, int lineShift, boolean withSelection, boolean blockSelection, boolean scrollToCaret)
          Moves the caret by the specified number of lines and/or columns.
 void moveToLogicalPosition(LogicalPosition pos)
          Moves the caret to the specified logical position.
 void moveToOffset(int offset)
          Moves the caret to the specified offset in the document.
 void moveToVisualPosition(VisualPosition pos)
          Moves the caret to the specified visual position.
 void removeCaretListener(CaretListener listener)
          Removes a listener for receiving notifications about caret movement.
 

Method Detail

moveCaretRelatively

void moveCaretRelatively(int columnShift,
                         int lineShift,
                         boolean withSelection,
                         boolean blockSelection,
                         boolean scrollToCaret)
Moves the caret by the specified number of lines and/or columns.

Parameters:
columnShift - the number of columns to move the caret by.
lineShift - the number of lines to move the caret by.
withSelection - if true, the caret move should extend the range or block selection in the document.
blockSelection - if true and withSelection is true, the caret move should extend the block selection in the document.
scrollToCaret - if true, the document should be scrolled so that the caret is visible after the move.

moveToLogicalPosition

void moveToLogicalPosition(LogicalPosition pos)
Moves the caret to the specified logical position.

Parameters:
pos - the position to move to.

moveToVisualPosition

void moveToVisualPosition(VisualPosition pos)
Moves the caret to the specified visual position.

Parameters:
pos - the position to move to.

moveToOffset

void moveToOffset(int offset)
Moves the caret to the specified offset in the document.

Parameters:
offset - the offset to move to.

getLogicalPosition

LogicalPosition getLogicalPosition()
Returns the logical position of the caret.

Returns:
the caret position.

getVisualPosition

VisualPosition getVisualPosition()
Returns the visual position of the caret.

Returns:
the caret position.

getOffset

int getOffset()
Returns the offset of the caret in the document.

Returns:
the caret offset.

addCaretListener

void addCaretListener(CaretListener listener)
Adds a listener for receiving notifications about caret movement.

Parameters:
listener - the listener instance.

removeCaretListener

void removeCaretListener(CaretListener listener)
Removes a listener for receiving notifications about caret movement.

Parameters:
listener - the listener instance.