public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, Queryable, Dumpable, CodeStyleSettingsListener, java.awt.event.FocusListener
Modifier and Type | Class and Description |
---|---|
static class |
EditorImpl.CaretRectangle |
Queryable.Contributor, Queryable.PrintInfo, Queryable.Util
Modifier and Type | Field and Description |
---|---|
static Key<java.lang.Boolean> |
DISABLE_CARET_POSITION_KEEPING |
static Key<java.lang.Boolean> |
FORCED_SOFT_WRAPS |
boolean |
myDisableRtl |
java.lang.Object |
myFractionalMetricsHintValue |
static Key<java.lang.Boolean> |
SOFT_WRAPS_EXIST |
static int |
TEXT_ALIGNMENT_LEFT |
static int |
TEXT_ALIGNMENT_RIGHT |
LAST_PASTED_REGION, PROP_COLUMN_MODE, PROP_FONT_SIZE, PROP_INSERT_MODE, VERTICAL_SCROLLBAR_LEFT, VERTICAL_SCROLLBAR_RIGHT
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.
|
void |
addEditorMouseMotionListener(EditorMouseMotionListener listener)
Adds a listener for receiving notifications about mouse movement in the editor.
|
void |
addFocusListener(FocusChangeListener listener) |
void |
addFocusListener(FocusChangeListener listener,
Disposable parentDisposable) |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener,
Disposable parentDisposable) |
void |
applyFocusMode() |
void |
codeStyleSettingsChanged(CodeStyleSettingsChangeEvent event) |
EditorColorsScheme |
createBoundColorSchemeDelegate(EditorColorsScheme customGlobalScheme)
Creates color scheme delegate which is bound to current editor.
|
java.lang.String |
dumpState() |
int |
findNearestDirectionBoundary(int offset,
boolean lookForward) |
void |
focusGained(java.awt.event.FocusEvent e) |
void |
focusLost(java.awt.event.FocusEvent e) |
int |
getAscent()
Vertical distance, in pixels, between the top of visual line (corresponding coordinate is returned by
Editor.visualLineToY(int) ,
Editor.visualPositionToXY(VisualPosition) , etc) and baseline of text in that visual line. |
java.awt.Color |
getBackgroundColor() |
EditorImpl.CaretRectangle [] |
getCaretLocations(boolean onlyIfShown) |
CaretModelImpl |
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.
|
int |
getCharHeight() |
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.
|
TextRange |
getComposedTextRange() |
EditorComponentImpl |
getContentComponent()
Returns the component for the content area of the editor (the area displaying the document text).
|
java.awt.Dimension |
getContentSize() |
java.lang.String |
getContextMenuGroupId()
Returns id of action group what will be used to construct context menu displayed by default editor popup handler on mouse right
button's click (
null value meaning no context menu). |
CopyProvider |
getCopyProvider() |
CutProvider |
getCutProvider() |
DataContext |
getDataContext() |
DeleteProvider |
getDeleteProvider() |
int |
getDescent() |
Disposable |
getDisposable() |
DocumentEx |
getDocument()
Returns the document edited or viewed in the editor.
|
EditorKind |
getEditorKind() |
int |
getExpectedCaretOffset() |
MarkupModelEx |
getFilteredDocumentMarkupModel()
Returns the markup model for the underlying Document.
|
FocusModeModel |
getFocusModeModel() |
Segment |
getFocusModeRange() |
FoldingModelImpl |
getFoldingModel()
Returns the folding model for the document, which can be used to add, remove, expand
or collapse folded regions in the document.
|
java.awt.FontMetrics |
getFontMetrics(int fontType) |
int |
getFontSize() |
EditorGutter |
getGutter()
Returns the gutter instance for the editor, which can be used to draw custom text annotations
in the gutter.
|
com.intellij.openapi.editor.impl.EditorGutterComponentImpl |
getGutterComponentEx() |
javax.swing.JComponent |
getHeaderComponent() |
EditorHighlighter |
getHighlighter() |
IndentsModel |
getIndentsModel() |
InlayModelImpl |
getInlayModel() |
java.awt.Insets |
getInsets() |
int |
getLineHeight()
Returns the height of a single line of text in the current editor font.
|
MarkupModelEx |
getMarkupModel()
Returns the markup model for the editor.
|
int |
getMaxWidthInRange(int startOffset,
int endOffset) |
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.
|
PasteProvider |
getPasteProvider() |
javax.swing.JComponent |
getPermanentHeaderComponent() |
java.lang.CharSequence |
getPlaceholder() |
TextAttributes |
getPlaceholderAttributes() |
int |
getPreferredHeight() |
java.awt.Dimension |
getPreferredSize() |
int |
getPrefixTextWidthInPixels() |
Project |
getProject()
Returns the project to which the editor is related.
|
float |
getScale()
Returns how much current line height bigger than the normal (16px)
This method is used to scale editors elements such as gutter icons, folding elements, and others
|
ScrollingModelEx |
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.
|
javax.swing.JScrollPane |
getScrollPane() |
SelectionModelImpl |
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 |
getShowPlaceholderWhenFocused() |
SoftWrapModelImpl |
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.
|
TextDrawingCallback |
getTextDrawingCallback() |
int |
getVerticalScrollbarOrientation() |
VirtualFile |
getVirtualFile() |
int |
getVisibleLineCount() |
boolean |
hasHeaderComponent() |
void |
hideCursor() |
void |
installPopupHandler(EditorPopupHandler popupHandler)
Allows to override default editor's context popup logic.
|
boolean |
isColumnMode()
Returns the block selection mode for the editor.
|
boolean |
isDisposed()
Checks if this editor instance has been disposed.
|
boolean |
isDumb() |
boolean |
isEmbeddedIntoDialogWrapper() |
boolean |
isInDistractionFreeMode() |
boolean |
isInFocusMode(FoldRegion region) |
boolean |
isInsertMode()
Returns the insert/overwrite mode for the editor.
|
boolean |
isMirrored() |
boolean |
isOneLineMode()
Checks if the current editor instance is a one-line editor (used in a dialog control, for example).
|
boolean |
isPaintSelection() |
boolean |
isProcessingTypedAction() |
boolean |
isPurePaintingMode() |
boolean |
isRendererMode() |
boolean |
isRightAligned() |
boolean |
isScrollToCaret() |
boolean |
isStickySelection()
Allows to answer if 'sticky selection' is active for the current editor.
|
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.
|
java.awt.geom.Point2D |
offsetToPoint2D(int offset,
boolean leanTowardsLargerOffsets,
boolean beforeSoftWrap) |
int |
offsetToVisualColumnInFoldRegion(FoldRegion region,
int offset,
boolean leanTowardsLargerOffsets) |
int |
offsetToVisualLine(int offset) |
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.
|
java.awt.Point |
offsetToXY(int offset,
boolean leanForward,
boolean beforeSoftWrap) |
boolean |
processKeyTyped(java.awt.event.KeyEvent e) |
boolean |
processLineExtensions(int line,
Processor<? super LineExtensionInfo> processor) |
void |
putInfo(java.util.Map<java.lang.String,java.lang.String> info) |
void |
recordLatencyAwareAction(java.lang.String actionId,
long timestampMs) |
void |
registerLineExtensionPainter(java.util.function.IntFunction<java.util.Collection<LineExtensionInfo>> lineExtensionPainter)
Registers a function which will be applied to a line number to obtain additional text fragments.
|
void |
registerScrollBarRepaintCallback(ButtonlessScrollBarUI.ScrollbarRepaintCallback callback)
Allows to register a callback that will be called one each repaint of the editor vertical scrollbar.
|
void |
reinitSettings() |
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 |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
repaint(int startOffset,
int endOffset) |
void |
resetSizes() |
void |
setBackgroundColor(java.awt.Color color) |
void |
setBorder(javax.swing.border.Border border) |
void |
setCaretActive() |
boolean |
setCaretEnabled(boolean enabled) |
boolean |
setCaretVisible(boolean b) |
void |
setColorsScheme(EditorColorsScheme scheme) |
void |
setColumnMode(boolean mode) |
void |
setContextMenuGroupId(java.lang.String groupId)
Sets id of action group what will be used to construct context menu displayed by default editor popup handler on mouse right button's
click (with
null value disabling context menu). |
void |
setCustomCursor(java.lang.Object requestor,
java.awt.Cursor cursor)
If
cursor parameter value is not null , sets custom cursor to editor's content component ,
otherwise restores default editor cursor management logic (requestor parameter value should be the same in both setting and
restoring requests). |
void |
setDropHandler(EditorDropHandler dropHandler) |
void |
setEmbeddedIntoDialogWrapper(boolean b) |
void |
setFile(VirtualFile vFile) |
void |
setFontSize(int fontSize) |
void |
setHeaderComponent(javax.swing.JComponent header)
Set up a header component for this text editor.
|
void |
setHighlighter(EditorHighlighter highlighter) |
void |
setHighlightingFilter(Condition<RangeHighlighter> filter) |
void |
setHorizontalScrollbarVisible(boolean b) |
void |
setHorizontalTextAlignment(int alignment) |
void |
setInsertMode(boolean mode) |
void |
setOneLineMode(boolean isOneLineMode) |
void |
setPaintSelection(boolean paintSelection) |
void |
setPermanentHeaderComponent(javax.swing.JComponent component) |
void |
setPlaceholder(java.lang.CharSequence text)
Allows to define
'placeholder text' for the current editor, i.e. |
void |
setPlaceholderAttributes(TextAttributes attributes)
Sets text attributes for a placeholder.
|
void |
setPrefixTextAndAttributes(java.lang.String prefixText,
TextAttributes attributes)
Allows to define prefix to be displayed on every editor line and text attributes to use for its coloring.
|
void |
setPurePaintingMode(boolean enabled)
We often re-use the logic encapsulated at the editor.
|
void |
setRendererMode(boolean isRendererMode) |
void |
setScrollToCaret(boolean scrollToCaret) |
void |
setShowPlaceholderWhenFocused(boolean show)
Controls whether
'placeholder text' is visible when editor is focused. |
void |
setStickySelection(boolean enable)
Allows to set current
sticky selection mode. |
void |
setUseEditorAntialiasing(boolean value) |
void |
setVerticalScrollbarOrientation(int type) |
void |
setVerticalScrollbarVisible(boolean b) |
void |
setViewer(boolean isViewer)
shouldn't be called during Document update
|
boolean |
shouldSoftWrapsBeForced() |
void |
startDumb()
stopDumbLater() or stopDumb() must be performed in finally |
void |
stopDumbLater() |
void |
throwDisposalError(java.lang.String msg)
In case of "editor not disposed error" use
throwEditorNotDisposedError(String) |
ActionCallback |
type(java.lang.String text) |
void |
uninstallPopupHandler(EditorPopupHandler popupHandler)
Removes previously installed
EditorPopupHandler . |
int |
visualColumnToOffsetInFoldRegion(FoldRegion region,
int visualColumn,
boolean leansRight) |
int |
visualLineStartOffset(int visualLine) |
int |
visualLineToY(int line) |
java.awt.geom.Point2D |
visualPositionToPoint2D(VisualPosition visible)
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. |
int |
yToVisualLine(int y) |
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, offsetToPoint2D, offsetToXY
getUserData, putUserData
public static final int TEXT_ALIGNMENT_LEFT
public static final int TEXT_ALIGNMENT_RIGHT
public static final Key<java.lang.Boolean> FORCED_SOFT_WRAPS
public static final Key<java.lang.Boolean> SOFT_WRAPS_EXIST
public static final Key<java.lang.Boolean> DISABLE_CARET_POSITION_KEEPING
public final boolean myDisableRtl
public final java.lang.Object myFractionalMetricsHintValue
public void applyFocusMode()
public boolean isInFocusMode(FoldRegion region)
public Segment getFocusModeRange()
public FocusModeModel getFocusModeModel()
public void focusGained(java.awt.event.FocusEvent e)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent e)
focusLost
in interface java.awt.event.FocusListener
public boolean shouldSoftWrapsBeForced()
public EditorColorsScheme createBoundColorSchemeDelegate(EditorColorsScheme customGlobalScheme)
EditorEx
createBoundColorSchemeDelegate
in interface EditorEx
public int getPrefixTextWidthInPixels()
getPrefixTextWidthInPixels
in interface EditorEx
prefix
used with the current editor if any;
zero otherwisepublic void setPrefixTextAndAttributes(java.lang.String prefixText, TextAttributes attributes)
EditorEx
setPrefixTextAndAttributes
in interface EditorEx
prefixText
- target prefix textattributes
- text attributes to use during given prefix paintingpublic boolean isPurePaintingMode()
isPurePaintingMode
in interface EditorEx
EditorEx.setPurePaintingMode(boolean)
public void setPurePaintingMode(boolean enabled)
EditorEx
The thing is that the editor itself may change its state if any postponed operation is triggered by the painting request (e.g. soft wraps recalculation is triggered by the paint request and newly calculated soft wraps cause caret to change its position).
This method allows to inform the editor that all subsequent painting request should not change the editor state.
In 'pure painting mode' editor also behaves as if soft wraps were not enabled.
setPurePaintingMode
in interface EditorEx
enabled
- 'pure painting mode' status to usepublic void registerLineExtensionPainter(java.util.function.IntFunction<java.util.Collection<LineExtensionInfo>> lineExtensionPainter)
EditorEx
EditorLinePainter
extensions).registerLineExtensionPainter
in interface EditorEx
public boolean processLineExtensions(int line, Processor<? super LineExtensionInfo> processor)
public void registerScrollBarRepaintCallback(ButtonlessScrollBarUI.ScrollbarRepaintCallback callback)
EditorEx
Animator
to draw itself.registerScrollBarRepaintCallback
in interface EditorEx
callback
- callback which will be called from the JComponent.paint(Graphics)
method of
the editor vertical scrollbar.public int getExpectedCaretOffset()
getExpectedCaretOffset
in interface EditorEx
EditorMouseListener.mousePressed(EditorMouseEvent)
implementation, as at the time this method is invoked caret wasn't yet moved
to the press position. In other circumstances it's just equal to primary caret's offset.public void setContextMenuGroupId(java.lang.String groupId)
EditorEx
null
value disabling context menu). This method might have no effect if default editor's popup handler was
overridden using EditorEx.installPopupHandler(EditorPopupHandler)
.setContextMenuGroupId
in interface EditorEx
EditorEx.getContextMenuGroupId()
public java.lang.String getContextMenuGroupId()
EditorEx
null
value meaning no context menu). Returned value might be meaningless if default editor's popup handler
was overridden using EditorEx.installPopupHandler(EditorPopupHandler)
.getContextMenuGroupId
in interface EditorEx
EditorEx.setContextMenuGroupId(String)
public void installPopupHandler(EditorPopupHandler popupHandler)
EditorEx
Default handler shows a context menu corresponding to a certain action group
registered in ActionManager
. Group's id can be changed using EditorEx.setContextMenuGroupId(String)
. For inline custom visual
elements (inlays) action group is determined by EditorCustomElementRenderer.getContextMenuGroupId(Inlay)
and
EditorCustomElementRenderer.getContextMenuGroup(Inlay)
.
If multiple handlers are installed, they are processed in order, starting from the most recently installed one. Processing stops when
some handler returns true
from EditorPopupHandler.handlePopup(EditorMouseEvent)
method.
installPopupHandler
in interface EditorEx
EditorEx.uninstallPopupHandler(EditorPopupHandler)
public void uninstallPopupHandler(EditorPopupHandler popupHandler)
EditorEx
EditorPopupHandler
.uninstallPopupHandler
in interface EditorEx
EditorEx.installPopupHandler(EditorPopupHandler)
public void setCustomCursor(java.lang.Object requestor, java.awt.Cursor cursor)
EditorEx
cursor
parameter value is not null
, sets custom cursor to editor's content component
,
otherwise restores default editor cursor management logic (requestor
parameter value should be the same in both setting and
restoring requests). 'Restoring' call for a requestor, which hasn't set a cursor previously, has no effect. If multiple requestors have
currently set custom cursors, one of them will be used (it is unspecified, which one).setCustomCursor
in interface EditorEx
public void setViewer(boolean isViewer)
EditorEx
public boolean isViewer()
Editor
public boolean isRendererMode()
isRendererMode
in interface EditorEx
public void setRendererMode(boolean isRendererMode)
setRendererMode
in interface EditorEx
public void setFile(VirtualFile vFile)
public VirtualFile getVirtualFile()
getVirtualFile
in interface EditorEx
public SelectionModelImpl getSelectionModel()
Editor
To query or change selections for specific carets, CaretModel
interface should be used.
getSelectionModel
in interface Editor
Editor.getCaretModel()
public MarkupModelEx getMarkupModel()
Editor
See also DocumentMarkupModel.forDocument(Document, Project, boolean)
EditorEx.getFilteredDocumentMarkupModel()
.
getMarkupModel
in interface Editor
getMarkupModel
in interface EditorEx
public MarkupModelEx getFilteredDocumentMarkupModel()
EditorEx
This model differs from the one from DocumentMarkupModel#forDocument, as it does not contain highlighters that should not be visible in this Editor. (for example, debugger breakpoints in a diff viewer editors)
getFilteredDocumentMarkupModel
in interface EditorEx
MarkupEditorFilter
,
setHighlightingFilter(Condition)
,
DocumentMarkupModel.forDocument(Document, Project, boolean)
public FoldingModelImpl getFoldingModel()
Editor
getFoldingModel
in interface Editor
getFoldingModel
in interface EditorEx
public CaretModelImpl getCaretModel()
Editor
getCaretModel
in interface Editor
public ScrollingModelEx getScrollingModel()
Editor
getScrollingModel
in interface Editor
getScrollingModel
in interface EditorEx
public SoftWrapModelImpl getSoftWrapModel()
Editor
getSoftWrapModel
in interface Editor
getSoftWrapModel
in interface EditorEx
public InlayModelImpl getInlayModel()
getInlayModel
in interface Editor
public EditorKind getEditorKind()
getEditorKind
in interface Editor
public EditorSettings getSettings()
Editor
getSettings
in interface Editor
public void resetSizes()
public void reinitSettings()
reinitSettings
in interface EditorEx
public void throwDisposalError(java.lang.String msg)
throwEditorNotDisposedError(String)
public void setFontSize(int fontSize)
setFontSize
in interface EditorEx
public int getFontSize()
public ActionCallback type(java.lang.String text)
public void setHighlighter(EditorHighlighter highlighter)
setHighlighter
in interface EditorEx
public EditorHighlighter getHighlighter()
getHighlighter
in interface EditorEx
public EditorComponentImpl getContentComponent()
Editor
DataProvider
.getContentComponent
in interface Editor
public com.intellij.openapi.editor.impl.EditorGutterComponentImpl getGutterComponentEx()
getGutterComponentEx
in interface EditorEx
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface EditorEx
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener, Disposable parentDisposable)
addPropertyChangeListener
in interface EditorEx
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface EditorEx
public void setInsertMode(boolean mode)
setInsertMode
in interface EditorEx
public boolean isInsertMode()
Editor
isInsertMode
in interface Editor
true
if the editor is in insert mode, false
otherwise.public void setColumnMode(boolean mode)
setColumnMode
in interface EditorEx
public boolean isColumnMode()
Editor
isColumnMode
in interface Editor
true
if the editor uses column selection, false
if it uses regular selection.public int yToVisualLine(int y)
yToVisualLine
in interface Editor
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 java.awt.geom.Point2D offsetToPoint2D(int offset, boolean leanTowardsLargerOffsets, boolean beforeSoftWrap)
offsetToPoint2D
in interface Editor
Editor.offsetToVisualPosition(int, boolean, boolean)
public java.awt.Point offsetToXY(int offset, boolean leanForward, boolean beforeSoftWrap)
offsetToXY
in interface Editor
Editor.offsetToVisualPosition(int, boolean, boolean)
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 int offsetToVisualColumnInFoldRegion(FoldRegion region, int offset, boolean leanTowardsLargerOffsets)
public int visualColumnToOffsetInFoldRegion(FoldRegion region, int visualColumn, boolean leansRight)
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 void setCaretActive()
public int offsetToVisualLine(int offset)
public int visualLineStartOffset(int visualLine)
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 java.awt.Point logicalPositionToXY(LogicalPosition pos)
Editor
logicalPositionToXY
in interface Editor
pos
- the logical position.content component
.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 visible)
Editor
Editor.visualPositionToXY(VisualPosition)
, but returns potentially more precise result.visualPositionToPoint2D
in interface Editor
public float getScale()
public int findNearestDirectionBoundary(int offset, boolean lookForward)
public int visualLineToY(int line)
visualLineToY
in interface Editor
public void repaint(int startOffset, int endOffset)
repaint
in interface EditorEx
repaint
in interface HighlighterClient
public void hideCursor()
public boolean isScrollToCaret()
public void setScrollToCaret(boolean scrollToCaret)
public Disposable getDisposable()
public DocumentEx getDocument()
Editor
getDocument
in interface Editor
getDocument
in interface EditorEx
getDocument
in interface HighlighterClient
public javax.swing.JComponent getComponent()
Editor
getComponent
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 isStickySelection()
EditorEx
EditorEx.setStickySelection(boolean)
call with 'true'
argument.isStickySelection
in interface EditorEx
true
if 'sticky selection' mode is active at the current editor; false
otherwisepublic void setStickySelection(boolean enable)
EditorEx
sticky selection
mode.setStickySelection
in interface EditorEx
enable
- flag that identifies if 'sticky selection'
mode should be enabledpublic void setHorizontalTextAlignment(int alignment)
public boolean isRightAligned()
public boolean isDisposed()
Editor
isDisposed
in interface Editor
true
if the editor has been disposed, false
otherwise.public void stopDumbLater()
public void startDumb()
stopDumbLater()
or stopDumb()
must be performed in finallypublic boolean isDumb()
public IndentsModel getIndentsModel()
getIndentsModel
in interface Editor
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 getPermanentHeaderComponent()
getPermanentHeaderComponent
in interface EditorEx
public void setPermanentHeaderComponent(javax.swing.JComponent component)
setPermanentHeaderComponent
in interface EditorEx
public javax.swing.JComponent getHeaderComponent()
getHeaderComponent
in interface Editor
Editor.setHeaderComponent(JComponent)
or null
if no header currently installed.public void setBackgroundColor(java.awt.Color color)
setBackgroundColor
in interface EditorEx
public java.awt.Color getBackgroundColor()
getBackgroundColor
in interface EditorEx
public TextDrawingCallback getTextDrawingCallback()
getTextDrawingCallback
in interface EditorEx
public void setPlaceholder(java.lang.CharSequence text)
EditorEx
'placeholder text'
for the current editor, i.e. virtual text that will be represented until
any user data is entered.
Feel free to see the detailed feature
definition here.setPlaceholder
in interface EditorEx
text
- virtual text to show until user data is entered or the editor is focusedpublic void setPlaceholderAttributes(TextAttributes attributes)
EditorEx
null
means default values should be used.setPlaceholderAttributes
in interface EditorEx
EditorEx.setPlaceholder(CharSequence)
public TextAttributes getPlaceholderAttributes()
public java.lang.CharSequence getPlaceholder()
public void setShowPlaceholderWhenFocused(boolean show)
EditorEx
'placeholder text'
is visible when editor is focused.setShowPlaceholderWhenFocused
in interface EditorEx
show
- flag indicating whether placeholder is visible when editor is focused.EditorEx.setPlaceholder(CharSequence)
public boolean getShowPlaceholderWhenFocused()
public TextRange getComposedTextRange()
public int getMaxWidthInRange(int startOffset, int endOffset)
getMaxWidthInRange
in interface EditorEx
public boolean isPaintSelection()
public void setPaintSelection(boolean paintSelection)
public EditorImpl.CaretRectangle [] getCaretLocations(boolean onlyIfShown)
public int getAscent()
Editor
Editor.visualLineToY(int)
,
Editor.visualPositionToXY(VisualPosition)
, etc) and baseline of text in that visual line.public int getLineHeight()
Editor
getLineHeight
in interface Editor
public int getDescent()
public int getCharHeight()
public java.awt.FontMetrics getFontMetrics(int fontType)
public int getPreferredHeight()
public java.awt.Dimension getPreferredSize()
public java.awt.Dimension getContentSize()
getContentSize
in interface EditorEx
public javax.swing.JScrollPane getScrollPane()
getScrollPane
in interface EditorEx
public void setBorder(javax.swing.border.Border border)
public int logicalPositionToOffset(LogicalPosition pos)
Editor
logicalPositionToOffset
in interface Editor
pos
- the logical position.public int getVisibleLineCount()
public VisualPosition logicalToVisualPosition(LogicalPosition logicalPos)
Editor
logicalToVisualPosition
in interface Editor
logicalPos
- the logical position.public LogicalPosition visualToLogicalPosition(VisualPosition visiblePos)
Editor
visualToLogicalPosition
in interface Editor
visiblePos
- the visual position.public DataContext getDataContext()
getDataContext
in interface EditorEx
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 boolean setCaretVisible(boolean b)
setCaretVisible
in interface EditorEx
public boolean setCaretEnabled(boolean enabled)
setCaretEnabled
in interface EditorEx
public void addFocusListener(FocusChangeListener listener)
addFocusListener
in interface EditorEx
public void addFocusListener(FocusChangeListener listener, Disposable parentDisposable)
addFocusListener
in interface EditorEx
public Project getProject()
Editor
getProject
in interface Editor
getProject
in interface HighlighterClient
null
if the editor is not related to any project.public boolean isOneLineMode()
Editor
isOneLineMode
in interface Editor
true
if the editor is one-line, false
otherwise.public boolean isEmbeddedIntoDialogWrapper()
isEmbeddedIntoDialogWrapper
in interface EditorEx
public void setEmbeddedIntoDialogWrapper(boolean b)
setEmbeddedIntoDialogWrapper
in interface EditorEx
public void setOneLineMode(boolean isOneLineMode)
setOneLineMode
in interface EditorEx
public CopyProvider getCopyProvider()
getCopyProvider
in interface EditorEx
public CutProvider getCutProvider()
getCutProvider
in interface EditorEx
public PasteProvider getPasteProvider()
getPasteProvider
in interface EditorEx
public DeleteProvider getDeleteProvider()
getDeleteProvider
in interface EditorEx
public void setColorsScheme(EditorColorsScheme scheme)
setColorsScheme
in interface EditorEx
public EditorColorsScheme getColorsScheme()
Editor
getColorsScheme
in interface Editor
public void setVerticalScrollbarOrientation(int type)
setVerticalScrollbarOrientation
in interface EditorEx
public void setVerticalScrollbarVisible(boolean b)
setVerticalScrollbarVisible
in interface EditorEx
public void setHorizontalScrollbarVisible(boolean b)
setHorizontalScrollbarVisible
in interface EditorEx
public int getVerticalScrollbarOrientation()
getVerticalScrollbarOrientation
in interface EditorEx
public boolean isMirrored()
public boolean processKeyTyped(java.awt.event.KeyEvent e)
processKeyTyped
in interface EditorEx
public void recordLatencyAwareAction(java.lang.String actionId, long timestampMs)
public boolean isProcessingTypedAction()
public void setDropHandler(EditorDropHandler dropHandler)
public void setHighlightingFilter(Condition<RangeHighlighter> filter)
public void setUseEditorAntialiasing(boolean value)
public EditorGutter getGutter()
Editor
public boolean isInDistractionFreeMode()
public void putInfo(java.util.Map<java.lang.String,java.lang.String> info)
public void codeStyleSettingsChanged(CodeStyleSettingsChangeEvent event)
codeStyleSettingsChanged
in interface CodeStyleSettingsListener