gnu.jemacs.buffer
Class Buffer

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

public abstract class Buffer
extends AbstractSequence
implements CharSeq


Field Summary
 EKeymap[] activeKeymaps
           
static java.util.Hashtable buffers
          Map buffer names to buffers.
static java.util.Hashtable fileBuffers
          Map file names to buffer.s
 Marker markMarker
           
 Marker pointMarker
           
 
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
Buffer(java.lang.String name)
           
 
Method Summary
 void backwardChar(int i)
           
 char charAt(int index)
           
 int charWidth(char ch, int column)
           
 int checkMark()
           
static Buffer coerceBuffer(java.lang.Object buf)
           
 void consume(int start, int count, Consumer out)
           
 int countColumns(char[] chars, int start, int count, int initial)
           
 int currentColumn()
           
 int currentColumn(int offset)
          Return the column number at a specified offset.
 EWindow display(boolean notThisWindow, EFrame frame)
           
 void fill(char value)
          Set all the elements to a given character.
 void fill(int fromIndex, int toIndex, char value)
           
static Buffer findFile(java.lang.String fname)
           
 void forwardChar(int i)
           
 int forwardLine(int lines)
           
 long forwardLine(int lines, int start)
          Find the position a give number of lines forward or backward.
static java.lang.String generateNewBufferName(java.lang.String start)
           
static Buffer getBuffer(java.lang.String name)
           
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
          Copy characters into a destination buffer.
static Buffer getCurrent()
           
 int getDot()
           
 java.lang.String getFileName()
           
abstract  int getLength()
           
 EKeymap getLocalKeymap()
           
 Marker getMarkMarker(boolean force)
           
 java.lang.String getName()
           
 int getPoint()
           
 Marker getPointMarker(boolean share)
           
abstract  CharSeq getStringContent()
           
 void insert(char[] chars, int offset, int count, java.lang.Object style, int ipos)
          Insert character with given style at position pair.
 void insert(char ch, int count)
          Insert count copies of ch at point.
 void insert(char ch, int count, java.lang.Object style)
          Insert count copies of ch at point.
 void insert(java.lang.Object value, java.lang.Object style)
           
 void insert(java.lang.String string, java.lang.Object style)
           
abstract  void insert(java.lang.String string, java.lang.Object style, int ipos)
          Insert string with given style at position pair.
 void insertAll(java.lang.Object[] values, java.lang.Object style)
           
abstract  void insertFile(java.io.Reader in)
           
 void insertFile(java.lang.String filename)
           
abstract  void invoke(java.lang.Runnable doRun)
          This is intended for Runnable's that may affect the state of the buffer.
 int length()
          Get length of string, in characters.
 int lineStartOffset()
           
abstract  int lineStartOffset(int offset)
           
static void makeBufferLocal(java.lang.Object symbol, boolean all)
           
abstract  int maxDot()
           
 int minDot()
           
 int moveToColumn(int column, boolean force)
           
abstract  InPort openReader(int start, int count)
           
 int positionToOffset(java.lang.Object position)
          Convert an Emacs position (Marker, or 1-origin integer) to a (0-origin) buffer offset.
abstract  void redrawModeline()
           
abstract  void removeAll()
           
 void removeChar(int count)
           
abstract  void restorePointMark(long pointMark)
           
 void save()
           
abstract  void save(java.io.Writer out)
           
abstract  long savePointMark()
           
abstract  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 setCharAt(int index, char ch)
           
static void setCurrent(Buffer buffer)
           
 void setDot(int i)
           
 void setFileName(java.lang.String fname)
           
 void setLocalKeymap(EKeymap map)
           
 void setPoint(int i)
           
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
           
 void writeTo(java.lang.Appendable dest)
           
 void writeTo(int start, int count, java.lang.Appendable dest)
          Append a specified subsequence to an Appendable.
 
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, append, append, append, baseUriOfPos, clear, compare, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createPos, createRelativePos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, fromEndIndex, get, 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, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setPosNext, setPosPrevious, size, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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
 

Field Detail

pointMarker

public Marker pointMarker

markMarker

public Marker markMarker

buffers

public static java.util.Hashtable buffers
Map buffer names to buffers.


fileBuffers

public static java.util.Hashtable fileBuffers
Map file names to buffer.s


activeKeymaps

public EKeymap[] activeKeymaps
Constructor Detail

Buffer

public Buffer(java.lang.String name)
Method Detail

getName

public java.lang.String getName()

getFileName

public java.lang.String getFileName()

setFileName

public void setFileName(java.lang.String fname)

getStringContent

public abstract CharSeq getStringContent()

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSeq
Specified by:
charAt in interface java.lang.CharSequence
See Also:
CharSeq.charAt(int)

setCharAt

public void setCharAt(int index,
                      char ch)
Specified by:
setCharAt in interface CharSeq
See Also:
CharSeq.setCharAt(int, char)

fill

public void fill(char value)
Description copied from interface: CharSeq
Set all the elements to a given character.

Specified by:
fill in interface CharSeq
See Also:
CharSeq.fill(char)

fill

public void fill(int fromIndex,
                 int toIndex,
                 char value)
