APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.org.jline.reader.impl

public Class LineReaderImpl

extends Object
implements LineReader, Flushable
Class Inheritance
All Implemented Interfaces
java.io.Flushable, jdk.internal.org.jline.reader.LineReader
Annotations
@SuppressWarnings:StatementWithEmptyBody
Imports
java.io.BufferedReader, .File, .FileWriter, .Flushable, .IOError, .IOException, .InputStream, .InterruptedIOException, java.lang.reflect.Constructor, java.nio.file.Files, .Path, .Paths, java.time.Instant, java.util.*, java.util.concurrent.atomic.AtomicBoolean, java.util.concurrent.locks.ReentrantLock, java.util.function.*, java.util.regex.Matcher, .Pattern, java.util.stream.Collectors, .Stream, .StreamSupport, jdk.internal.org.jline.keymap.BindingReader, .KeyMap, jdk.internal.org.jline.reader.*, .Parser.ParseContext, jdk.internal.org.jline.reader.impl.history.DefaultHistory, jdk.internal.org.jline.terminal.*, .Attributes.ControlChar, .Terminal.Signal, .Terminal.SignalHandler, jdk.internal.org.jline.terminal.impl.AbstractWindowsTerminal, jdk.internal.org.jline.utils.AttributedString, .AttributedStringBuilder, .AttributedStyle, .Curses, .Display, .InfoCmp.Capability, .Log, .Status, .StyleResolver, .WCWidth

A reader for terminal applications. It supports custom tab-completion, saveable command history, and command line editing.
Authors
Marc Prud'hommeaux, Jason Dillon, Guillaume Nodet

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
private static class
protected static enum
pack-priv static class
protected static class
protected static enum
LineReaderImpl.State

Possible states in which the current readline operation may be in.

private static class
protected static enum

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected final String
appName

The application name

protected LineReader.SuggestionType
protected final BindingReader
public static final String
public static final String
public static final String
public static final String
protected final Buffer
protected Map<String, Widget>
protected int
protected List<String>
protected Completer
protected CompletionMatcher
protected int
public static final long
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final String
public static final String
public static final String
public static final String
public static final String
public static final int
public static final String
public static final int
public static final String
private static final String
private static final String
protected Display
protected boolean
protected Expander
protected int
findChar

VI character find

protected int
protected int
public static final String
public static final String
private boolean
private boolean
protected Highlighter
protected History
protected Buffer
protected boolean
protected boolean
protected String
protected final Map<String, KeyMap<Binding>>
keyMaps

The terminal keys mapping

protected KillRing
protected final ReentrantLock
lock

State lock

private static final int
private static final int
protected MaskingCallback
private static final int
protected Map<Integer, String>
protected int
protected boolean
protected int
public static final char
protected final Map<LineReader.Option, Boolean>
protected boolean
protected ParsedLine
protected Parser
protected Supplier<AttributedString>
protected AttributedString
protected boolean
protected LineReader.RegionType
protected int
regionMark

Region state

protected int
protected AttributedString
protected boolean
protected CharSequence
private int
searchDir

VI history string search

protected boolean
protected int
private String
protected StringBuffer
protected final Size
protected boolean
protected int
protected final AtomicBoolean
protected LineReaderImpl.State
public static final int
protected String
protected final Terminal
terminal

The terminal to use

protected UndoTree<Buffer>
protected int
protected final Map<String, Object>
protected LineReaderImpl.ViMoveMode
protected Map<String, Widget>
protected String
yankBuffer

The vi yank buffer

Constructor Summary

AccessConstructor and Description
public
public
LineReaderImpl(Terminal terminal, String appName)

public
LineReaderImpl(Terminal terminal, String appName, Map<String, Object> variables)

Method Summary

Modifier and TypeMethod and Description
protected boolean
protected boolean
protected boolean
protected boolean
private void
addBuiltinWidget(Map<String, Widget> widgets, String name, Widget widget)

public void
private AttributedString
protected boolean
protected boolean
protected boolean
protected boolean
public boolean
protected boolean
protected boolean
public boolean

Returns:

true
beep
()

Issue an audible keyboard bell.

protected boolean
protected boolean
protected boolean
protected boolean
public boolean
private void
bind(KeyMap<Binding> map, String widget, Iterable<? extends CharSequence> keySeqs)

private void
bind(KeyMap<Binding> map, String widget, CharSequence... keySeqs)

private void
bind(KeyMap<Binding> map, Widget widget, CharSequence... keySeqs)

private void
private void
bindConsoleChars(KeyMap<Binding> keyMap, Attributes attr)

Bind special chars defined by the terminal instead of the default bindings

private void
protected AttributedStyle
protected Map<String, Widget>
private boolean
callNeg(Widget widget)

