com.intellij.openapi.editor
Interface Editor

All Superinterfaces:
UserDataHolder

public interface Editor
extends UserDataHolder

Represents an instance of the IDEA text editor.

See Also:
EditorFactory.createEditor(Document), EditorFactory.createViewer(Document)

Method Summary
 void addEditorMouseListener(EditorMouseListener listener)
          Adds a listener for receiving notifications about mouse clicks in the editor and the mouse entering/exiting the editor.
 void addEditorMouseMotionListener(EditorMouseMotionListener listener)
          Adds a listener for receiving notifications about mouse movement in the editor.
 CaretModel getCaretModel()
          Returns the caret model for the document, which can be used to move the caret and retrieve information about the caret position.
 EditorColorsScheme getColorsScheme()
          Returns the editor color scheme for this editor instance.
 javax.swing.JComponent getComponent()
          Returns the component for the entire editor including the scrollbars, error stripe, gutter and other decorations.
 javax.swing.JComponent getContentComponent()
          Returns the component for the content area of the editor (the area displaying the document text).
 Document getDocument()
          Returns the document edited or viewed in the editor.
 FoldingModel getFoldingModel()
          Returns the folding model for the document, which can be used to add, remove, expand or collapse folded regions in the document.
 EditorGutter getGutter()
          Returns the gutter instance for the editor, which can be used to draw custom text annotations in the gutter.
 int getLineHeight()
          Returns the height of a single line of text in the current editor font.
 MarkupModel getMarkupModel()
          Returns the markup model for the editor.
 EditorMouseEventArea getMouseEventArea(java.awt.event.MouseEvent e)
          Returns the editor area (text, gutter, folding outline and so on) in which the specified mouse event occurred.
 Project getProject()
          Returns the project to which the editor is related.
 ScrollingModel getScrollingModel()
          Returns the scrolling model for the document, which can be used to scroll the document and retrieve information about the current position of the scrollbars.
 SelectionModel getSelectionModel()
          Returns the selection model for the editor, which can be used to select ranges of text in the document and retrieve information about the selection.
 EditorSettings getSettings()
          Returns the editor settings for this editor instance.
 boolean isColumnMode()
          Returns the block selection mode for the editor.
 boolean isDisposed()
          Checks if this editor instance has been disposed.
 boolean isInsertMode()
          Returns the insert/overwrite mode for the editor.
 boolean isOneLineMode()
          Checks if the current editor instance is a one-line editor (used in a dialog control, for example).
 boolean isViewer()
          Returns the value indicating whether the editor operates in viewer mode, with all modification actions disabled.
 int logicalPositionToOffset(LogicalPosition pos)
          Maps a logical position in the editor to the offset in the document.
 java.awt.Point logicalPositionToXY(LogicalPosition pos)
          Maps a logical position in the editor to pixel coordinates.
 VisualPosition logicalToVisualPosition(LogicalPosition logicalPos)
          Maps a logical position in the editor (the line and column ignoring folding) to a visual position (with folded lines and columns not included in the line and column count).
 LogicalPosition offsetToLogicalPosition(int offset)
          Maps an offset in the document to a logical position.
 VisualPosition offsetToVisualPosition(int offset)
          Maps an offset in the document to a visual position.
 void removeEditorMouseListener(EditorMouseListener listener)
          Removes a listener for receiving notifications about mouse clicks in the editor and the mouse entering/exiting the editor.
 void removeEditorMouseMotionListener(EditorMouseMotionListener listener)
          Removes a listener for receiving notifications about mouse movement in the editor.
 java.awt.Point visualPositionToXY(VisualPosition visible)
          Maps a visual position in the editor to pixel coordinates.
 LogicalPosition visualToLogicalPosition(VisualPosition visiblePos)
          Maps a visual position in the editor (with folded lines and columns not included in the line and column count) to a logical position (the line and column ignoring folding).
 LogicalPosition xyToLogicalPosition(java.awt.Point p)
          Maps the pixel coordinates in the editor to a logical position.
 VisualPosition xyToVisualPosition(java.awt.Point p)
          Maps the pixel coordinates in the editor to a visual position.
 
Methods inherited from interface com.intellij.openapi.util.UserDataHolder
getUserData, putUserData
 

Method Detail

getDocument

@NotNull
Document getDocument()
Returns the document edited or viewed in the editor.

Returns:
the document instance.

isViewer

boolean isViewer()
Returns the value indicating whether the editor operates in viewer mode, with all modification actions disabled.

Returns:
true if the editor works as a viewer, false otherwise

getComponent

@NotNull
javax.swing.JComponent getComponent()
Returns the component for the entire editor including the scrollbars, error stripe, gutter and other decorations. The component can be used, for example, for converting logical to screen coordinates.

Returns:
the component instance.

getContentComponent

@NotNull
javax.swing.JComponent getContentComponent()
Returns the component for the content area of the editor (the area displaying the document text). The component can be used, for example, for converting logical to screen coordinates.

Returns:
the component instance.

getSelectionModel

@NotNull
SelectionModel getSelectionModel()
Returns the selection model for the editor, which can be used to select ranges of text in the document and retrieve information about the selection.

Returns:
the selection model instance.

getMarkupModel

@NotNull
MarkupModel getMarkupModel()
Returns the markup model for the editor. This model contains editor-specific highlighters (for example, highlighters added by "Highlight usages in file"), which are painted in addition to the highlighters contained in the markup model for the document.

Returns:
the markup model instance.
See Also:
Document.getMarkupModel(com.intellij.openapi.project.Project)

getFoldingModel

@NotNull
FoldingModel getFoldingModel()
Returns the folding model for the document, which can be used to add, remove, expand or collapse folded regions in the document.

