public interface LineReader
LineReader
implementations are not thread safe,
thus you should not attempt to use a single reader in several threads.
Any attempt to call one of the readLine
call while one is
already executing in a different thread will immediately result in an
IllegalStateException
being thrown. Other calls may lead to
unknown behaviors. There is one exception though: users are allowed to call
LineReader.printAbove(String)
or LineReader.printAbove(AttributedString)
at
any time to allow text to be printed above the current prompt.
All of these are specified with prompt templates,
which are similar to printf
format strings,
using the character '%'
to indicate special functionality.
%N
getLineNumber()
and a counter starting with 1 for the first continuation line.
%M
EOFError.getMissing()
method, if provided.
Defaults to an empty string.
%
nP
c%P
c%%
'%'
.
%{
%}
%{
...%}
pair is printed as
part of a prompt, but not interpreted by JLine
(except that '%'
-escapes are processed). The text is assumed
to take zero columns (not move the cursor). If it changes the style,
you're responsible for changing it back. Standard ANSI escape sequences
do not need to be within a %{
...%}
pair
(though can be) since JLine knows how to deal with them. However,
these delimiters are needed for unusual non-standard escape sequences.
Modifier and Type | Interface and Description |
---|---|
static class |
LineReader.Option |
static class |
LineReader.RegionType |
static class |
LineReader.SuggestionType |
Modifier and Type | Method and Description |
---|---|
void |
addCommandsInBuffer(Collection<String> commands) |
void |
callWidget(String name) |
Map<String,org.graalvm.shadowed.org.jline.keymap.KeyMap<Binding>> |
defaultKeyMaps() |
void |
editAndAddInBuffer(File file) |
String |
getAppName() |
LineReader.SuggestionType |
getAutosuggestion() |
Buffer |
getBuffer() |
Map<String,Widget> |
getBuiltinWidgets() |
Expander |
getExpander() |
Highlighter |
getHighlighter() |
History |
getHistory() |
String |
getKeyMap() |
Map<String,org.graalvm.shadowed.org.jline.keymap.KeyMap<Binding>> |
getKeyMaps() |
org.graalvm.shadowed.org.jline.keymap.KeyMap<Binding> |
getKeys() |
String |
getLastBinding() |
ParsedLine |
getParsedLine() |
Parser |
getParser() |
LineReader.RegionType |
getRegionActive() |
int |
getRegionMark() |
String |
getSearchTerm() |
String |
getTailTip() |
org.graalvm.shadowed.org.jline.terminal.Terminal |
getTerminal() |
Object |
getVariable(String name) |
Map<String,Object> |
getVariables() |
Map<String,Widget> |
getWidgets() |
boolean |
isReading()
Check if a thread is currently in a
readLine() call. |
boolean |
isSet(LineReader.Option option) |
LineReader |
option(LineReader.Option option,
boolean value) |
void |
printAbove(AttributedString str)
Prints a string before the prompt and redraw everything.
|
void |
printAbove(String str)
Prints a line above the prompt and redraw everything.
|
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)
Read the next line with the specified prompt.
|
String |
readLine(String prompt,
Character mask)
Read a line from the in
InputStream , and return the line
(without any trailing newlines). |
String |
readLine(String prompt,
Character mask,
String buffer)
Read a line from the in
InputStream , and return the line
(without any trailing newlines). |
String |
readLine(String prompt,
String rightPrompt,
Character mask,
String buffer)
Read a line from the in
InputStream , and return the line
(without any trailing newlines). |
String |
readLine(String prompt,
String rightPrompt,
MaskingCallback maskingCallback,
String buffer)
Read a line from the in
InputStream , and return the line
(without any trailing newlines). |
org.graalvm.shadowed.org.jline.terminal.MouseEvent |
readMouseEvent()
Read a mouse event when the
InfoCmp.Capability.key_mouse sequence
has just been read on the input stream. |
void |
runMacro(String macro)
Push back a key sequence that will be later consumed by the line reader.
|
void |
setAutosuggestion(LineReader.SuggestionType type) |
boolean |
setKeyMap(String name) |
void |
setOpt(LineReader.Option option) |
void |
setTailTip(String tailTip) |
void |
setVariable(String name,
Object value) |
void |
unsetOpt(LineReader.Option option) |
LineReader |
variable(String name,
Object value) |
static final String PROP_SUPPORT_PARSEDLINE
CompletingParsedLine
objects.static final String CALLBACK_INIT
static final String CALLBACK_FINISH
static final String CALLBACK_KEYMAP
static final String ACCEPT_AND_INFER_NEXT_HISTORY
static final String ACCEPT_AND_HOLD
static final String ACCEPT_LINE
static final String ACCEPT_LINE_AND_DOWN_HISTORY
static final String ARGUMENT_BASE
static final String BACKWARD_CHAR
static final String BACKWARD_DELETE_CHAR
static final String BACKWARD_DELETE_WORD
static final String BACKWARD_KILL_LINE
static final String BACKWARD_KILL_WORD
static final String BACKWARD_WORD
static final String BEEP
static final String BEGINNING_OF_BUFFER_OR_HISTORY
static final String BEGINNING_OF_HISTORY
static final String BEGINNING_OF_LINE
static final String BEGINNING_OF_LINE_HIST
static final String CAPITALIZE_WORD
static final String CHARACTER_SEARCH
static final String CHARACTER_SEARCH_BACKWARD
static final String CLEAR
static final String CLEAR_SCREEN
static final String COMPLETE_PREFIX
static final String COMPLETE_WORD
static final String COPY_PREV_WORD
static final String COPY_REGION_AS_KILL
static final String DELETE_CHAR
static final String DELETE_CHAR_OR_LIST
static final String DELETE_WORD
static final String DIGIT_ARGUMENT
static final String DO_LOWERCASE_VERSION
static final String DOWN_CASE_WORD
static final String DOWN_HISTORY
static final String DOWN_LINE
static final String DOWN_LINE_OR_HISTORY
static final String DOWN_LINE_OR_SEARCH
static final String EDIT_AND_EXECUTE_COMMAND
static final String EMACS_BACKWARD_WORD
static final String EMACS_EDITING_MODE
static final String EMACS_FORWARD_WORD
static final String END_OF_BUFFER_OR_HISTORY
static final String END_OF_HISTORY
static final String END_OF_LINE
static final String END_OF_LINE_HIST
static final String EXCHANGE_POINT_AND_MARK
static final String EXECUTE_NAMED_CMD
static final String EXPAND_HISTORY
static final String EXPAND_OR_COMPLETE
static final String EXPAND_OR_COMPLETE_PREFIX
static final String EXPAND_WORD
static final String FRESH_LINE
static final String FORWARD_CHAR
static final String FORWARD_WORD
static final String HISTORY_BEGINNING_SEARCH_BACKWARD
static final String HISTORY_BEGINNING_SEARCH_FORWARD
static final String HISTORY_INCREMENTAL_PATTERN_SEARCH_BACKWARD
static final String HISTORY_INCREMENTAL_PATTERN_SEARCH_FORWARD
static final String HISTORY_INCREMENTAL_SEARCH_BACKWARD
static final String HISTORY_INCREMENTAL_SEARCH_FORWARD
static final String HISTORY_SEARCH_BACKWARD
static final String HISTORY_SEARCH_FORWARD
static final String INSERT_CLOSE_CURLY
static final String INSERT_CLOSE_PAREN
static final String INSERT_CLOSE_SQUARE
static final String INFER_NEXT_HISTORY
static final String INSERT_COMMENT
static final String INSERT_LAST_WORD
static final String KILL_BUFFER
static final String KILL_LINE
static final String KILL_REGION
static final String KILL_WHOLE_LINE
static final String KILL_WORD
static final String LIST_CHOICES
static final String LIST_EXPAND
static final String MAGIC_SPACE
static final String MENU_EXPAND_OR_COMPLETE
static final String MENU_COMPLETE
static final String MENU_SELECT
static final String NEG_ARGUMENT
static final String OVERWRITE_MODE
static final String PUT_REPLACE_SELECTION
static final String QUOTED_INSERT
static final String READ_COMMAND
static final String RECURSIVE_EDIT
static final String REDISPLAY
static final String REDRAW_LINE
static final String REDO
static final String REVERSE_MENU_COMPLETE
static final String SELF_INSERT
static final String SELF_INSERT_UNMETA
static final String SEND_BREAK
static final String SET_LOCAL_HISTORY
static final String SET_MARK_COMMAND
static final String SPELL_WORD
static final String SPLIT_UNDO
static final String TRANSPOSE_CHARS
static final String TRANSPOSE_WORDS
static final String UNDEFINED_KEY
static final String UNDO
static final String UNIVERSAL_ARGUMENT
static final String UP_CASE_WORD
static final String UP_HISTORY
static final String UP_LINE
static final String UP_LINE_OR_HISTORY
static final String UP_LINE_OR_SEARCH
static final String VI_ADD_EOL
static final String VI_ADD_NEXT
static final String VI_BACKWARD_BLANK_WORD
static final String VI_BACKWARD_BLANK_WORD_END
static final String VI_BACKWARD_CHAR
static final String VI_BACKWARD_DELETE_CHAR
static final String VI_BACKWARD_KILL_WORD
static final String VI_BACKWARD_WORD
static final String VI_BACKWARD_WORD_END
static final String VI_BEGINNING_OF_LINE
static final String VI_CHANGE
static final String VI_CHANGE_EOL
static final String VI_CHANGE_WHOLE_LINE
static final String VI_CMD_MODE
static final String VI_DELETE
static final String VI_DELETE_CHAR
static final String VI_DIGIT_OR_BEGINNING_OF_LINE
static final String VI_DOWN_LINE_OR_HISTORY
static final String VI_END_OF_LINE
static final String VI_FETCH_HISTORY
static final String VI_FIND_NEXT_CHAR
static final String VI_FIND_NEXT_CHAR_SKIP
static final String VI_FIND_PREV_CHAR
static final String VI_FIND_PREV_CHAR_SKIP
static final String VI_FIRST_NON_BLANK
static final String VI_FORWARD_BLANK_WORD
static final String VI_FORWARD_BLANK_WORD_END
static final String VI_FORWARD_CHAR
static final String VI_FORWARD_WORD
static final String VI_FORWARD_WORD_END
static final String VI_GOTO_COLUMN
static final String VI_HISTORY_SEARCH_BACKWARD
static final String VI_HISTORY_SEARCH_FORWARD
static final String VI_INSERT
static final String VI_INSERT_BOL
static final String VI_INSERT_COMMENT
static final String VI_JOIN
static final String VI_KILL_EOL
static final String VI_KILL_LINE
static final String VI_MATCH_BRACKET
static final String VI_OPEN_LINE_ABOVE
static final String VI_OPEN_LINE_BELOW
static final String VI_OPER_SWAP_CASE
static final String VI_PUT_AFTER
static final String VI_PUT_BEFORE
static final String VI_QUOTED_INSERT
static final String VI_REPEAT_CHANGE
static final String VI_REPEAT_FIND
static final String VI_REPEAT_SEARCH
static final String VI_REPLACE
static final String VI_REPLACE_CHARS
static final String VI_REV_REPEAT_FIND
static final String VI_REV_REPEAT_SEARCH
static final String VI_SET_BUFFER
static final String VI_SUBSTITUTE
static final String VI_SWAP_CASE
static final String VI_UNDO_CHANGE
static final String VI_UP_LINE_OR_HISTORY
static final String VI_YANK
static final String VI_YANK_EOL
static final String VI_YANK_WHOLE_LINE
static final String VISUAL_LINE_MODE
static final String VISUAL_MODE
static final String WHAT_CURSOR_POSITION
static final String YANK
static final String YANK_POP
static final String MOUSE
static final String FOCUS_IN
static final String FOCUS_OUT
static final String BEGIN_PASTE
static final String VICMD
static final String VIINS
static final String VIOPP
static final String VISUAL
static final String MAIN
static final String EMACS
static final String SAFE
static final String MENU
static final String BIND_TTY_SPECIAL_CHARS
static final String COMMENT_BEGIN
static final String BELL_STYLE
static final String PREFER_VISIBLE_BELL
static final String LIST_MAX
static final String MENU_LIST_MAX
static final String DISABLE_HISTORY
static final String DISABLE_COMPLETION
static final String EDITING_MODE
static final String KEYMAP
static final String BLINK_MATCHING_PAREN
static final String WORDCHARS
static final String REMOVE_SUFFIX_CHARS
static final String SEARCH_TERMINATORS
static final String ERRORS
static final String OTHERS_GROUP_NAME
static final String ORIGINAL_GROUP_NAME
static final String COMPLETION_STYLE_GROUP
static final String COMPLETION_STYLE_LIST_GROUP
static final String COMPLETION_STYLE_SELECTION
static final String COMPLETION_STYLE_LIST_SELECTION
static final String COMPLETION_STYLE_DESCRIPTION
static final String COMPLETION_STYLE_LIST_DESCRIPTION
static final String COMPLETION_STYLE_STARTING
static final String COMPLETION_STYLE_LIST_STARTING
static final String COMPLETION_STYLE_BACKGROUND
static final String COMPLETION_STYLE_LIST_BACKGROUND
static final String SECONDARY_PROMPT_PATTERN
static final String LINE_OFFSET
static final String AMBIGUOUS_BINDING
static final String HISTORY_IGNORE
static final String HISTORY_FILE
static final String HISTORY_SIZE
static final String HISTORY_FILE_SIZE
static final String INDENTATION
static final String FEATURES_MAX_BUFFER_SIZE
static final String SUGGESTIONS_MIN_BUFFER_SIZE
String readLine() throws UserInterruptException, EndOfFileException
readLine(null, null, null)
.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsString readLine(Character mask) throws UserInterruptException, EndOfFileException
readLine(null, mask, null)
mask
- The mask character, null
or 0
.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsString readLine(String prompt) throws UserInterruptException, EndOfFileException
readLine(prompt, null, null)
prompt
- The prompt to issue to the terminal, may be null.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsString readLine(String prompt, Character mask) throws UserInterruptException, EndOfFileException
InputStream
, and return the line
(without any trailing newlines).
Equivalent to readLine(prompt, mask, null)
prompt
- The prompt to issue to the terminal, may be null.mask
- The mask character, null
or 0
.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsString readLine(String prompt, Character mask, String buffer) throws UserInterruptException, EndOfFileException
InputStream
, and return the line
(without any trailing newlines).
Equivalent to readLine(prompt, null, mask, buffer)
prompt
- The prompt to issue to the terminal, may be null.
This is a template, with optional '%'
escapes, as
described in the class header.mask
- The character mask, may be null.buffer
- The default value presented to the user to edit, may be null.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsString readLine(String prompt, String rightPrompt, Character mask, String buffer) throws UserInterruptException, EndOfFileException
InputStream
, and return the line
(without any trailing newlines).prompt
- The prompt to issue to the terminal, may be null.
This is a template, with optional '%'
escapes, as
described in the class header.rightPrompt
- The right prompt
This is a template, with optional '%'
escapes, as
described in the class header.mask
- The character mask, may be null.buffer
- The default value presented to the user to edit, may be null.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsString readLine(String prompt, String rightPrompt, MaskingCallback maskingCallback, String buffer) throws UserInterruptException, EndOfFileException
InputStream
, and return the line
(without any trailing newlines).prompt
- The prompt to issue to the terminal, may be null.
This is a template, with optional '%'
escapes, as
described in the class header.rightPrompt
- The right prompt
This is a template, with optional '%'
escapes, as
described in the class header.maskingCallback
- The MaskingCallback
to use when displaying lines and adding them to the line History
buffer
- The default value presented to the user to edit, may be null.UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)IOError
- in case of other i/o errorsvoid printAbove(String str)
str
- the string to printLineReader.printAbove(AttributedString)
void printAbove(AttributedString str)
str
- the string to printLineReader.printAbove(String)
boolean isReading()
readLine()
call.true
if there is an ongoing readLine()
call.LineReader variable(String name, Object value)
LineReader option(LineReader.Option option, boolean value)
void callWidget(String name)
boolean isSet(LineReader.Option option)
void setOpt(LineReader.Option option)
void unsetOpt(LineReader.Option option)
org.graalvm.shadowed.org.jline.terminal.Terminal getTerminal()
Buffer getBuffer()
String getAppName()
void runMacro(String macro)
Terminal.getCursorPosition(IntConsumer)
.macro
- the key sequence to push backTerminal.getCursorPosition(IntConsumer)
,
LineReader.readMouseEvent()
org.graalvm.shadowed.org.jline.terminal.MouseEvent readMouseEvent()
InfoCmp.Capability.key_mouse
sequence
has just been read on the input stream.
Compared to Terminal.readMouseEvent()
, this method takes into account keys
that have been pushed back using LineReader.runMacro(String)
.LineReader.runMacro(String)
,
Terminal.getCursorPosition(IntConsumer)
History getHistory()
Parser getParser()
Highlighter getHighlighter()
Expander getExpander()
String getKeyMap()
boolean setKeyMap(String name)
org.graalvm.shadowed.org.jline.keymap.KeyMap<Binding> getKeys()
ParsedLine getParsedLine()
String getSearchTerm()
LineReader.RegionType getRegionActive()
int getRegionMark()
void addCommandsInBuffer(Collection<String> commands)
String getLastBinding()
String getTailTip()
void setTailTip(String tailTip)
void setAutosuggestion(LineReader.SuggestionType type)
LineReader.SuggestionType getAutosuggestion()