gnu.mapping
Class TtyInPort

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by gnu.text.LineBufferedReader
              extended by gnu.mapping.InPort
                  extended by gnu.mapping.TtyInPort
All Implemented Interfaces:
Printable, java.io.Closeable, java.lang.Readable

public class TtyInPort
extends InPort

An interactive input-port. Supports prompting, auto-flush of tied output port, transcripts.


Field Summary
protected  boolean promptEmitted
           
protected  Procedure prompter
           
protected  OutPort tie
           
 
Fields inherited from class gnu.mapping.InPort
inLocation
 
Fields inherited from class gnu.text.LineBufferedReader
buffer, limit, lineNumber, markPos, pos, readAheadLimit, readState
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
TtyInPort(java.io.InputStream in, java.lang.String name, OutPort tie)
           
TtyInPort(java.io.Reader in, java.lang.String name, OutPort tie)
           
 
Method Summary
 int fill(int len)
          Called by read() when it needs its buffer filled.
 Procedure getPrompter()
          Get the current prompter function.
 void lineStart(boolean revisited)
          A hook to allow sub-classes to perform some action at start of line.
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 void setPrompter(Procedure prompter)
          Set the prompter function.
 
Methods inherited from class gnu.mapping.InPort
convertToReader, inDefault, openFile, openFile, print, setInDefault
 
Methods inherited from class gnu.text.LineBufferedReader
getColumnNumber, getConvertCR, getLineNumber, getName, getReadState, mark, markSupported, peek, readLine, readLine, ready, reset, setBuffer, setConvertCR, setLineNumber, setName, skip_quick, skip, skip, unread_quick, unread
 
Methods inherited from class java.io.FilterReader
close, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tie

protected OutPort tie

prompter

protected Procedure prompter

promptEmitted

protected boolean promptEmitted
Constructor Detail

TtyInPort

public TtyInPort(java.io.InputStream in,
                 java.lang.String name,
                 OutPort tie)

TtyInPort

public TtyInPort(java.io.Reader in,
                 java.lang.String name,
                 OutPort tie)
Method Detail

getPrompter

public Procedure getPrompter()
Get the current prompter function.


setPrompter

public void setPrompter(Procedure prompter)
Set the prompter function. The argument is called when a new line is read. It is passed one argument (this input port), and should return a string. That string is printed as the prompt string.


fill

public int fill(int len)
         throws java.io.IOException
Description copied from class: LineBufferedReader
Called by read() when it needs its buffer filled. Read characters into buffer, starting at off, for len. Can assume that len > 0. Only called if pos>=limit. Return -1 if EOF, otherwise number of read chars. This can be usefully overridden by sub-classes.

Overrides:
fill in class LineBufferedReader
Throws:
java.io.IOException

lineStart

public void lineStart(boolean revisited)
               throws java.io.IOException
Description copied from class: LineBufferedReader
A hook to allow sub-classes to perform some action at start of line. Called just before the first character of the new line is read.

Overrides:
lineStart in class LineBufferedReader
Parameters:
revisited - true if we have read here before (i.e. we did a reset of unread() to get here)
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Overrides:
read in class LineBufferedReader
Throws:
java.io.IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class LineBufferedReader
Throws:
java.io.IOException