public void
private int
protected boolean
protected void
public boolean

Returns:

true
clear
()

Clean the used display

protected boolean
public boolean

Returns:

true
clearScreen
()

Clear the screen by issuing the ANSI "clear screen" code.

protected boolean
protected boolean
protected LineReaderImpl.PostResult
computePost(List<Candidate> possible, Candidate selection, List<Candidate> ordered, String completed)

protected LineReaderImpl.PostResult
computePost(List<Candidate> possible, Candidate selection, List<Candidate> ordered, String completed, Function<String, Integer> wcwidth, int width, boolean autoGroup, boolean groupName, boolean rowsFirst)

private void
protected boolean
public boolean
protected boolean
public Map<String, KeyMap<Binding>>
protected boolean
protected boolean
protected boolean
protected boolean
private int
private int
protected void
doCleanup(boolean nl)

protected boolean
doComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix)

protected boolean
doComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix, boolean forSuggestion)

private boolean
doCopyKillRegion(boolean kill)

private void
private String
protected boolean
doInsertComment(boolean isViMode)

protected boolean
doList(List<Candidate> possible, String completed, boolean runLoop, BiFunction<CharSequence, Boolean, CharSequence> escaper)

protected boolean
doList(List<Candidate> possible, String completed, boolean runLoop, BiFunction<CharSequence, Boolean, CharSequence> escaper, boolean forSuggestion)

protected boolean
protected boolean
protected <T> T
doReadBinding(KeyMap<T> keys, KeyMap<T> local)

protected String
protected boolean
doSearchHistory(boolean backward)

protected boolean

Returns:

