Interface FoldManager
-
- All Known Implementing Classes:
DefaultFoldManager
public interface FoldManager
Manages code folding in an instance of RSyntaxTextArea.By default,
RSyntaxTextArea
uses aDefaultFoldManager
, which is sufficient for almost all applications.- Version:
- 1.0
- See Also:
DefaultFoldManager
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_FOLDS_UPDATED
Property fired when folds have been updated.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener to this fold manager.void
clear()
Removes all folds.boolean
ensureOffsetNotInClosedFold(int offs)
Ensures that the specified offset is not hidden in a collapsed fold.Fold
getDeepestFoldContaining(int offs)
Returns the "deepest" nested fold containing the specified offset.Fold
getDeepestOpenFoldContaining(int offs)
Returns the "deepest" open fold containing the specified offset.Fold
getFold(int index)
Returns a specific top-level fold, which may have child folds.int
getFoldCount()
Returns the number of top-level folds.Fold
getFoldForLine(int line)
Returns the fold region that starts at the specified line.int
getHiddenLineCount()
Returns the total number of hidden (folded) lines.int
getHiddenLineCountAbove(int line)
Returns the number of lines "hidden" by collapsed folds above the specified line.int
getHiddenLineCountAbove(int line, boolean physical)
Returns the number of lines "hidden" by collapsed folds above the specified line.int
getLastVisibleLine()
Returns the last visible line in the text area, taking into account folds.int
getVisibleLineAbove(int line)
Returns the visible line above a specified line.int
getVisibleLineBelow(int line)
Returns the visible line below a specified line.boolean
isCodeFoldingEnabled()
Returns whether code folding is enabled.boolean
isCodeFoldingSupportedAndEnabled()
Returnstrue
if and only if code folding is enabled for this text area, AND folding is supported for the language it is editing.boolean
isFoldStartLine(int line)
Returns whether the specified line contains the start of a fold region.boolean
isLineHidden(int line)
Returns whether a line is hidden in a collapsed fold.void
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a property change listener from this fold manager.void
reparse()
Forces an immediate reparsing for folds, if folding is enabled.void
setCodeFoldingEnabled(boolean enabled)
Sets whether code folding is enabled.void
setFolds(java.util.List<Fold> folds)
Sets the folds for this fold manager.
-
-
-
Field Detail
-
PROPERTY_FOLDS_UPDATED
static final java.lang.String PROPERTY_FOLDS_UPDATED
Property fired when folds have been updated.- See Also:
- Constant Field Values
-
-
Method Detail
-
addPropertyChangeListener
void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener to this fold manager.- Parameters:
l
- The new listener.- See Also:
removePropertyChangeListener(PropertyChangeListener)
-
clear
void clear()
Removes all folds.
-
ensureOffsetNotInClosedFold
boolean ensureOffsetNotInClosedFold(int offs)
Ensures that the specified offset is not hidden in a collapsed fold. Any folds containing this offset that are collapsed will be expanded.- Parameters:
offs
- The offset.- Returns:
- Whether any folds had to be opened.
- See Also:
getDeepestFoldContaining(int)
-
getDeepestFoldContaining
Fold getDeepestFoldContaining(int offs)
Returns the "deepest" nested fold containing the specified offset.- Parameters:
offs
- The offset.- Returns:
- The deepest fold containing the offset, or
null
if no fold contains the offset.
-
getDeepestOpenFoldContaining
Fold getDeepestOpenFoldContaining(int offs)
Returns the "deepest" open fold containing the specified offset.- Parameters:
offs
- The offset.- Returns:
- The fold, or
null
if no open fold contains the offset.
-
getFold
Fold getFold(int index)
Returns a specific top-level fold, which may have child folds.- Parameters:
index
- The index of the fold.- Returns:
- The fold.
- See Also:
getFoldCount()
-
getFoldCount
int getFoldCount()
Returns the number of top-level folds.- Returns:
- The number of top-level folds.
- See Also:
getFold(int)
-
getFoldForLine
Fold getFoldForLine(int line)
Returns the fold region that starts at the specified line.- Parameters:
line
- The line number.- Returns:
- The fold, or
null
if the line is not the start of a fold region. - See Also:
isFoldStartLine(int)
-
getHiddenLineCount
int getHiddenLineCount()
Returns the total number of hidden (folded) lines.- Returns:
- The total number of hidden (folded) lines.
- See Also:
getHiddenLineCountAbove(int)
-
getHiddenLineCountAbove
int getHiddenLineCountAbove(int line)
Returns the number of lines "hidden" by collapsed folds above the specified line.- Parameters:
line
- The line. This is the line number for a logical line. For the line number of a physical line (i.e. visible, not folded), usegetHiddenLineCountAbove(int, true)
.- Returns:
- The number of lines hidden in folds above
line
. - See Also:
getHiddenLineCountAbove(int, boolean)
-
getHiddenLineCountAbove
int getHiddenLineCountAbove(int line, boolean physical)
Returns the number of lines "hidden" by collapsed folds above the specified line.- Parameters:
line
- The line.physical
- Whetherline
is the number of a physical line (i.e. visible, not code-folded), or a logical one (i.e. any line from the model). Ifline
was determined by a raw line calculation (i.e.(visibleTopY / lineHeight)
), this value should betrue
. It should befalse
when it was calculated from an offset in the document (for example).- Returns:
- The number of lines hidden in folds above
line
.
-
getLastVisibleLine
int getLastVisibleLine()
Returns the last visible line in the text area, taking into account folds.- Returns:
- The last visible line.
-
getVisibleLineAbove
int getVisibleLineAbove(int line)
Returns the visible line above a specified line.- Parameters:
line
- The line to check.- Returns:
- The visible line above the specified line.
- See Also:
getVisibleLineBelow(int)
-
getVisibleLineBelow
int getVisibleLineBelow(int line)
Returns the visible line below a specified line.- Parameters:
line
- The line to check.- Returns:
- The visible line below the specified line.
- See Also:
getVisibleLineAbove(int)
-
isCodeFoldingEnabled
boolean isCodeFoldingEnabled()
Returns whether code folding is enabled. Note that only certain languages support code folding; those that do not will ignore this property.- Returns:
- Whether code folding is enabled.
- See Also:
setCodeFoldingEnabled(boolean)
-
isCodeFoldingSupportedAndEnabled
boolean isCodeFoldingSupportedAndEnabled()
Returnstrue
if and only if code folding is enabled for this text area, AND folding is supported for the language it is editing. Whether folding is supported for a language depends on whether a fold parser is registered for that language with theFoldParserManager
.- Returns:
- Whether folding is supported and enabled for this text area.
- See Also:
FoldParserManager
-
isFoldStartLine
boolean isFoldStartLine(int line)
Returns whether the specified line contains the start of a fold region.- Parameters:
line
- The line.- Returns:
- Whether the line contains the start of a fold region.
- See Also:
getFoldForLine(int)
-
isLineHidden
boolean isLineHidden(int line)
Returns whether a line is hidden in a collapsed fold.- Parameters:
line
- The line to check.- Returns:
- Whether the line is hidden in a collapsed fold.
-
removePropertyChangeListener
void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a property change listener from this fold manager.- Parameters:
l
- The listener to remove.- See Also:
addPropertyChangeListener(PropertyChangeListener)
-
reparse
void reparse()
Forces an immediate reparsing for folds, if folding is enabled. This usually does not need to be called by the programmer, since fold parsing is done automatically by RSTA.
-
setCodeFoldingEnabled
void setCodeFoldingEnabled(boolean enabled)
Sets whether code folding is enabled. Note that only certain languages will support code folding out of the box. Those languages which do not support folding will ignore this property.- Parameters:
enabled
- Whether code folding should be enabled.- See Also:
isCodeFoldingEnabled()
-
setFolds
void setFolds(java.util.List<Fold> folds)
Sets the folds for this fold manager.- Parameters:
folds
- The new folds. This should not benull
.
-
-