gnu.jemacs.swing
Class SwingBuffer

java.lang.Object
  extended by gnu.lists.AbstractSequence
      extended by gnu.jemacs.buffer.Buffer
          extended by gnu.jemacs.swing.SwingBuffer
All Implemented Interfaces:
CharSeq, Consumable, Sequence, java.lang.CharSequence, java.lang.Iterable, java.util.Collection, java.util.List

public class SwingBuffer
extends Buffer

An Emacs buffer implemented using the Swing toolkits.


Field Summary
 BufferContent content
           
 javax.swing.text.Caret curPosition
           
static javax.swing.text.Style defaultStyle
           
 javax.swing.text.DefaultStyledDocument doc
           
 javax.swing.text.Style inputStyle
           
 javax.swing.text.StyledDocument modelineDocument
           
static javax.swing.text.Style redStyle
           
static javax.swing.text.StyleContext styles
           
 
Fields inherited from class gnu.jemacs.buffer.Buffer
activeKeymaps, buffers, fileBuffers, markMarker, pointMarker
 
Fields inherited from interface gnu.lists.Sequence
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, ELEMENT_VALUE, EOF_VALUE, eofValue, FLOAT_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
SwingBuffer(java.lang.String name)
           
SwingBuffer(java.lang.String name, BufferContent content)
           
 
Method Summary
 int createPos(int index, boolean isAfter)
          Generate a position at a given index.
 java.lang.Object get(int index)
          See java.util.List.
 int getDot()
           
 int getLength()
           
 CharSeq getStringContent()
           
 void insert(char ch, int count)
          Insert count copies of ch at point.
 void insert(int index, java.lang.String string, java.lang.Object style)
           
 void insert(java.lang.String string, java.lang.Object style)
           
 void insert(java.lang.String string, java.lang.Object style, int ipos)
          Insert string with given style at position pair.
 void insertFile(java.io.Reader in)
           
 void invoke(java.lang.Runnable doRun)
          This is intended for Runnable's that may affect the state of the buffer.
 int lineStartOffset(int offset)
           
 int maxDot()
           
 int nextIndex(int ipos)
          Get the offset from the beginning corresponding to a position cookie.
 InPort openReader(int start, int count)
           
 void redrawModeline()
           
 void removeAll()
           
 void removeChar(int count)
           
 void removePos(int ipos, int count)
          Remove one or more elements.
 void removeRegion(int start, int end)
           
 void restorePointMark(long pointMark)
           
 void save(java.io.Writer out)
           
 long savePointMark()
           
 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.
 void setDot(int i)
           
 int size()
          See java.util.List.
 
Methods inherited from class gnu.jemacs.buffer.Buffer
backwardChar, charAt, charWidth, checkMark, coerceBuffer, consume, countColumns, currentColumn, currentColumn, display, fill, fill, findFile, forwardChar, forwardLine, forwardLine, generateNewBufferName, getBuffer, getChars, getCurrent, getFileName, getLocalKeymap, getMarkMarker, getName, getPath, getPoint, getPointMarker, insert, insert, insert, insertAll, insertFile, length, lineStartOffset, makeBufferLocal, minDot, moveToColumn, positionToOffset, save, setCharAt, setCurrent, setFileName, setLocalKeymap, setPath, setPoint, subSequence, toString, writeTo, writeTo
 
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, clear, compare, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createRelativePos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePosRange, retainAll, set, set, setPosNext, setPosPrevious, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gnu.lists.Sequence
elements, fill, isEmpty, set
 
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, subList, toArray, toArray
 
Methods inherited from interface gnu.lists.Consumable
consume
 

Field Detail

doc

public javax.swing.text.DefaultStyledDocument doc

curPosition

public javax.swing.text.Caret curPosition

content

public BufferContent content

modelineDocument

public javax.swing.text.StyledDocument modelineDocument

styles

public static javax.swing.text.StyleContext styles

defaultStyle

public static javax.swing.text.Style defaultStyle

inputStyle

public javax.swing.text.Style inputStyle

