jline
public class ConsoleReader extends Object implements ConsoleOperations
Field Summary | |
---|---|
static String | CR |
static SortedMap | KEYMAP_NAMES
Map that contains the operation name to keymay operation mapping. |
Constructor Summary | |
---|---|
ConsoleReader()
Create a new reader using FileDescriptor#in for input and
System#out for output. FileDescriptor#in is used because
it has a better chance of being unbuffered. | |
ConsoleReader(InputStream in, Writer out)
Create a new reader using the specified InputStream for input and
the specific writer for output, using the default keybindings resource. | |
ConsoleReader(InputStream in, Writer out, InputStream bindings) | |
ConsoleReader(InputStream in, Writer out, InputStream bindings, Terminal term)
Create a new reader.
|
Method Summary | |
---|---|
boolean | addCompletor(Completor completor)
Add the specified Completor to the list of handlers for
tab-completion.
|
void | addTriggeredAction(char c, ActionListener listener)
Adding a triggered Action allows to give another curse of action
if a character passed the preprocessing.
|
boolean | backspace()
Issue a backspace.
|
void | beep()
Issue an audible keyboard bell, if ConsoleReader return true. |
boolean | clearScreen()
Clear the screen by issuing the ANSI "clear screen" code. |
static void | debug(String str)
debug.
|
boolean | delete()
Issue a delete.
|
void | drawLine()
Output put the prompt + the current buffer |
void | flushConsole()
Flush the console output stream. |
int | getAutoprintThreshhold() |
boolean | getBellEnabled() |
CompletionHandler | getCompletionHandler() |
Collection | getCompletors()
Returns an unmodifiable list of all the completors. |
CursorBuffer | getCursorBuffer() |
String | getDefaultPrompt()
The default prompt that will be issued. |
Character | getEchoCharacter()
Returns the echo character. |
History | getHistory() |
InputStream | getInput()
Returns the stream used for console input. |
int | getTermheight()
Query the terminal to find the current width;
|
Terminal | getTerminal()
Loads the key bindings. |
int | getTermwidth()
Query the terminal to find the current width;
|
boolean | getUseHistory()
Whether or not to add new commands to the history buffer. |
boolean | getUsePagination()
Whether to use pagination when the number of rows of candidates exceeds
the height of the temrinal. |
boolean | killLine()
Kill the buffer ahead of the current cursor position.
|
int | moveCursor(int num)
Move the cursor where characters.
|
boolean | paste()
Paste the contents of the clipboard into the console buffer
|
void | printColumns(Collection stuff)
Output the specified Collection in proper columns.
|
void | printNewline()
Output a platform-dependant newline. |
void | printString(String str)
Output the specified string to the output stream (but not the buffer). |
void | putString(String str)
Write out the specified string to the buffer and the output stream. |
int | readCharacter(char[] allowed) |
String | readLine()
Read the next line and return the contents of the buffer. |
String | readLine(Character mask)
Read the next line with the specified character mask. |
String | readLine(String prompt) |
String | readLine(String prompt, Character mask)
Read a line from the in InputStream, and return the line
(without any trailing newlines).
|
int | readVirtualKey()
Read a character from the console.
|
void | redrawLine()
Clear the line and redraw it. |
boolean | removeCompletor(Completor completor)
Remove the specified Completor from the list of handlers for
tab-completion.
|
boolean | replace(int num, String replacement) |
void | setAutoprintThreshhold(int autoprintThreshhold) |
void | setBellEnabled(boolean bellEnabled) |
void | setCompletionHandler(CompletionHandler completionHandler) |
boolean | setCursorPosition(int position)
Move the cursor position to the specified absolute index. |
void | setDebug(PrintWriter debugger)
Set the stream for debugging. |
void | setDefaultPrompt(String prompt)
The default prompt that will be issued. |
void | setEchoCharacter(Character echoCharacter) Set the echo character. |
void | setHistory(History history) |
void | setInput(InputStream in)
Set the stream to be used for console input. |
void | setUseHistory(boolean useHistory)
Whether or not to add new commands to the history buffer. |
void | setUsePagination(boolean usePagination)
Whether to use pagination when the number of rows of candidates exceeds
the height of the temrinal. |
Parameters: in the input out the output bindings the key bindings to use term the terminal to use
Parameters: completor the Completor to add
Returns: true if it was successfully added
Parameters: c listener
Returns: true if successful
Parameters: str the message to issue.
Returns: true if successful
Returns: the number of candidates to print without issing a warning.
Returns: true is audible keyboard bell is enabled.
Returns: the height of the current terminal.
See Also: Terminal
Returns: the width of the current terminal.
See Also: Terminal
Returns: true if successful
Parameters: where if less than 0, move abs(where) to the left, otherwise move where to the right.
Returns: the number of spaces we moved
Returns: true if clipboard contents pasted
Parameters: stuff the stuff to print
Parameters: prompt the prompt to issue to the console, may be null.
Returns: a line that is read from the terminal, or null if there was null input (e.g., CTRL-D was pressed).
Returns: the character, or -1 if an EOF is received.
Parameters: completor the Completor to remove
Returns: true if it was successfully removed
Parameters: autoprintThreshhold the number of candidates to print without issuing a warning.
Parameters: bellEnabled if true, enable audible keyboard bells if an alert is required.
Set the echo character. For example, to have "*" entered when a password is typed:
myConsoleReader.setEchoCharacter(new Character('*'));
Setting the character to
nullwill restore normal character echoing. Setting the character to
new Character(0)will cause nothing to be echoed.
Parameters: echoCharacter the character to echo to the console in place of the typed character.