true if it succeeded, false otherwise
doViDeleteOrChange
(int
The start position
startPos
,
int
The end position.
endPos
,
boolean
If true, then the delete is part of a change operationg (e.g. "c$" is change-to-end-of line, so we first must delete to end of line to start the change
isChange
)

Performs the vi "delete-to" action, deleting characters between a given span of the input line.

protected boolean

Returns:

true if it worked, false if the cursor was not on a bracket character or if there was no matching bracket.
doViMatchBracket
()

Implements vi style bracket matching ("%" command).

protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
public KeyMap<Binding>
dumb()

public void
protected boolean
public KeyMap<Binding>
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
private AttributedString
expandPromptPattern(String pattern, int padToWidth, String message, int line)

protected boolean
private int
private int
protected String
protected String

Returns:

the former contents of the buffer.
finishBuffer
()

Clear the buffer and add its contents to the history.

public void
flush()

Implements java.io.Flushable.flush.

Flush the terminal output stream.

public boolean
public boolean
protected boolean
protected boolean
protected boolean
private AttributedString
public String
public LineReader.SuggestionType
pack-priv boolean
getBoolean(String name, boolean def)

protected int

Returns:

1 is square, 2 curly, 3 parent, or zero for none. The value will be negated if it is the closing form of the bracket.
getBracketType
(int
The character to check
ch
)

Given a character determines what type of bracket it is (paren, square, curly, or none).

public Buffer
public Map<String, Widget>
protected Comparator<Candidate>
getCandidateComparator(boolean caseInsensitive, String word)

public Completer

Returns:

the completer
getCompleter
()

Returns the completer.

protected AttributedStyle
protected AttributedStyle
getCompletionStyleBackground(boolean menuList)

protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
getCompletionStyleGroup(boolean menuList)

protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
protected AttributedStyle
getCompletionStyleSelection(boolean menuList)

protected AttributedStyle
protected AttributedStyle
getCompletionStyleStarting(boolean menuList)

protected AttributedStyle
public AttributedString

Returns:

the displayed string including the buffer, left prompts and the help below
getDisplayedBufferWithPrompts
(List<AttributedString>
a list to store the secondary prompts
secondaryPrompts
)

Compute the full string to be displayed with the left, right and secondary prompts

public Expander
private CharSequence
protected Comparator<String>
private AttributedString
public Highlighter
public History
pack-priv int
getInt(String name, int def)

public String

Returns:

the name of the key mapping. This will be the canonical name of the current mode of the key map and may not reflect the name that was used with setKeyMap(String).
getKeyMap
()

Implements jdk.internal.org.jline.reader.LineReader.getKeyMap.

Returns the name of the current key mapping.

public Map<String, KeyMap<Binding>>
public KeyMap<Binding>
public String
pack-priv long
getLong(String name, long def)

protected String
protected String
public ParsedLine
public Parser
public LineReader.RegionType
public int
public String
pack-priv String
getString(String name, String def)

protected int
public String
public Terminal
public Object
public Map<String, Object>
private boolean
protected Widget
getWidget(Object binding)

public Map<String, Widget>
protected synchronized void
protected boolean
protected boolean
protected boolean
protected boolean
pack-priv void
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
private AttributedString
private AttributedString
insertSecondaryPrompts(AttributedString strAtt, List<AttributedString> prompts, boolean computePrompts)

protected boolean
protected boolean
isAlpha(int c)

protected boolean

Returns:

True if it is a delimiter
isDelimiter
(int
The character to test
c
)

Checks to see if the specified character is a delimiter.

protected boolean
protected boolean
protected boolean
isInViMoveOperation()

Returns: true if line reader is in the middle of doing a change-to delete-to or yank-to.

public boolean
public boolean
isReading()

Implements jdk.internal.org.jline.reader.LineReader.isReading.

Check if a thread is currently in a readLine() call.

public boolean
private boolean
protected boolean
isViAlphaNum(int c)

protected boolean

Returns:

true if the character is a whitespace
isWhitespace
(int
The character to check
c
)

Checks to see if a character is a whitespace character.

protected boolean
isWord(int c)

private String
key(InfoCmp.Capability capability)

protected boolean
public boolean

Returns:

true if successful
killLine
()

Kill the buffer ahead of the current cursor position.

public boolean
protected boolean
protected boolean
protected boolean
private boolean
listChoices(boolean forSuggestion)

private List<LineReaderImpl.Pair<Integer, Integer>>
matches(Pattern p, String line, int index)

private String
private void
public boolean
protected boolean

Returns:

true if the move was successful
moveHistory
(final boolean
If true, move forward
next
,
int
The number of entries to move
count
)

Used in "vi" mode for argumented history move, to move a specific number of history entries forward or back.

protected boolean

Returns:

true if successful, false otherwise
moveHistory
(final boolean
true to go to the next, false for the previous.
next
)

Move up or down the history tree.

private Widget
namedWidget(String name, Widget widget)

protected boolean
protected boolean
public LineReader
protected boolean
public int
peekCharacter(long timeout)

public void
printAbove(String str)

Implements jdk.internal.org.jline.reader.LineReader.printAbove.

Prints a line above the prompt and redraw everything.

public void
printAbove(AttributedString str)

Implements jdk.internal.org.jline.reader.LineReader.printAbove.

Prints a string before the prompt and redraw everything.

pack-priv void
pack-priv void
println()

Output a platform-dependant newline.

private int
private void
private void
pushBackBinding(boolean skip)

public void
putString(final CharSequence
the char sequence to write in the buffer
str
)

Write out the specified string to the buffer and the output stream.

protected boolean
quit()

protected boolean
public Binding

Returns:

the decoded binding or null if the end of stream has been reached
readBinding
(KeyMap<Binding>
the KeyMap to use for decoding the input stream
keys
)

Read from the input stream and decode an operation from the key map.

public Binding
public int

Returns:

the character, or -1 if an EOF is received.
readCharacter
()

Read a character from the terminal.

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
()

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read the next line and return the contents of the buffer.

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
(Character
The mask character, null or 0.
mask
)

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read the next line with the specified character mask.

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
(String
The prompt to issue to the terminal, may be null.
prompt
)

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read a line from the in InputStream, and return the line (without any trailing newlines).

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
(String
The prompt to issue to the terminal, may be null.
prompt
,
Character
The mask character, null or 0.
mask
)

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read a line from the in InputStream, and return the line (without any trailing newlines).

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
(String
The prompt to issue to the terminal, may be null.
prompt
,
Character
The mask character, null or 0.
mask
,
String
A string that will be set for editing.
buffer
)

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read a line from the in InputStream, and return the line (without any trailing newlines).

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
(String
The prompt to issue to the terminal, may be null.
prompt
,
String
The prompt to issue to the right of the terminal, may be null.
rightPrompt
,
Character
The mask character, null or 0.
mask
,
String
A string that will be set for editing.
buffer
)

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read a line from the in InputStream, and return the line (without any trailing newlines).

public String

Returns:

A line that is read from the terminal, can never be null.
readLine
(String
The prompt to issue to the terminal, may be null.
prompt
,
String
The prompt to issue to the right of the terminal, may be null.
rightPrompt
,
MaskingCallback
The callback used to mask parts of the edited line.
maskingCallback
,
String
A string that will be set for editing.
buffer
)

Implements jdk.internal.org.jline.reader.LineReader.readLine.

Read a line from the in InputStream, and return the line (without any trailing newlines).

public MouseEvent
readMouseEvent()

Implements jdk.internal.org.jline.reader.LineReader.readMouseEvent.

Read a mouse event when the org.jline.utils.InfoCmp.Capability#key_mouse sequence has just been read on the input stream.

private void
rebind(KeyMap<Binding> keyMap, String operation, String prevBinding, char newBinding)

public boolean
protected void
redisplay(boolean flush)

protected boolean
redo()

public boolean

Returns:

true
redrawLine
()

Clear the line and redraw it.

private void
public void
runMacro(String macro)

Implements jdk.internal.org.jline.reader.LineReader.runMacro.

Push back a key sequence that will be later consumed by the line reader.

public KeyMap<Binding>
safe()

public int

Returns:

index where this substring has been found, or -1 else.
searchBackwards
(String
substring to search for.
searchTerm
,
int
the index from which on to search
startIndex
)

Search backward in history from a given position.

public int

Returns:

index where the substring has been found, or -1 else.
searchBackwards
(String
substring to search for.
searchTerm
)

Search backwards in history from the current position.

public int
searchBackwards(String searchTerm, int startIndex, boolean startsWith)

public int
searchForwards(String searchTerm, int startIndex, boolean startsWith)

public int

Returns:

index where this substring has been found, or -1 else.
searchForwards
(String
substring to search for.
searchTerm
,
int
the index from which on to search
startIndex
)

Search forward in history from a given position.

public int

Returns:

index where the substring has been found, or -1 else.
searchForwards
(String
substring to search for.
searchTerm
)

Search forwards in history from the current position.

protected boolean
protected boolean
protected boolean
public void
protected void
setBuffer(Buffer buffer)

protected void
setBuffer(final String
the new contents of the buffer.
buffer
)

Set the current buffer's content to the specified String.

public void
setCompleter(Completer
the completer to use
completer
)

Set the completer.

public void
public void
public void
public void
setHistory(final History history)

public boolean

Returns:

true if the keymap was set, or false if the keymap is not recognized.
setKeyMap
(String
The name of the keymap to switch to
name
)

Implements jdk.internal.org.jline.reader.LineReader.setKeyMap.

Sets the current keymap by name.

protected boolean
public void
public void
setParser(Parser parser)

public void
setPrompt(final String prompt)

public void
setRightPrompt(final String rightPrompt)

public void
public void
protected int
switchCase(int ch)

protected LineReaderImpl.PostResult
toColumns(List<Object> items, Candidate selection, String completed, Function<String, Integer> wcwidth, int width, boolean rowsFirst)

protected void
toColumns(Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, String completed, boolean rowsFirst, boolean doMenuList, int[] out)

protected boolean

Returns:

true
transposeChars
()

Performs character transpose.

protected boolean
protected boolean
protected boolean
undo()

protected boolean
public void
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
public LineReader
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean

Returns:

true if it succeeded, false otherwise
viBackwardDeleteChar
()

Deletes the previous character from the cursor position

protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
viChange(int startPos, int endPos)

protected boolean
protected boolean
public KeyMap<Binding>
protected boolean
protected boolean
protected String

Returns:

The remaped operation
viDeleteChangeYankToRemap
(String
The incoming operation to remap
op
)

This method is calling while doing a delete-to ("d"), change-to ("c"), or yank-to ("y") and it filters out only those movement operations that are allowable during those operations.

protected boolean

Returns:

true if it succeeded, false otherwise
viDeleteChar
()

Deletes the character you are sitting on and sucks the rest of the line in from the right.

protected boolean
viDeleteTo(int startPos, int endPos)

protected boolean
protected boolean
protected boolean
private boolean
vifindchar(boolean repeat)

protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
private int
protected boolean
protected boolean

Returns:

true if the search was successful
viHistorySearchForward
()

Implements vi search ("/" or "?").

protected boolean
protected boolean
protected boolean
public KeyMap<Binding>
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
public KeyMap<Binding>
protected boolean

Returns:

true
viPutAfter
()

Pasts the yank buffer to the right of the current cursor position and moves the cursor to the end of the pasted region.

protected boolean
protected boolean
protected boolean
protected boolean

Returns:

true if it succeeded, false otherwise
viReplaceChars
()

Implements the vi change character command (in move-mode "r" followed by the character to change to).

protected boolean
protected boolean
private int
public KeyMap<Binding>
protected boolean
protected boolean
protected boolean

Returns:

true if it succeeded, false otherwise
viSwapCase
()

Switches the case of the current character from upper to lower or lower to upper as necessary and advances the cursor one position to the right.

protected boolean
protected boolean
protected boolean

Returns:

true if the yank succeeded
viYankTo
(int
The starting position from which to yank
startPos
,
int
The ending position to which to yank
endPos
)

Implement the "vi" yank-to operation.

protected boolean
protected boolean
protected static CompletingParsedLine
public boolean
yank()

public boolean
public void
zeroOut()

Implements jdk.internal.org.jline.reader.LineReader.zeroOut.

Clear any internal buffers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait