gnu.jemacs.swing

Class SwingBuffer

Implemented Interfaces:
CharSeq, CharSequence, java.util.List, Consumable, Sequence

public class SwingBuffer
extends Buffer

An Emacs buffer implemented using the Swing toolkits.

Field Summary

BufferContent
content
Caret
curPosition
static Style
defaultStyle
DefaultStyledDocument
doc
Style
inputStyle
StyledDocument
modelineDocument
static 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, 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, eofValue

Constructor Summary

SwingBuffer(String name)
SwingBuffer(String name, BufferContent content)

Method Summary

int
createPos(int index, boolean isAfter)
Generate a position at a given index.
Object
get(int index)
See java.util.List.
int
getDot()
int
getLength()
CharSeq
getStringContent()
void
insert(String string, Object style)
void
insert(String string, Object style, int ipos)
void
insert(char ch, int count)
void
insert(int index, String string, Object style)
void
insertFile(Reader in)
void
invoke(Runnable doRun)
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(Writer out)
long
savePointMark()
long
scan(char target, int start, int end, int count, boolean allowQuit)
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, getDot, getFileName, getLength, getLocalKeymap, getMarkMarker, getName, getPath, getPoint, getPointMarker, getStringContent, insert, insert, insert, insert, insert, insert, insertAll, insertFile, insertFile, invoke, length, lineStartOffset, lineStartOffset, makeBufferLocal, maxDot, minDot, moveToColumn, openReader, positionToOffset, redrawModeline, removeAll, removeChar, restorePointMark, save, save, savePointMark, scan, setCharAt, setCurrent, setDot, 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, createPos, createRelativePos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hasNext, hasPrevious, hashCode, 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, toString, unsupported, unsupportedException

Field Details

content

public BufferContent content

curPosition

public Caret curPosition

defaultStyle

public static Style defaultStyle

doc

public DefaultStyledDocument doc

inputStyle

public Style inputStyle

modelineDocument

public StyledDocument modelineDocument

redStyle

public static Style redStyle

styles

public static javax.swing.text.StyleContext styles

Constructor Details

SwingBuffer

public SwingBuffer(String name)

SwingBuffer

public SwingBuffer(String name,
                   BufferContent content)

Method Details

createPos

public int createPos(int index,
                     boolean isAfter)
Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.
Overrides:
createPos in interface AbstractSequence
Parameters:
index - offset from beginning of desired position
isAfter - should the position have the isAfter property

get

public Object get(int index)
See java.util.List.
Specified by:
get in interface Sequence
Overrides:
get in interface AbstractSequence

getDot

public int getDot()
Overrides:
getDot in interface Buffer

getLength

public int getLength()
Overrides:
getLength in interface Buffer

getStringContent

public CharSeq getStringContent()
Overrides:
getStringContent in interface Buffer

insert

public void insert(String string,
                   Object style)
Overrides:
insert in interface Buffer

insert

public void insert(String string,
                   Object style,
                   int ipos)
Overrides:
insert in interface Buffer

insert

public void insert(char ch,
                   int count)
Overrides:
insert in interface Buffer

insert

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

insertFile

public void insertFile(Reader in)
            throws Exception
Overrides:
insertFile in interface Buffer

invoke

public void invoke(Runnable doRun)
Overrides:
invoke in interface Buffer
See Also:
gnu.jemacs.buffer.Buffer.invoke(java.lang.Runnable)

lineStartOffset

public int lineStartOffset(int offset)
Overrides:
lineStartOffset in interface Buffer

maxDot

public int maxDot()
Overrides:
maxDot in interface Buffer

nextIndex

public int nextIndex(int ipos)
Get the offset from the beginning corresponding to a position cookie.
Overrides:
nextIndex in interface AbstractSequence

openReader

public InPort openReader(int start,
                         int count)
Overrides:
openReader in interface Buffer

redrawModeline

public void redrawModeline()
Overrides:
redrawModeline in interface Buffer

removeAll

public void removeAll()
Overrides:
removeAll in interface Buffer

removeChar

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

removePos

public void removePos(int ipos,
                      int count)
Remove one or more elements.
Overrides:
removePos in interface 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).

removeRegion

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

restorePointMark

public void restorePointMark(long pointMark)
Overrides:
restorePointMark in interface Buffer

save

public void save(Writer out)
            throws Exception
Overrides:
save in interface Buffer

savePointMark

public long savePointMark()
Overrides:
savePointMark in interface Buffer

scan

public long scan(char target,
                 int start,
                 int end,
                 int count,
                 boolean allowQuit)
Overrides:
scan in interface Buffer

setDot

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

size

public int size()
See java.util.List.
Specified by:
size in interface Sequence
Overrides:
size in interface AbstractSequence