java.lang.Object | |
↳ | jline.console.ConsoleReader |
A reader for console applications. It supports custom tab-completion,
saveable command history, and command line editing. On some platforms,
platform-specific commands will need to be issued before the reader will
function properly. See init()
for convenience
methods for issuing platform-specific setup commands.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
char | BACKSPACE | ||||||||||
String | DEFAULT_INPUT_RC | ||||||||||
String | INPUT_RC | ||||||||||
String | JLINE_COMPLETION_THRESHOLD | ||||||||||
String | JLINE_ESC_TIMEOUT | ||||||||||
String | JLINE_INPUTRC | ||||||||||
String | JLINE_NOBELL | ||||||||||
char | KEYBOARD_BELL | ||||||||||
char | NULL_MASK | ||||||||||
char | RESET_LINE | ||||||||||
int | TAB_WIDTH |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CR |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
The equivalent of hitting <RET>.
| |||||||||||
Add the specified
Completer to the list of handlers for tab-completion. | |||||||||||
Adding a triggered Action allows to give another curse of action if a character passed the pre-processing.
| |||||||||||
Issue a backspace.
| |||||||||||
Issue an audible keyboard bell.
| |||||||||||
Clear the screen by issuing the ANSI "clear screen" code.
| |||||||||||
Issue a delete.
| |||||||||||
Output put the prompt + the current buffer
| |||||||||||
Flush the console output stream.
| |||||||||||
Get whether the console bell is enabled
| |||||||||||
Returns an unmodifiable list of all the completers.
| |||||||||||
Returns the echo character.
| |||||||||||
Get whether user interrupt handling is enabled
| |||||||||||
Returns the name of the current key mapping.
| |||||||||||
Whether or not to add new commands to the history buffer.
| |||||||||||
Whether to use pagination when the number of rows of candidates exceeds the height of the terminal.
| |||||||||||
Kill the buffer ahead of the current cursor position.
| |||||||||||
Move the cursor where characters.
| |||||||||||
Paste the contents of the clipboard into the console buffer
| |||||||||||
Output the specified string to the output stream (but not the buffer).
| |||||||||||
Output the specified
Collection in proper columns. | |||||||||||
Output a platform-dependant newline.
| |||||||||||
Write out the specified string to the buffer and the output stream.
| |||||||||||
Read a character from the console.
| |||||||||||
Read a line from the in
InputStream , and return the line
(without any trailing newlines). | |||||||||||
Read the next line with the specified character mask.
| |||||||||||
Read the next line and return the contents of the buffer.
| |||||||||||
Clear the line and redraw it.
| |||||||||||
Remove the specified
Completer from the list of handlers for tab-completion. | |||||||||||
Erases the current line with the existing prompt, then redraws the line
with the provided prompt and buffer
| |||||||||||
Search backward in history from a given position.
| |||||||||||
Search backwards in history from the current position.
| |||||||||||
Search forwards in history from the current position.
| |||||||||||
Search forward in history from a given position.
| |||||||||||
Set whether the console bell is enabled.
| |||||||||||
Sets the string that will be used to start a comment when the
insert-comment key is struck.
| |||||||||||
Enables or disables copy and paste detection.
| |||||||||||
Move the cursor position to the specified absolute index.
| |||||||||||
Set the echo character.
| |||||||||||
Set whether user interrupts (ctrl-C) are handled by having JLine
throw
UserInterruptException from readLine() . | |||||||||||
Whether or not to add new commands to the history buffer.
| |||||||||||
Sets the current keymap by name.
| |||||||||||
Whether to use pagination when the number of rows of candidates exceeds the height of the terminal.
| |||||||||||
Shuts the console reader down.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Move the visual cursor backwards without modifying the buffer cursor.
| |||||||||||
Use the completers to modify the buffer with the appropriate completions.
| |||||||||||
Expand event designator such as !!, !#, !3, etc...
| |||||||||||
Shuts down the ConsoleReader if the JVM attempts to clean it up.
| |||||||||||
Erase the current line.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
IOException |
---|
IOException |
---|
The equivalent of hitting <RET>. The line is considered complete and is returned.
IOException |
---|
Adding a triggered Action allows to give another curse of action if a character passed the pre-processing.
Say you want to close the application if the user enter q. addTriggerAction('q', new ActionListener(){ System.exit(0); }); would do the trick.Clear the screen by issuing the ANSI "clear screen" code.
IOException |
---|
Flush the console output stream. This is important for printout out single characters (like a backspace or keyboard) that we want the console to handle immediately.
IOException |
---|
Get whether the console bell is enabled
Get whether user interrupt handling is enabled
Returns the name of the current key mapping.
setKeyMap(String)
.
Whether or not to add new commands to the history buffer.
Whether to use pagination when the number of rows of candidates exceeds the height of the terminal.
Move the cursor where characters.
num | If less than 0, move abs(where) to the left, otherwise move where to the right. |
---|
IOException |
---|
Paste the contents of the clipboard into the console buffer
IOException |
---|
Output the specified string to the output stream (but not the buffer).
IOException |
---|
Output the specified Collection
in proper columns.
IOException |
---|
Write out the specified string to the buffer and the output stream.
IOException |
---|
Read a character from the console.
IOException |
---|
Read a line from the in InputStream
, and return the line
(without any trailing newlines).
prompt | The prompt to issue to the console, may be null. |
---|
IOException |
---|
Read the next line with the specified character mask. If null, then characters will be echoed. If 0, then no characters will be echoed.
IOException |
---|
Read the next line and return the contents of the buffer.
IOException |
---|
Erases the current line with the existing prompt, then redraws the line with the provided prompt and buffer
prompt | the new prompt |
---|---|
buffer | the buffer to be drawn |
cursorDest | where you want the cursor set when the line has been drawn. -1 for end of line. |
IOException |
---|
Search backward in history from a given position.
searchTerm | substring to search for. |
---|---|
startIndex | the index from which on to search |
Search backwards in history from the current position.
searchTerm | substring to search for. |
---|
Search forwards in history from the current position.
searchTerm | substring to search for. |
---|
Search forward in history from a given position.
searchTerm | substring to search for. |
---|---|
startIndex | the index from which on to search |
threshold | the number of candidates to print without issuing a warning. |
---|
Set whether the console bell is enabled.
enabled | true if enabled; false otherwise |
---|
Sets the string that will be used to start a comment when the insert-comment key is struck.
commentBegin | The begin comment string. |
---|
Enables or disables copy and paste detection. The effect of enabling this this setting is that when a tab is received immediately followed by another character, the tab will not be treated as a completion, but as a tab literal.
onoff | true if detection is enabled |
---|
Move the cursor position to the specified absolute index.
IOException |
---|
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.
c | the character to echo to the console in place of the typed character. |
---|
Set whether user interrupts (ctrl-C) are handled by having JLine
throw UserInterruptException
from readLine()
.
Otherwise, the JVM will handle SIGINT
as normal, which
usually causes it to exit. The default is false
.
Whether or not to add new commands to the history buffer.
Sets the current keymap by name. Supported keymaps are "emacs", "vi-insert", "vi-move".
name | The name of the keymap to switch to |
---|
Whether to use pagination when the number of rows of candidates exceeds the height of the terminal.
Shuts the console reader down. This method should be called when you have completed using the reader as it shuts down and cleans up resources that would otherwise be "leaked".
Move the visual cursor backwards without modifying the buffer cursor.
IOException |
---|
Use the completers to modify the buffer with the appropriate completions.
IOException |
---|
Expand event designator such as !!, !#, !3, etc... See http://www.gnu.org/software/bash/manual/html_node/Event-Designators.html
IOException |
---|
Shuts down the ConsoleReader if the JVM attempts to clean it up.
Throwable |
---|