public interface Editor extends UserDataHolder
Modifier and Type | Field and Description |
---|---|
static Editor[] |
EMPTY_ARRAY |
Modifier and Type | Method and Description |
---|---|
void |
addEditorMouseListener(EditorMouseListener listener)
Adds a listener for receiving notifications about mouse clicks in the editor and
the mouse entering/exiting the editor.
|
default void |
addEditorMouseListener(EditorMouseListener listener,
Disposable parentDisposable)
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.
|
default void |
addEditorMouseMotionListener(EditorMouseMotionListener listener,
Disposable parentDisposable)
Adds a listener for receiving notifications about mouse movement in the editor.
|
default int |
getAscent()
Vertical distance, in pixels, between the top of visual line (corresponding coordinate is returned by
visualLineToY(int) ,
visualPositionToXY(VisualPosition) , etc) and baseline of text in that visual line. |
CaretModel |
getCaretModel()
Returns the caret model for the document, which can be used to add and remove carets to the editor, as well as to query and update
carets' and corresponding selections' positions.
|
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.
|
EditorKind |
getEditorKind() |
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.
|
javax.swing.JComponent |
getHeaderComponent() |
IndentsModel |
getIndentsModel() |
InlayModel |
getInlayModel() |
java.awt.Insets |
getInsets() |
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.
|
SoftWrapModel |
getSoftWrapModel()
Returns the soft wrap model for the document, which can be used to get information about soft wraps registered
for the editor document at the moment and provides basic management functions for them.
|
boolean |
hasHeaderComponent() |
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.
|
default java.awt.geom.Point2D |
offsetToPoint2D(int offset) |
default java.awt.geom.Point2D |
offsetToPoint2D(int offset,
boolean leanForward,
boolean beforeSoftWrap) |
VisualPosition |
offsetToVisualPosition(int offset)
Maps an offset in the document to visual position.
|
VisualPosition |
offsetToVisualPosition(int offset,
boolean leanForward,
boolean beforeSoftWrap)
Maps an offset in the document to visual position.
|
default java.awt.Point |
offsetToXY(int offset) |
default java.awt.Point |
offsetToXY(int offset,
boolean leanForward,
boolean beforeSoftWrap) |
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.
|
void |
setBorder(javax.swing.border.Border border) |
void |
setHeaderComponent(javax.swing.JComponent header)
Set up a header component for this text editor.
|
default int |
visualLineToY(int visualLine) |
java.awt.geom.Point2D |
visualPositionToPoint2D(VisualPosition pos)
Same as
visualPositionToXY(VisualPosition) , but returns potentially more precise result. |
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.
|
VisualPosition |
xyToVisualPosition(java.awt.geom.Point2D p)
Same as {
xyToVisualPosition(Point) }, but allows to specify target point with higher precision. |
default int |
yToVisualLine(int y) |
getUserData, putUserData
static final Editor[] EMPTY_ARRAY
Document getDocument()
boolean isViewer()
true
if the editor works as a viewer, false
otherwise.javax.swing.JComponent getComponent()
javax.swing.JComponent getContentComponent()
DataProvider
.void setBorder(javax.swing.border.Border border)
java.awt.Insets getInsets()
SelectionModel getSelectionModel()
To query or change selections for specific carets, CaretModel
interface should be used.
getCaretModel()
MarkupModel getMarkupModel()
See also DocumentMarkupModel.forDocument(Document, Project, boolean)
EditorEx.getFilteredDocumentMarkupModel()
.
FoldingModel getFoldingModel()
ScrollingModel getScrollingModel()
CaretModel getCaretModel()
SoftWrapModel getSoftWrapModel()
EditorSettings getSettings()
EditorColorsScheme getColorsScheme()
int getLineHeight()
java.awt.Point logicalPositionToXY(LogicalPosition pos)
pos
- the logical position.content component
.int logicalPositionToOffset(LogicalPosition pos)
pos
- the logical position.VisualPosition logicalToVisualPosition(LogicalPosition logicalPos)
logicalPos
- the logical position.java.awt.Point visualPositionToXY(VisualPosition visible)
visible
- the visual position.content component
.java.awt.geom.Point2D visualPositionToPoint2D(VisualPosition pos)
visualPositionToXY(VisualPosition)
, but returns potentially more precise result.LogicalPosition visualToLogicalPosition(VisualPosition visiblePos)
visiblePos
- the visual position.LogicalPosition offsetToLogicalPosition(int offset)
It's assumed that original position is associated with character immediately preceding given offset, so target logical position will
have leansForward
value set to false
.
offset
- the offset in the document.VisualPosition offsetToVisualPosition(int offset)
It's assumed that original position is associated with the character immediately preceding given offset,
leansRight
value for visual position will be determined correspondingly.
If there's a soft wrap at the given offset, visual position on a line following the wrap will be returned.
offset
- the offset in the document.VisualPosition offsetToVisualPosition(int offset, boolean leanForward, boolean beforeSoftWrap)
offset
- the offset in the document.leanForward
- if true
, original position is associated with character after given offset, if false
-
with character before given offset. This can make a difference in bidirectional text (see LogicalPosition
,
VisualPosition
)beforeSoftWrap
- if true
, visual position at line preceeding the wrap will be returned, otherwise - visual position
at line following the wrap.LogicalPosition xyToLogicalPosition(java.awt.Point p)
p
- the coordinates relative to the top left corner of the content component
.VisualPosition xyToVisualPosition(java.awt.Point p)
p
- the coordinates relative to the top left corner of the content component
.VisualPosition xyToVisualPosition(java.awt.geom.Point2D p)
xyToVisualPosition(Point)
}, but allows to specify target point with higher precision.default java.awt.Point offsetToXY(int offset)
default java.awt.Point offsetToXY(int offset, boolean leanForward, boolean beforeSoftWrap)
default java.awt.geom.Point2D offsetToPoint2D(int offset)
default java.awt.geom.Point2D offsetToPoint2D(int offset, boolean leanForward, boolean beforeSoftWrap)
default int visualLineToY(int visualLine)
default int yToVisualLine(int y)
void addEditorMouseListener(EditorMouseListener listener)
listener
- the listener instance.default void addEditorMouseListener(EditorMouseListener listener, Disposable parentDisposable)
listener
- the listener instance.parentDisposable
- the parent Disposable instance.void removeEditorMouseListener(EditorMouseListener listener)
listener
- the listener instance.void addEditorMouseMotionListener(EditorMouseMotionListener listener)
listener
- the listener instance.default void addEditorMouseMotionListener(EditorMouseMotionListener listener, Disposable parentDisposable)
listener
- the listener instance.parentDisposable
- the parent Disposable instance.void removeEditorMouseMotionListener(EditorMouseMotionListener listener)
listener
- the listener instance.boolean isDisposed()
true
if the editor has been disposed, false
otherwise.Project getProject()
null
if the editor is not related to any project.boolean isInsertMode()
true
if the editor is in insert mode, false
otherwise.boolean isColumnMode()
true
if the editor uses column selection, false
if it uses regular selection.boolean isOneLineMode()
true
if the editor is one-line, false
otherwise.EditorGutter getGutter()
EditorMouseEventArea getMouseEventArea(java.awt.event.MouseEvent e)
e
- the mouse event for which the area is requested.null
if the event occurred over an unknown area.void setHeaderComponent(javax.swing.JComponent header)
header
- a component to setup as header for this text editor or null
to remove existing one.boolean hasHeaderComponent()
true
if this editor has active header component set up by setHeaderComponent(JComponent)
javax.swing.JComponent getHeaderComponent()
setHeaderComponent(JComponent)
or null
if no header currently installed.IndentsModel getIndentsModel()
InlayModel getInlayModel()
EditorKind getEditorKind()
default int getAscent()
visualLineToY(int)
,
visualPositionToXY(VisualPosition)
, etc) and baseline of text in that visual line.