public class TextComponentEditorImpl extends UserDataHolderBase implements TextComponentEditor
EMPTY_ARRAY
Constructor and Description |
---|
TextComponentEditorImpl(Project project,
javax.swing.text.JTextComponent textComponent) |
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.
|
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 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.text.JTextComponent |
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.
|
com.intellij.openapi.editor.textarea.TextComponentSelectionModel |
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.
|
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.
|
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.
|
java.awt.geom.Point2D |
visualPositionToPoint2D(VisualPosition pos)
Same as
Editor.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 {
Editor.xyToVisualPosition(Point) }, but allows to specify target point with higher precision. |
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addEditorMouseListener, addEditorMouseMotionListener, getAscent, offsetToPoint2D, offsetToPoint2D, offsetToXY, offsetToXY, visualLineToY, yToVisualLine
getUserData, putUserData
public TextComponentEditorImpl(Project project, javax.swing.text.JTextComponent textComponent)
public Document getDocument()
Editor
getDocument
in interface Editor
public boolean isViewer()
Editor
public javax.swing.JComponent getComponent()
Editor
getComponent
in interface Editor
public javax.swing.text.JTextComponent getContentComponent()
Editor
DataProvider
.getContentComponent
in interface Editor
public void setBorder(javax.swing.border.Border border)
public com.intellij.openapi.editor.textarea.TextComponentSelectionModel getSelectionModel()
Editor
To query or change selections for specific carets, CaretModel
interface should be used.
getSelectionModel
in interface Editor
Editor.getCaretModel()
public MarkupModel getMarkupModel()
Editor
See also DocumentMarkupModel.forDocument(Document, Project, boolean)
EditorEx.getFilteredDocumentMarkupModel()
.
getMarkupModel
in interface Editor
public FoldingModel getFoldingModel()
Editor
getFoldingModel
in interface Editor
public ScrollingModel getScrollingModel()
Editor
getScrollingModel
in interface Editor
public CaretModel getCaretModel()
Editor
getCaretModel
in interface Editor
public SoftWrapModel getSoftWrapModel()
Editor
getSoftWrapModel
in interface Editor
public InlayModel getInlayModel()
getInlayModel
in interface Editor
public EditorKind getEditorKind()
getEditorKind
in interface Editor
public EditorSettings getSettings()
Editor
getSettings
in interface Editor
public EditorColorsScheme getColorsScheme()
Editor
getColorsScheme
in interface Editor
public int getLineHeight()
Editor
getLineHeight
in interface Editor
public java.awt.Point logicalPositionToXY(LogicalPosition pos)
Editor
logicalPositionToXY
in interface Editor
pos
- the logical position.content component
.public int logicalPositionToOffset(LogicalPosition pos)
Editor
logicalPositionToOffset
in interface Editor
pos
- the logical position.public VisualPosition logicalToVisualPosition(LogicalPosition logicalPos)
Editor
logicalToVisualPosition
in interface Editor
logicalPos
- the logical position.public java.awt.Point visualPositionToXY(VisualPosition visible)
Editor
visualPositionToXY
in interface Editor
visible
- the visual position.content component
.public java.awt.geom.Point2D visualPositionToPoint2D(VisualPosition pos)
Editor
Editor.visualPositionToXY(VisualPosition)
, but returns potentially more precise result.visualPositionToPoint2D
in interface Editor
public LogicalPosition visualToLogicalPosition(VisualPosition visiblePos)
Editor
visualToLogicalPosition
in interface Editor
visiblePos
- the visual position.public LogicalPosition offsetToLogicalPosition(int offset)
Editor
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
.
offsetToLogicalPosition
in interface Editor
offset
- the offset in the document.public VisualPosition offsetToVisualPosition(int offset)
Editor
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.
offsetToVisualPosition
in interface Editor
offset
- the offset in the document.public VisualPosition offsetToVisualPosition(int offset, boolean leanForward, boolean beforeSoftWrap)
Editor
offsetToVisualPosition
in interface Editor
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.public LogicalPosition xyToLogicalPosition(java.awt.Point p)
Editor
xyToLogicalPosition
in interface Editor
p
- the coordinates relative to the top left corner of the content component
.public VisualPosition xyToVisualPosition(java.awt.Point p)
Editor
xyToVisualPosition
in interface Editor
p
- the coordinates relative to the top left corner of the content component
.public VisualPosition xyToVisualPosition(java.awt.geom.Point2D p)
Editor
Editor.xyToVisualPosition(Point)
}, but allows to specify target point with higher precision.xyToVisualPosition
in interface Editor
public void addEditorMouseListener(EditorMouseListener listener)
Editor
addEditorMouseListener
in interface Editor
listener
- the listener instance.public void removeEditorMouseListener(EditorMouseListener listener)
Editor
removeEditorMouseListener
in interface Editor
listener
- the listener instance.public void addEditorMouseMotionListener(EditorMouseMotionListener listener)
Editor
addEditorMouseMotionListener
in interface Editor
listener
- the listener instance.public void removeEditorMouseMotionListener(EditorMouseMotionListener listener)
Editor
removeEditorMouseMotionListener
in interface Editor
listener
- the listener instance.public boolean isDisposed()
Editor
isDisposed
in interface Editor
true
if the editor has been disposed, false
otherwise.public Project getProject()
Editor
getProject
in interface Editor
null
if the editor is not related to any project.public boolean isInsertMode()
Editor
isInsertMode
in interface Editor
true
if the editor is in insert mode, false
otherwise.public boolean isColumnMode()
Editor
isColumnMode
in interface Editor
true
if the editor uses column selection, false
if it uses regular selection.public boolean isOneLineMode()
Editor
isOneLineMode
in interface Editor
true
if the editor is one-line, false
otherwise.public EditorGutter getGutter()
Editor
public EditorMouseEventArea getMouseEventArea(java.awt.event.MouseEvent e)
Editor
getMouseEventArea
in interface Editor
e
- the mouse event for which the area is requested.null
if the event occurred over an unknown area.public void setHeaderComponent(javax.swing.JComponent header)
Editor
setHeaderComponent
in interface Editor
header
- a component to setup as header for this text editor or null
to remove existing one.public boolean hasHeaderComponent()
hasHeaderComponent
in interface Editor
true
if this editor has active header component set up by Editor.setHeaderComponent(JComponent)
public javax.swing.JComponent getHeaderComponent()
getHeaderComponent
in interface Editor
Editor.setHeaderComponent(JComponent)
or null
if no header currently installed.public IndentsModel getIndentsModel()
getIndentsModel
in interface Editor