public class DefaultFoldManager extends java.lang.Object implements FoldManager
RSyntaxTextArea.SYNTAX_STYLE_PROPERTY
changes, the current fold parser is uninstalled, and one appropriate
for the new language, if any, is installed.
FoldParserManager
.PROPERTY_FOLDS_UPDATED
Constructor and Description |
---|
DefaultFoldManager(RSyntaxTextArea textArea)
Constructor.
|
Modifier and Type | Method and 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) |
int |
getVisibleLineBelow(int line) |
boolean |
isCodeFoldingEnabled()
Returns whether code folding is enabled.
|
boolean |
isCodeFoldingSupportedAndEnabled()
Returns
true 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.
|
public DefaultFoldManager(RSyntaxTextArea textArea)
textArea
- The text area whose folds we are managing.public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
FoldManager
addPropertyChangeListener
in interface FoldManager
l
- The new listener.FoldManager.removePropertyChangeListener(PropertyChangeListener)
public void clear()
FoldManager
clear
in interface FoldManager
public boolean ensureOffsetNotInClosedFold(int offs)
FoldManager
ensureOffsetNotInClosedFold
in interface FoldManager
offs
- The offset.FoldManager.getDeepestFoldContaining(int)
public Fold getDeepestFoldContaining(int offs)
FoldManager
getDeepestFoldContaining
in interface FoldManager
offs
- The offset.null
if
no fold contains the offset.public Fold getDeepestOpenFoldContaining(int offs)
FoldManager
getDeepestOpenFoldContaining
in interface FoldManager
offs
- The offset.null
if no open fold contains the
offset.public Fold getFold(int index)
FoldManager
getFold
in interface FoldManager
index
- The index of the fold.FoldManager.getFoldCount()
public int getFoldCount()
FoldManager
getFoldCount
in interface FoldManager
FoldManager.getFold(int)
public Fold getFoldForLine(int line)
FoldManager
getFoldForLine
in interface FoldManager
line
- The line number.null
if the line is not the start
of a fold region.FoldManager.isFoldStartLine(int)
public int getHiddenLineCount()
FoldManager
getHiddenLineCount
in interface FoldManager
FoldManager.getHiddenLineCountAbove(int)
public int getHiddenLineCountAbove(int line)
FoldManager
getHiddenLineCountAbove
in interface FoldManager
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),
use getHiddenLineCountAbove(int, true)
.line
.FoldManager.getHiddenLineCountAbove(int, boolean)
public int getHiddenLineCountAbove(int line, boolean physical)
FoldManager
getHiddenLineCountAbove
in interface FoldManager
line
- The line.physical
- Whether line
is the number of a physical
line (i.e. visible, not code-folded), or a logical one (i.e. any
line from the model). If line
was determined by a
raw line calculation (i.e. (visibleTopY / lineHeight)
),
this value should be true
. It should be
false
when it was calculated from an offset in the
document (for example).line
.public int getLastVisibleLine()
FoldManager
getLastVisibleLine
in interface FoldManager
public int getVisibleLineAbove(int line)
getVisibleLineAbove
in interface FoldManager
public int getVisibleLineBelow(int line)
getVisibleLineBelow
in interface FoldManager
public boolean isCodeFoldingEnabled()
FoldManager
isCodeFoldingEnabled
in interface FoldManager
FoldManager.setCodeFoldingEnabled(boolean)
public boolean isCodeFoldingSupportedAndEnabled()
FoldManager
true
if and only if code folding is enabled for
this text area, AND folding is supported for the language it is editing.
Whether or not folding is supported for a language depends on whether
a fold parser is registered for that language with the
FoldParserManager
.isCodeFoldingSupportedAndEnabled
in interface FoldManager
FoldParserManager
public boolean isFoldStartLine(int line)
FoldManager
isFoldStartLine
in interface FoldManager
line
- The line.FoldManager.getFoldForLine(int)
public boolean isLineHidden(int line)
FoldManager
isLineHidden
in interface FoldManager
line
- The line to check.public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
FoldManager
removePropertyChangeListener
in interface FoldManager
l
- The listener to remove.FoldManager.addPropertyChangeListener(PropertyChangeListener)
public void reparse()
FoldManager
reparse
in interface FoldManager
public void setCodeFoldingEnabled(boolean enabled)
FoldManager
setCodeFoldingEnabled
in interface FoldManager
enabled
- Whether code folding should be enabled.FoldManager.isCodeFoldingEnabled()
public void setFolds(java.util.List<Fold> folds)
FoldManager
setFolds
in interface FoldManager
folds
- The new folds. This should not be null
.