public class Session extends DefaultStyledDocument
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElement
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
buffer, BUFFER_SIZE_DEFAULT
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
StreamDescriptionProperty, TitleProperty
Constructor and Description |
---|
Session(StringEvaluator e)
Create a session for the evaluator e with a default prompt.
|
Session(String promptString,
StringEvaluator e)
Create a session for the evaluator e with prescribed prompt
|
Modifier and Type | Method and Description |
---|---|
void |
displayAndPrompt(String result,
AttributeSet style)
Display the result of some work done by the evaluator and provide
a new prompt.
|
void |
evaluate()
Send the text portion between the prompt and the end of the
document to the evaluator and append the result.
|
protected String |
getCommand()
Returns the text portion between the prompt and the end of the
document.
|
void |
historyNext()
Go forward in the command history.
|
void |
historyPrevious()
Go backwards in the command history.
|
void |
insertString(int offs,
String str,
AttributeSet a)
Inserts str at the specified offset using the input style, iff
the offset corresponds to a position behaind the last promp.
|
void |
remove(int offs,
int len)
Ignore requests to replace the selection
|
protected void |
replaceCommand(String str)
Removes the text portion between the prompt and the end of the
document and replaces it by str.
|
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged
addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeUndoableEditListener, render
public Session(StringEvaluator e)
public Session(String promptString, StringEvaluator e)
public void displayAndPrompt(String result, AttributeSet style)
public void evaluate()
protected String getCommand()
public void historyNext()
public void historyPrevious()
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
insertString
in interface Document
insertString
in class AbstractDocument
BadLocationException
public void remove(int offs, int len)
remove
in interface Document
remove
in class AbstractDocument
protected void replaceCommand(String str)