gnu.mapping

Class TtyInPort

Implemented Interfaces:
Printable

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_SIZE, buffer, in, limit, lineNumber, markPos, pos, readAheadLimit, readState

Constructor Summary

TtyInPort(InputStream in, Path name, OutPort tie)
TtyInPort(Reader in, Path name, OutPort tie)

Method Summary

int
fill(int len)
Procedure
getPrompter()
Get the current prompter function.
void
lineStart(boolean revisited)
int
read()
int
read(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

close, fill, getColumnNumber, getConvertCR, getLineNumber, getName, getPath, getReadState, incrLineNumber, lineStart, mark, markSupported, peek, read, read, readLine, readLine, ready, reset, setBuffer, setConvertCR, setKeepFullLines, setLineNumber, setName, setPath, skip, skip, skipRestOfLine, skip_quick, unread, unread_quick

Field Details

promptEmitted

protected boolean promptEmitted

prompter

protected Procedure prompter

tie

protected OutPort tie

Constructor Details

TtyInPort

public TtyInPort(InputStream in,
                 Path name,
                 OutPort tie)

TtyInPort

public TtyInPort(Reader in,
                 Path name,
                 OutPort tie)

Method Details

fill

public int fill(int len)
            throws java.io.IOException
Overrides:
fill in interface LineBufferedReader

getPrompter

public Procedure getPrompter()
Get the current prompter function.

lineStart

public void lineStart(boolean revisited)
            throws java.io.IOException
Overrides:
lineStart in interface LineBufferedReader

read

public int read()
            throws IOException
Overrides:
read in interface LineBufferedReader

read

public int read(cbuf[] ,
                int off,
                int len)
            throws IOException

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.