Returns:
the folding model instance.

getScrollingModel

@NotNull
ScrollingModel getScrollingModel()
Returns the scrolling model for the document, which can be used to scroll the document and retrieve information about the current position of the scrollbars.

Returns:
the scrolling model instance.

getCaretModel

@NotNull
CaretModel getCaretModel()
Returns the caret model for the document, which can be used to move the caret and retrieve information about the caret position.

Returns:
the caret model instance.

getSettings

@NotNull
EditorSettings getSettings()
Returns the editor settings for this editor instance. Changes to these settings affect only the current editor instance.

Returns:
the settings instance.

getColorsScheme

@NotNull
EditorColorsScheme getColorsScheme()
Returns the editor color scheme for this editor instance. Changes to the scheme affect only the current editor instance.

Returns:
the color scheme instance.

getLineHeight

int getLineHeight()
Returns the height of a single line of text in the current editor font.

Returns:
the line height in pixels.

logicalPositionToXY

@NotNull
java.awt.Point logicalPositionToXY(@NotNull
                                           LogicalPosition pos)
Maps a logical position in the editor to pixel coordinates.

Parameters:
pos - the logical position.
Returns:
the coordinates relative to the top left corner of the content component.

logicalPositionToOffset

int logicalPositionToOffset(@NotNull
                            LogicalPosition pos)
Maps a logical position in the editor to the offset in the document.

Parameters:
pos - the logical position.
Returns:
the corresponding offset in the document.

logicalToVisualPosition

@NotNull
VisualPosition logicalToVisualPosition(@NotNull
                                               LogicalPosition logicalPos)
Maps a logical position in the editor (the line and column ignoring folding) to a visual position (with folded lines and columns not included in the line and column count).

Parameters:
logicalPos - the logical position.
Returns:
the corresponding visual position.

visualPositionToXY

@NotNull
java.awt.Point visualPositionToXY(@NotNull
                                          VisualPosition visible)
Maps a visual position in the editor to pixel coordinates.

Parameters:
visible - the visual position.
Returns:
the coordinates relative to the top left corner of the content component.

visualToLogicalPosition

@NotNull
LogicalPosition visualToLogicalPosition(@NotNull
                                                VisualPosition visiblePos)
Maps a visual position in the editor (with folded lines and columns not included in the line and column count) to a logical position (the line and column ignoring folding).

Parameters:
visiblePos - the visual position.
Returns:
the corresponding logical position.

offsetToLogicalPosition

@NotNull
LogicalPosition offsetToLogicalPosition(int offset)
Maps an offset in the document to a logical position.

Parameters:
offset - the offset in the document.
Returns:
the corresponding logical position.

offsetToVisualPosition

@NotNull
VisualPosition offsetToVisualPosition(int offset)
Maps an offset in the document to a visual position.

Parameters:
offset - the offset in the document.
Returns:
the corresponding visual position.

xyToLogicalPosition

@NotNull
LogicalPosition xyToLogicalPosition(@NotNull
                                            java.awt.Point p)
Maps the pixel coordinates in the editor to a logical position.

Parameters:
p - the coordinates relative to the top left corner of the content component.
Returns:
the corresponding logical position.

xyToVisualPosition

@NotNull
VisualPosition xyToVisualPosition(@NotNull
                                          java.awt.Point p)
Maps the pixel coordinates in the editor to a visual position.

Parameters:
p - the coordinates relative to the top left corner of the content component.
Returns:
the corresponding visual position.

addEditorMouseListener

void addEditorMouseListener(@NotNull
                            EditorMouseListener listener)
Adds a listener for receiving notifications about mouse clicks in the editor and the mouse entering/exiting the editor.

Parameters:
listener - the listener instance.

removeEditorMouseListener

void removeEditorMouseListener(@NotNull
                               EditorMouseListener listener)
Removes a listener for receiving notifications about mouse clicks in the editor and the mouse entering/exiting the editor.

Parameters:
listener - the listener instance.

addEditorMouseMotionListener

void addEditorMouseMotionListener(@NotNull
                                  EditorMouseMotionListener listener)
Adds a listener for receiving notifications about mouse movement in the editor.

Parameters:
listener - the listener instance.

removeEditorMouseMotionListener

void removeEditorMouseMotionListener(@NotNull
                                     EditorMouseMotionListener listener)
Removes a listener for receiving notifications about mouse movement in the editor.

Parameters:
listener - the listener instance.

isDisposed

boolean isDisposed()
Checks if this editor instance has been disposed.

Returns:
true if the editor has been disposed, false otherwise.

getProject

@Nullable
Project getProject()
Returns the project to which the editor is related.

Returns:
the project instance, or null if the editor is not related to any project.

isInsertMode

boolean isInsertMode()
Returns the insert/overwrite mode for the editor.

Returns:
true if the editor is in insert mode, false otherwise.

isColumnMode

boolean isColumnMode()
Returns the block selection mode for the editor.

Returns:
true if the editor uses column selection, false if it uses regular selection.

isOneLineMode

boolean isOneLineMode()
Checks if the current editor instance is a one-line editor (used in a dialog control, for example).

Returns:
true if the editor is one-line, false otherwise.

getGutter

@NotNull
EditorGutter getGutter()
Returns the gutter instance for the editor, which can be used to draw custom text annotations in the gutter.

Returns:
the gutter instance.

getMouseEventArea

@Nullable
EditorMouseEventArea getMouseEventArea(@NotNull
                                                java.awt.event.MouseEvent e)
Returns the editor area (text, gutter, folding outline and so on) in which the specified mouse event occurred.

Parameters:
e - the mouse event for which the area is requested.
Returns:
the editor area, or null if the event occurred over an unknown area.