redStyle

public static javax.swing.text.Style redStyle
Constructor Detail

SwingBuffer

public SwingBuffer(java.lang.String name)

SwingBuffer

public SwingBuffer(java.lang.String name,
                   BufferContent content)
Method Detail

removeRegion

public void removeRegion(int start,
                         int end)
                  throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException

removeAll

public void removeAll()
Specified by:
removeAll in class Buffer

removeChar

public void removeChar(int count)
Overrides:
removeChar in class Buffer

removePos

public void removePos(int ipos,
                      int count)
Description copied from class: AbstractSequence
Remove one or more elements.

Overrides:
removePos in class AbstractSequence
Parameters:
ipos - position where elements should be removed
count - if non-negative, remove that number of elements following (poses, posNumber); if negative the negative of the number of elements to remove before (poses, posNumber).

save

public void save(java.io.Writer out)
          throws java.lang.Exception
Specified by:
save in class Buffer
Throws:
java.lang.Exception

insert

public void insert(char ch,
                   int count)
Description copied from class: Buffer
Insert count copies of ch at point.

Overrides:
insert in class Buffer

insert

public void insert(int index,
                   java.lang.String string,
                   java.lang.Object style)

insert

public void insert(java.lang.String string,
                   java.lang.Object style)
Overrides:
insert in class Buffer

insert

public void insert(java.lang.String string,
                   java.lang.Object style,
                   int ipos)
Description copied from class: Buffer
Insert string with given style at position pair.

Specified by:
insert in class Buffer

insertFile

public void insertFile(java.io.Reader in)
                throws java.lang.Exception
Specified by:
insertFile in class Buffer
Throws:
java.lang.Exception

redrawModeline

public void redrawModeline()
Specified by:
redrawModeline in class Buffer

scan

public long scan(char target,
                 int start,
                 int end,
                 int count,
                 boolean allowQuit)
Description copied from class: Buffer
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 END is zero, use beginning or end of (FIXME: accessible part of) the buffer, as appropriate for the direction indicated by COUNT. 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).

Specified by:
scan in class Buffer
Returns:
(SHORTAGE<<32|POS)

lineStartOffset

public int lineStartOffset(int offset)
Specified by:
lineStartOffset in class Buffer

getDot

public int getDot()
Overrides:
getDot in class Buffer

setDot

public void setDot(int i)
Overrides:
setDot in class Buffer

maxDot

public int maxDot()
Specified by:
maxDot in class Buffer

getLength

public int getLength()
Specified by:
getLength in class Buffer

getStringContent

public CharSeq getStringContent()
Specified by:
getStringContent in class Buffer

createPos

public int createPos(int index,
                     boolean isAfter)
Description copied from class: AbstractSequence
Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.

Specified by:
createPos in class AbstractSequence
Parameters:
index - offset from beginning of desired position
isAfter - should the position have the isAfter property

get

public java.lang.Object get(int index)
Description copied from class: AbstractSequence
See java.util.List.

Specified by:
get in interface Sequence
Specified by:
get in interface java.util.List
Specified by:
get in class AbstractSequence

size

public int size()
Description copied from class: AbstractSequence
See java.util.List.

Specified by:
size in interface Sequence
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Specified by:
size in class AbstractSequence

nextIndex

public int nextIndex(int ipos)
Description copied from class: AbstractSequence
Get the offset from the beginning corresponding to a position cookie.

Overrides:
nextIndex in class AbstractSequence

savePointMark

public long savePointMark()
Specified by:
savePointMark in class Buffer

restorePointMark

public void restorePointMark(long pointMark)
Specified by:
restorePointMark in class Buffer

openReader

public InPort openReader(int start,
                         int count)
Specified by:
openReader in class Buffer

invoke

public void invoke(java.lang.Runnable doRun)
Description copied from class: Buffer
This is intended for Runnable's that may affect the state of the buffer. The implementation should make shure that the GUI is properly updated before control returns

Specified by:
invoke in class Buffer
See Also:
Buffer.invoke(java.lang.Runnable)