public interface FoldingModel
Editor.getFoldingModel()
Modifier and Type | Method and Description |
---|---|
default boolean |
addFoldRegion(FoldRegion region)
Deprecated.
Does nothing
|
FoldRegion |
addFoldRegion(int startOffset,
int endOffset,
java.lang.String placeholderText)
Adds a fold region for the specified range of the document.
|
FoldRegion [] |
getAllFoldRegions()
Gets the list of all fold regions in the specified editor.
|
FoldRegion |
getCollapsedRegionAtOffset(int offset)
Returns collapsed folded region at a given offset or
null if there's no such region. |
FoldRegion |
getFoldRegion(int startOffset,
int endOffset)
Returns fold region with given boundaries, if it exists, or
null otherwise. |
boolean |
isOffsetCollapsed(int offset)
Checks if the specified offset in the document belongs to a folded region.
|
void |
removeFoldRegion(FoldRegion region)
Removes the specified fold region.
|
default void |
runBatchFoldingOperation(java.lang.Runnable operation)
Runs an operation which is allowed to modify fold regions in the editor by calling
addFoldRegion(int, int, String) and removeFoldRegion(FoldRegion) . |
void |
runBatchFoldingOperation(java.lang.Runnable operation,
boolean moveCaretFromCollapsedRegion)
Deprecated.
Passing
false for moveCaretFromCollapsedRegion might leave caret in an inconsistent state
after the operation. Use runBatchFoldingOperation(Runnable) instead. |
void |
runBatchFoldingOperation(java.lang.Runnable operation,
boolean allowMovingCaret,
boolean keepRelativeCaretPosition)
Performs folding model changes (creation/deletion/expanding/collapsing of fold regions).
|
default void |
runBatchFoldingOperationDoNotCollapseCaret(java.lang.Runnable operation) |
FoldRegion addFoldRegion(int startOffset, int endOffset, java.lang.String placeholderText)
Runnable
passed to runBatchFoldingOperation(Runnable)
.
The region is initially not folded.startOffset
- the start offset of the region to fold.endOffset
- the end offset of the region to fold.placeholderText
- the text to display instead of the region contents when the region is folded.null
if folding is currently disabled or corresponding region cannot be added (e.g. if it
intersects with another existing region)@Deprecated default boolean addFoldRegion(FoldRegion region)
void removeFoldRegion(FoldRegion region)
Runnable
passed to runBatchFoldingOperation(Runnable)
.region
- the region to remove.FoldRegion [] getAllFoldRegions()
RangeMarker.BY_START_OFFSET
comparator, i.e. first by start offset, then by end offset.boolean isOffsetCollapsed(int offset)
runBatchFoldingOperation(Runnable)
invocation.offset
- the offset to check.getCollapsedRegionAtOffset(int)
FoldRegion getCollapsedRegionAtOffset(int offset)
null
if there's no such region. Returned region will satisfy the
following condition: region.getStartOffset() <= offset < region.getEndOffset()
runBatchFoldingOperation(Runnable)
invocation.isOffsetCollapsed(int)
FoldRegion getFoldRegion(int startOffset, int endOffset)
null
otherwise.default void runBatchFoldingOperation(java.lang.Runnable operation)
addFoldRegion(int, int, String)
and removeFoldRegion(FoldRegion)
.operation
- the operation to execute.@Deprecated void runBatchFoldingOperation(java.lang.Runnable operation, boolean moveCaretFromCollapsedRegion)
false
for moveCaretFromCollapsedRegion
might leave caret in an inconsistent state
after the operation. Use runBatchFoldingOperation(Runnable)
instead.default void runBatchFoldingOperationDoNotCollapseCaret(java.lang.Runnable operation)
void runBatchFoldingOperation(java.lang.Runnable operation, boolean allowMovingCaret, boolean keepRelativeCaretPosition)
allowMovingCaret
- If false
, requests to collapse a region containing caret won't be processed. If true
-
corresponding operation will be performed with caret automatically moved to the region's start offset
(original caret position is remembered and is restored on region expansion).keepRelativeCaretPosition
- If true
, editor scrolling position will be adjusted after the operation, so that vertical
caret position will remain unchanged (if caret is not visible at operation start, top left corner
of editor will be used as an anchor instead). If false
, no scrolling adjustment will be done.