com.raelity.jvi.swing
Class DefaultBuffer

java.lang.Object
  extended by com.raelity.jvi.Buffer
      extended by com.raelity.jvi.swing.DefaultBuffer
All Implemented Interfaces:
ViBuffer, ViOptionBag

public class DefaultBuffer
extends Buffer


Nested Class Summary
static class DefaultBuffer.UndoGroupManager
          UndoGroupManager is an UndoManager that allows explicit control of how UndoableEdits are coalesced into compound edits, rather than using the rules defined by the edits themselves.
 
Nested classes/interfaces inherited from class com.raelity.jvi.Buffer
Buffer.VisualBounds
 
Field Summary
static BooleanOption cacheTrace
           
 
Fields inherited from class com.raelity.jvi.Buffer
b_op_end, b_op_start, b_p_et, b_p_mps, b_p_sw, b_p_ts, b_p_tw, b_visual_end, b_visual_mode, b_visual_start
 
Constructor Summary
DefaultBuffer(ViTextView tv)
           
 
Method Summary
 void beginInsertUndo()
          start a insert (user typing) ungo group, must be paired
protected  void beginInsertUndoOperation()
           
 void beginUndo()
          start an undo group, must be paired
protected  void beginUndoOperation()
           
 ViMark createMark()
          NEEDSWORK: createMark: attached to this text view, should be in ViBuffer
 void deleteChar(int start, int end)
          Delete a bunch of characters
 void endInsertUndo()
          end a insert (user typing) ungo group, must be paired
protected  void endInsertUndoOperation()
           
 void endUndo()
          end an undo group, must be paired
protected  void endUndoOperation()
           
 int getColumnNumber(int offset)
           
 Element getCurrentLineElement()
           
protected  Document getDoc()
           
 Document getDocument()
          Use the document in default implementation.
protected  Element getElem(int offset)
           
protected  com.raelity.jvi.swing.DefaultBuffer.ElemCache getElemCache(int offset)
           
protected  int getElemIndex(int offset)
           
 int getLength()
           
 int getLineCount()
           
 Element getLineElement(int line)
           
 int getLineEndOffset(int line)
           
 int getLineEndOffsetFromOffset(int offset)
           
 int getLineNumber(int offset)
           
 TextUtil.MySegment getLineSegment(int line)
          The associated character iterator is initialized with first().
 int getLineStartOffset(int line)
           
 int getLineStartOffsetFromOffset(int offset)
           
 TextUtil.MySegment getSegment(int offset, int length, TextUtil.MySegment seg)
          Fill the argument segment with the requested text.
 String getText(int offset, int length)
          get some text from the document
 int getUndoLength()
           
 int getUndoOffset()
           
 void insertText(int offset, String s)
          insert text at specified location
 boolean isGuarded(int offset)
          a portion of a document may be write protected
 boolean isInInsertUndo()
          between a insert begin and end undo?
 boolean isInUndo()
          between a begin and an end undo?
protected  boolean isUndoChange()
          This method can be used to determine if some action(s) cause a change.
protected  void processTextException(BadLocationException ex)
           
 void redo()
          redo a change
protected  void redoOperation()
           
 void reindent(int line, int count)
          platform indent algorithm
 void removeShare()
           
 void replaceChar(int offset, char c)
           
 void replaceString(int start, int end, String s)
          Replace indicated region with string
 void setMarkOffset(ViMark mark_arg, int offset, boolean global_mark)
          Deprecated.  
 void undo()
          undo a change
protected  void undoOperation()
           
 
Methods inherited from class com.raelity.jvi.Buffer
activateOptions, addBlock, addShare, calculateVisualBlocks, checkModeline, displayFileInfo, docInsert, docRemove, dumpBlocks, getDisplayFileName, getDisplayFileNameAndSize, getHighlightSearchBlocks, getJavaFile, getMark, getRemovedText, getShare, getVisualSelectBlocks, initOptions, isInsertMode, modifyFilename, viOptionSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheTrace

public static BooleanOption cacheTrace
Constructor Detail

DefaultBuffer

public DefaultBuffer(ViTextView tv)
Method Detail

removeShare

public void removeShare()
Overrides:
removeShare in class Buffer

getDoc

protected final Document getDoc()

getLineNumber

public int getLineNumber(int offset)
Returns:
the line number, 1 based, corresponding to the offset

getColumnNumber

public int getColumnNumber(int offset)
Returns:
the column number, 1 based, corresponding to the offset

getLineStartOffset