Specified by:
fill in interface CharSeq
See Also:
CharSeq.fill(int, int, char)

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
Description copied from interface: CharSeq
Copy characters into a destination buffer. Same interface as java.lang.String's getChars.

Specified by:
getChars in interface CharSeq
See Also:
CharSeq.getChars(int, int, char[], int)

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface CharSeq
Specified by:
subSequence in interface java.lang.CharSequence

writeTo

public void writeTo(int start,
                    int count,
                    java.lang.Appendable dest)
             throws java.io.IOException
Description copied from interface: CharSeq
Append a specified subsequence to an Appendable. An allowable implementation is: dest.append(this, start, start+count). Hence implementors of Appendable should avoid calling writeTo - though they can call getChars.

Specified by:
writeTo in interface CharSeq
Throws:
java.io.IOException
See Also:
CharSeq.writeTo(int, int, Appendable)

writeTo

public void writeTo(java.lang.Appendable dest)
             throws java.io.IOException
Specified by:
writeTo in interface CharSeq
Throws:
java.io.IOException

consume

public void consume(int start,
                    int count,
                    Consumer out)
Specified by:
consume in interface CharSeq
See Also:
CharSeq.consume(int, int, gnu.lists.Consumer)

findFile

public static Buffer findFile(java.lang.String fname)

getBuffer

public static Buffer getBuffer(java.lang.String name)

coerceBuffer

public static Buffer coerceBuffer(java.lang.Object buf)

generateNewBufferName

public static java.lang.String generateNewBufferName(java.lang.String start)

redrawModeline

public abstract void redrawModeline()

checkMark

public int checkMark()

getCurrent

public static Buffer getCurrent()

setCurrent

public static void setCurrent(Buffer buffer)

getDot

public int getDot()

getPoint

public int getPoint()

setDot

public void setDot(int i)

setPoint

public final void setPoint(int i)

minDot

public int minDot()

getLength

public abstract int getLength()

length

public final int length()
Description copied from interface: CharSeq
Get length of string, in characters. Synonym for size(), for compatibility with String and StringBuffer.

Specified by:
length in interface CharSeq
Specified by:
length in interface java.lang.CharSequence

maxDot

public abstract int maxDot()

forwardChar

public void forwardChar(int i)

backwardChar

public void backwardChar(int i)

toString

public java.lang.String toString()
Specified by:
toString in interface CharSeq
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class AbstractSequence

insert

public abstract void insert(java.lang.String string,
                            java.lang.Object style,
                            int ipos)
Insert string with given style at position pair.


insert

public void insert(char[] chars,
                   int offset,
                   int count,
                   java.lang.Object style,
                   int ipos)
Insert character with given style at position pair.


insertAll

public void insertAll(java.lang.Object[] values,
                      java.lang.Object style)

insert

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

insert

public void insert(java.lang.Object value,
                   java.lang.Object style)

insert

public void insert(char ch,
                   int count)
Insert count copies of ch at point.


insert

public void insert(char ch,
                   int count,
                   java.lang.Object style)
Insert count copies of ch at point.


removeChar

public void removeChar(int count)

removeAll

public abstract void removeAll()

getPointMarker

public Marker getPointMarker(boolean share)

getMarkMarker

public Marker getMarkMarker(boolean force)

positionToOffset

public int positionToOffset(java.lang.Object position)
Convert an Emacs position (Marker, or 1-origin integer) to a (0-origin) buffer offset.


insertFile

public abstract void insertFile(java.io.Reader in)
                         throws java.lang.Exception
Throws:
java.lang.Exception

save

public abstract void save(java.io.Writer out)
                   throws java.lang.Exception
Throws:
java.lang.Exception

save

public void save()

insertFile

public void insertFile(java.lang.String filename)

charWidth

public int charWidth(char ch,
                     int column)

countColumns

public int countColumns(char[] chars,
                        int start,
                        int count,
                        int initial)

currentColumn

public int currentColumn()

currentColumn

public int currentColumn(int offset)
Return the column number at a specified offset.


moveToColumn

public int moveToColumn(int column,
                        boolean force)

lineStartOffset

public abstract int lineStartOffset(int offset)

lineStartOffset

public int lineStartOffset()

scan

public abstract 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 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).

Returns:
(SHORTAGE<<32|POS)

forwardLine

public final long forwardLine(int lines,
                              int start)
Find the position a give number of lines forward or backward. A side-effect-free version of Emacs's forward-line function.

Parameters:
lines - number of lines forward (or backward if negative)
start - initial position (buffer offset)
Returns:
(SHORTAGE<<32|POS)

forwardLine

public int forwardLine(int lines)

display

public EWindow display(boolean notThisWindow,
                       EFrame frame)

makeBufferLocal

public static void makeBufferLocal(java.lang.Object symbol,
                                   boolean all)
Parameters:
all - true if make-variable-buffer-local, false if make-local-variable FIXME

getLocalKeymap

public EKeymap getLocalKeymap()

setLocalKeymap

public void setLocalKeymap(EKeymap map)

openReader

public abstract InPort openReader(int start,
                                  int count)

savePointMark

public abstract long savePointMark()

restorePointMark

public abstract void restorePointMark(long pointMark)

invoke

public abstract void invoke(java.lang.Runnable doRun)
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

Parameters:
doRun -