gnu.jemacs.swing
Class BufferContent

java.lang.Object
  extended by gnu.lists.AbstractSequence
      extended by gnu.lists.GapVector
          extended by gnu.lists.StableVector
              extended by gnu.lists.CharBuffer
                  extended by gnu.jemacs.swing.BufferContent
All Implemented Interfaces:
CharSeq, Consumable, Sequence, java.lang.CharSequence, java.lang.Iterable, java.util.Collection, java.util.List, javax.swing.text.AbstractDocument.Content

public class BufferContent
extends CharBuffer
implements javax.swing.text.AbstractDocument.Content

A Content class that supports Emacs-style Markers. The standard GapContent is close, but unfortunately it only supports inserting *before* marks, which is not the Emacs default. This provides a superset of the Position functionality (except for undo).


Field Summary
 
Fields inherited from class gnu.lists.StableVector
free, FREE_POSITION, positions
 
Fields inherited from class gnu.lists.GapVector
base, gapEnd, gapStart
 
Fields inherited from interface gnu.lists.Sequence
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, EOF_VALUE, eofValue, FLOAT_VALUE, GROUP_VALUE, INT_S16_VALUE, INT_S32_VALUE, INT_S64_VALUE, INT_S8_VALUE, INT_U16_VALUE, INT_U32_VALUE, INT_U64_VALUE, INT_U8_VALUE, OBJECT_VALUE, PRIM_VALUE, PROCESSING_INSTRUCTION_VALUE, TEXT_BYTE_VALUE
 
Constructor Summary
BufferContent()
           
BufferContent(int initialSize)
           
 
Method Summary
 javax.swing.text.Position createPosition(int offset)
           
 void dump()
           
protected  int getChars(int where, int len)
           
 void getChars(int where, int len, javax.swing.text.Segment txt)
           
 java.lang.String getString(int where, int len)
           
static int indexOf(char[] buffer, int start, int limit, char ch)
           
 javax.swing.undo.UndoableEdit insertString(int where, java.lang.String str)
           
 javax.swing.undo.UndoableEdit insertString(int where, java.lang.String str, boolean beforeMarkers)
           
static int lastIndexOf(char[] buffer, int start, int limit, char ch)
          Search for the last occurrence of a character in buffer[limit..start].
 javax.swing.undo.UndoableEdit remove(int where, int nitems)
           
 long scan(char target, int start, int end, int count, boolean allowQuit)
          Search in BUF for COUNT instances of the character TARGET between START and END.
 
Methods inherited from class gnu.lists.CharBuffer
charAt, consume, delete, fill, fill, getArray, getChars, insert, length, setCharAt, subSequence, toString, writeTo, writeTo, writeTo, writeTo
 
Methods inherited from class gnu.lists.StableVector
addPos, adjustPositions, allocPositionIndex, chainFreelist, consumePosRange, copyPos, createPos, endPos, fillPosRange, gapReserve, hasNext, isAfterPos, nextIndex, nextPos, releasePos, removePosRange, shiftGap, startPos, unchainFreelist
 
Methods inherited from class gnu.lists.GapVector
add, fill, gapReserve, get, getNextKind, set, size
 
Methods inherited from class gnu.lists.AbstractSequence
add, addAll, addAll, append, append, append, baseUriOfPos, clear, compare, compare, compare, consume, consumeNext, contains, containsAll, createRelativePos, elements, equals, equals, fill, firstAttributePos, firstChildPos, fromEndIndex, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, parentPos, previousPos, rank, remove, remove, removeAll, removePos, retainAll, set, setPosNext, setPosPrevious, stableCompare, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.text.AbstractDocument.Content
length
 
Methods inherited from interface gnu.lists.Sequence
elements, fill, get, isEmpty, size
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 
Methods inherited from interface gnu.lists.Consumable
consume
 

Constructor Detail

BufferContent

public BufferContent()

BufferContent

public BufferContent(int initialSize)
Method Detail

getChars

protected int getChars(int where,
                       int len)
                throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException

getChars

public void getChars(int where,
                     int len,
                     javax.swing.text.Segment txt)
              throws javax.swing.text.BadLocationException
Specified by:
getChars in interface javax.swing.text.AbstractDocument.Content
Throws:
javax.swing.text.BadLocationException

getString

public java.lang.String getString(int where,
                                  int len)
                           throws javax.swing.text.BadLocationException
Specified by:
getString in interface javax.swing.text.AbstractDocument.Content
Throws:
javax.swing.text.BadLocationException

remove

public javax.swing.undo.UndoableEdit remove(int where,
                                            int nitems)
                                     throws javax.swing.text.BadLocationException
Specified by:
remove in interface javax.swing.text.AbstractDocument.Content
Throws:
javax.swing.text.BadLocationException

insertString

public javax.swing.undo.UndoableEdit insertString(int where,
                                                  java.lang.String str,
                                                  boolean beforeMarkers)
                                           throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException

insertString

public javax.swing.undo.UndoableEdit insertString(int where,
                                                  java.lang.String str)
                                           throws javax.swing.text.BadLocationException
Specified by:
insertString in interface javax.swing.text.AbstractDocument.Content
Throws:
javax.swing.text.BadLocationException

createPosition

public javax.swing.text.Position createPosition(int offset)
                                         throws javax.swing.text.BadLocationException
Specified by:
createPosition in interface javax.swing.text.AbstractDocument.Content
Throws:
javax.swing.text.BadLocationException

dump

public void dump()

indexOf

public static int indexOf(char[] buffer,
                          int start,
                          int limit,
                          char ch)

lastIndexOf

public static int lastIndexOf(char[] buffer,
                              int start,
                              int limit,
                              char ch)
Search for the last occurrence of a character in buffer[limit..start].


scan

public final long scan(char target,
                       int start,
                       int end,
                       int count,
                       boolean allowQuit)
Search in BUF for COUNT instances of the character TARGET between START and END. If COUNT is positive, search forwards; END must be >= START. If COUNT is negative, search backwards for the -COUNTth instance; END must be <= START. If COUNT is zero, do anything you please; run rogue, for all I care. If we find COUNT instances, SHORTAGE is zero, and return the position after the COUNTth match. Note that for reverse motion this is not the same as the usual convention for Emacs motion commands. If we don't find COUNT instances before reaching END, set SHORTAGE to the number of TARGETs left unfound, and return (shortage<<32|END).

Returns:
(SHORTAGE<<32|POS)