public int getLineStartOffset(int line)
Returns:
the starting offset of the line

getLineEndOffset

public int getLineEndOffset(int line)
Returns:
the starting offset of the line

getLineStartOffsetFromOffset

public int getLineStartOffsetFromOffset(int offset)
Returns:
the starting offset of the line

getLineEndOffsetFromOffset

public int getLineEndOffsetFromOffset(int offset)
Returns:
the end offset of the line, char past newline

getLineCount

public int getLineCount()
Returns:
the number of lines in the associated file

getLength

public int getLength()
Returns:
the length of the document

getSegment

public final TextUtil.MySegment getSegment(int offset,
                                           int length,
                                           TextUtil.MySegment seg)
Description copied from interface: ViBuffer
Fill the argument segment with the requested text. If the segment is null, then create a segment. The associated character iterator is initialized with first().

Returns:
a segment for the requested text.

isGuarded

public boolean isGuarded(int offset)
Description copied from interface: ViBuffer
a portion of a document may be write protected


getDocument

public Document getDocument()
Use the document in default implementation.

Returns:
opaque FileObject backing this EditorPane

replaceString

public void replaceString(int start,
                          int end,
                          String s)
Description copied from interface: ViBuffer
Replace indicated region with string


deleteChar

public void deleteChar(int start,
                       int end)
Description copied from interface: ViBuffer
Delete a bunch of characters


insertText

public void insertText(int offset,
                       String s)
Description copied from interface: ViBuffer
insert text at specified location


replaceChar

public void replaceChar(int offset,
                        char c)

getText

public String getText(int offset,
                      int length)
               throws BadLocationException
Description copied from interface: ViBuffer
get some text from the document

Throws:
BadLocationException

processTextException

protected void processTextException(BadLocationException ex)

reindent

public void reindent(int line,
                     int count)
Description copied from interface: ViBuffer
platform indent algorithm


undo

public final void undo()
Description copied from interface: ViBuffer
undo a change


redo

public final void redo()
Description copied from interface: ViBuffer
redo a change


beginUndo

public final void beginUndo()
Description copied from interface: ViBuffer
start an undo group, must be paired


endUndo

public final void endUndo()
Description copied from interface: ViBuffer
end an undo group, must be paired


isInUndo

public final boolean isInUndo()
Description copied from interface: ViBuffer
between a begin and an end undo?


beginInsertUndo

public final void beginInsertUndo()
Description copied from interface: ViBuffer
start a insert (user typing) ungo group, must be paired


endInsertUndo

public final void endInsertUndo()
Description copied from interface: ViBuffer
end a insert (user typing) ungo group, must be paired


isInInsertUndo

public final boolean isInInsertUndo()
Description copied from interface: ViBuffer
between a insert begin and end undo?


beginUndoOperation

protected void beginUndoOperation()

endUndoOperation

protected void endUndoOperation()

beginInsertUndoOperation

protected void beginInsertUndoOperation()

endInsertUndoOperation

protected void endInsertUndoOperation()

undoOperation

protected void undoOperation()

redoOperation

protected void redoOperation()

setMarkOffset

public void setMarkOffset(ViMark mark_arg,
                          int offset,
                          boolean global_mark)
Deprecated. 

Set a mark at the specified offset.

Should use ViMark.set(ViFPOS, ViTextView)

Parameters:
global_mark - if false then it is a mark within a file, otherwise it is a file mark and is valid between files.

createMark

public ViMark createMark()
Description copied from interface: ViBuffer
NEEDSWORK: createMark: attached to this text view, should be in ViBuffer

Returns:
a null Mark

getElemIndex

protected int getElemIndex(int offset)
Returns:
the element index from root which contains the offset

getElem

protected Element getElem(int offset)
Returns:
the element which contains the offset

getElemCache

protected com.raelity.jvi.swing.DefaultBuffer.ElemCache getElemCache(int offset)

getLineSegment

public final TextUtil.MySegment getLineSegment(int line)
Description copied from interface: ViBuffer
The associated character iterator is initialized with first().

Returns:
the positionsegment for the indicated line

getLineElement

public final Element getLineElement(int line)
Returns:
the element for the indicated line

getCurrentLineElement

public final Element getCurrentLineElement()

isUndoChange

protected boolean isUndoChange()
This method can be used to determine if some action(s) cause a change. The method itself has nothing to do with undo. It is called from an optimized undo.

Returns:
true if there has be a change to the document since this method was last called.

getUndoOffset

public int getUndoOffset()

getUndoLength

public int getUndoLength()