Package org.gnu.readline
Class ReadlineReader
java.lang.Object
java.io.Reader
org.gnu.readline.ReadlineReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
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$
- Author:
- Shane Celis <shane@terrapsring.com>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionReadlineReader
(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.ReadlineReader
(String prompt, ReadlineLibrary lib) Constructs a ReadlineReader object with the given prompt.Constructs a ReadlineReader object with the default prompt. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Nullifies all buffers and writes history file if one was given at construction time.Returns the current prompt.static void
int
read
(char[] cbuf, int off, int len) Reads what's given fromreadline()
into a buffer.void
Sets the prompt to the given value.Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
Field Details
-
DEFAULT_PROMPT
- See Also:
-
-
Constructor Details
-
ReadlineReader
Constructs a ReadlineReader object with the given prompt. -
ReadlineReader
Constructs a ReadlineReader object with the default prompt. -
ReadlineReader
Constructs a ReadlineReader object with an associated history file.- Throws:
IOException
-
ReadlineReader
Constructs a ReadlineReader object with an associated history file and prompt.- Throws:
IOException
-
-
Method Details
-
getPrompt
Returns the current prompt. -
setPrompt
Sets the prompt to the given value. -
read
Reads what's given fromreadline()
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.- Specified by:
read
in classReader
- Throws:
IOException
-
close
Nullifies all buffers and writes history file if one was given at construction time.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
main
- Throws:
Exception
-