org.gnu.readline

Class ReadlineReader

public class ReadlineReader extends Reader

A Reader wrapper for the Readline classes. This seems to work fine in conjunction with such classes as BufferedReader, but it hasn't been tested well enough to see if this will work well in all cases. This was implemented to make it easier to supplant Readline's functionality [shrug] anywhere and everywhere, but specifically in BeanShell.

Version: $Revision: 1.2 $

Author: Shane Celis

Field Summary
static StringDEFAULT_PROMPT
Constructor Summary
ReadlineReader(String prompt, ReadlineLibrary lib)
Constructs a ReadlineReader object with the given prompt.
ReadlineReader(ReadlineLibrary lib)
Constructs a ReadlineReader object with the default prompt.
ReadlineReader(File history, ReadlineLibrary lib)
Constructs a ReadlineReader object with an associated history file.
ReadlineReader(String prompt, File history, ReadlineLibrary lib)
Constructs a ReadlineReader object with an associated history file and prompt.
Method Summary
voidclose()
Nullifies all buffers and writes history file if one was given at construction time.
StringgetPrompt()
Returns the current prompt.
static voidmain(String[] args)
intread(char[] cbuf, int off, int len)
Reads what's given from readline() into a buffer.
voidsetPrompt(String prompt)
Sets the prompt to the given value.

Field Detail

DEFAULT_PROMPT

public static final String DEFAULT_PROMPT

Constructor Detail

ReadlineReader

public ReadlineReader(String prompt, ReadlineLibrary lib)
Constructs a ReadlineReader object with the given prompt.

ReadlineReader

public ReadlineReader(ReadlineLibrary lib)
Constructs a ReadlineReader object with the default prompt.

ReadlineReader

public ReadlineReader(File history, ReadlineLibrary lib)
Constructs a ReadlineReader object with an associated history file.

ReadlineReader

public ReadlineReader(String prompt, File history, ReadlineLibrary lib)
Constructs a ReadlineReader object with an associated history file and prompt.

Method Detail

close

public void close()
Nullifies all buffers and writes history file if one was given at construction time.

getPrompt

public String getPrompt()
Returns the current prompt.

main

public static void main(String[] args)

read

public int read(char[] cbuf, int off, int len)
Reads what's given from readline() into a buffer. When that buffer is emptied, readline() is called again to replenish that buffer. This seems to work fine in conjunction with such classes as BufferedReader, but it hasn't been tested well enough to see if this will work well in all cases.

setPrompt

public void setPrompt(String prompt)
Sets the prompt to the given value.
Released under the LGPL, (c) Bernhard Bablok, Henner Zeller 1998-2002
Homepage: http://java-readline.sourceforge.net/