org.gjt.sp.jedit.textarea
Class FoldVisibilityManager

java.lang.Object
  |
  +--org.gjt.sp.jedit.textarea.FoldVisibilityManager

public class FoldVisibilityManager
extends java.lang.Object

Manages fold visibility.

This class contains methods for translating between physical and virtual line numbers, for determining which lines are visible and which aren't, and for expanding and collapsing folds.

When jEdit's folding or narrowing features are used to hide portions of a buffer, the "virtual" line count visible in the text area is generally not equal to the "physical" line count of the buffer represented by the gutter's display.

You can use the physicalToVirtual(int) and virtualToPhysical(int) methods to convert one type of line number to another.

Since:
jEdit 4.0pre1
Version:
$Id: FoldVisibilityManager.java,v 1.30 2003/02/21 20:12:19 spestov Exp $
Author:
Slava Pestov, John Gellene (API documentation)

Constructor Summary
FoldVisibilityManager(Buffer buffer, OffsetManager offsetMgr, JEditTextArea textArea)
           
 
Method Summary
 int _getIndex()
          Do not call this method.
 void _grab(int index)
          Do not call this method.
 void _invalidate(int startLine)
          Do not call this method.
 void _release()
          Do not call this method.
 void collapseFold(int line)
          Collapses the fold at the specified physical line index.
 void expandAllFolds()
          Expands all folds.
 int expandFold(int line, boolean fully)
          Expands the fold at the specified physical line index.
 void expandFolds(char digit)
          This method should only be called from actions.xml.
 void expandFolds(int foldLevel)
          Expands all folds with the specified fold level.
 void foldStructureChanged()
          This method is only public so that the EditPane class can call it in response to a buffer's fold handler change.
 int getFirstVisibleLine()
          Returns the physical line number of the first visible line.
 int getLastVisibleLine()
          Returns the physical line number of the last visible line.
 int getNextVisibleLine(int line)
          Returns the next visible line after the specified line index.
 int getPrevVisibleLine(int line)
          Returns the previous visible line before the specified line index.
 int getVirtualLineCount()
          Returns the number of virtual lines in the buffer.
 boolean isLineVisible(int line)
          Returns if the specified line is visible.
 boolean isNarrowed()
          Returns if the buffer has been narrowed.
 void narrow(int start, int end)
          Narrows the visible portion of the buffer to the specified line range.
 int physicalToVirtual(int line)
          Converts a physical line number to a virtual line number.
 int virtualToPhysical(int line)
          Converts a virtual line number to a physical line number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FoldVisibilityManager

public FoldVisibilityManager(Buffer buffer,
                             OffsetManager offsetMgr,
                             JEditTextArea textArea)
Method Detail

isNarrowed

public boolean isNarrowed()
Returns if the buffer has been narrowed.

Since:
jEdit 4.0pre2

getVirtualLineCount

public int getVirtualLineCount()
Returns the number of virtual lines in the buffer.

Since:
jEdit 4.0pre1

isLineVisible

public final boolean isLineVisible(int line)
Returns if the specified line is visible.

Parameters:
line - A physical line index
Since:
jEdit 4.0pre1

getFirstVisibleLine

public int getFirstVisibleLine()
Returns the physical line number of the first visible line.

Since:
jEdit 4.0pre3

getLastVisibleLine

public int getLastVisibleLine()
Returns the physical line number of the last visible line.

Since:
jEdit 4.0pre3

getNextVisibleLine

public int getNextVisibleLine(int line)
Returns the next visible line after the specified line index.

Parameters:
line - A physical line index
Since:
jEdit 4.0pre1

getPrevVisibleLine

public int getPrevVisibleLine(int line)
Returns the previous visible line before the specified line index.

Parameters:
line - A physical line index
Since:
jEdit 4.0pre1

physicalToVirtual

public int physicalToVirtual(int line)
Converts a physical line number to a virtual line number.

Parameters:
line - A physical line index
Since:
jEdit 4.0pre1

virtualToPhysical

public int virtualToPhysical(int line)
Converts a virtual line number to a physical line number.

Parameters:
line - A virtual line index
Since:
jEdit 4.0pre1

collapseFold

public void collapseFold(int line)
Collapses the fold at the specified physical line index.

Parameters:
line - A physical line index
Since:
jEdit 4.0pre1

expandFold

public int expandFold(int line,
                      boolean fully)
Expands the fold at the specified physical line index.

Parameters:
line - A physical line index
fully - If true, all subfolds will also be expanded
Since:
jEdit 4.0pre3

expandAllFolds

public void expandAllFolds()
Expands all folds.

Since:
jEdit 4.0pre1

expandFolds

public void expandFolds(char digit)
This method should only be called from actions.xml.

Since:
jEdit 4.0pre1

expandFolds

public void expandFolds(int foldLevel)
Expands all folds with the specified fold level.

Parameters:
foldLevel - The fold level
Since:
jEdit 4.0pre1

narrow

public void narrow(int start,
                   int end)
Narrows the visible portion of the buffer to the specified line range.

Parameters:
start - The first line
end - The last line
Since:
jEdit 4.0pre1

_grab

public final void _grab(int index)
Do not call this method. The only reason it is public is so that the Buffer class can call it.


_release

public final void _release()
Do not call this method. The only reason it is public is so that the Buffer class can call it.


_getIndex

public final int _getIndex()
Do not call this method. The only reason it is public is so that the Buffer class can call it.


_invalidate

public void _invalidate(int startLine)
Do not call this method. The only reason it is public is so that the Buffer class can call it.


foldStructureChanged

public void foldStructureChanged()
This method is only public so that the EditPane class can call it in response to a buffer's fold handler change.

Since:
jEdit 4.0pre8