Package org.jline.reader.impl
Class LineReaderImpl
- java.lang.Object
-
- org.jline.reader.impl.LineReaderImpl
-
- All Implemented Interfaces:
java.io.Flushable
,LineReader
public class LineReaderImpl extends java.lang.Object implements LineReader, java.io.Flushable
A reader for terminal applications. It supports custom tab-completion, saveable command history, and command line editing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
LineReaderImpl.BellType
private static class
LineReaderImpl.CompletingWord
protected static class
LineReaderImpl.CompletionType
private class
LineReaderImpl.MenuSupport
(package private) static class
LineReaderImpl.Pair<U,V>
protected static class
LineReaderImpl.PostResult
protected static class
LineReaderImpl.State
Possible states in which the current readline operation may be in.private static class
LineReaderImpl.TerminalLine
protected static class
LineReaderImpl.ViMoveMode
-
Nested classes/interfaces inherited from interface org.jline.reader.LineReader
LineReader.Option, LineReader.RegionType, LineReader.SuggestionType
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
appName
The application nameprotected LineReader.SuggestionType
autosuggestion
protected BindingReader
bindingReader
static java.lang.String
BRACKETED_PASTE_BEGIN
static java.lang.String
BRACKETED_PASTE_END
static java.lang.String
BRACKETED_PASTE_OFF
static java.lang.String
BRACKETED_PASTE_ON
protected Buffer
buf
protected java.util.Map<java.lang.String,Widget>
builtinWidgets
(package private) int
candidateStartPosition
protected java.util.List<java.lang.String>
commandsBuffer
protected Completer
completer
protected CompletionMatcher
completionMatcher
protected int
count
static long
DEFAULT_AMBIGUOUS_BINDING
static java.lang.String
DEFAULT_BELL_STYLE
static long
DEFAULT_BLINK_MATCHING_PAREN
static java.lang.String
DEFAULT_COMMENT_BEGIN
static java.lang.String
DEFAULT_COMPLETION_STYLE_BACKGROUND
static java.lang.String
DEFAULT_COMPLETION_STYLE_DESCRIPTION
static java.lang.String
DEFAULT_COMPLETION_STYLE_GROUP
static java.lang.String
DEFAULT_COMPLETION_STYLE_LIST_BACKGROUND
static java.lang.String
DEFAULT_COMPLETION_STYLE_LIST_DESCRIPTION
static java.lang.String
DEFAULT_COMPLETION_STYLE_LIST_GROUP
static java.lang.String
DEFAULT_COMPLETION_STYLE_LIST_SELECTION
static java.lang.String
DEFAULT_COMPLETION_STYLE_LIST_STARTING
static java.lang.String
DEFAULT_COMPLETION_STYLE_SELECTION
static java.lang.String
DEFAULT_COMPLETION_STYLE_STARTING
static int
DEFAULT_ERRORS
static int
DEFAULT_FEATURES_MAX_BUFFER_SIZE
static int
DEFAULT_INDENTATION
static int
DEFAULT_LIST_MAX
static int
DEFAULT_MENU_LIST_MAX
static java.lang.String
DEFAULT_ORIGINAL_GROUP_NAME
static java.lang.String
DEFAULT_OTHERS_GROUP_NAME
static java.lang.String
DEFAULT_REMOVE_SUFFIX_CHARS
static java.lang.String
DEFAULT_SEARCH_TERMINATORS
static java.lang.String
DEFAULT_SECONDARY_PROMPT_PATTERN
static int
DEFAULT_SUGGESTIONS_MIN_BUFFER_SIZE
static java.lang.String
DEFAULT_WORDCHARS
private static java.lang.String
DESC_PREFIX
private static java.lang.String
DESC_SUFFIX
protected Display
display
protected boolean
doAutosuggestion
protected Expander
expander
protected int
findChar
VI character findprotected int
findDir
protected int
findTailAdd
static java.lang.String
FOCUS_IN_SEQ
static java.lang.String
FOCUS_OUT_SEQ
private boolean
forceChar
private boolean
forceLine
protected Highlighter
highlighter
protected History
history
protected Buffer
historyBuffer
protected boolean
isArgDigit
protected boolean
isUndo
protected java.lang.String
keyMap
protected java.util.Map<java.lang.String,KeyMap<Binding>>
keyMaps
The terminal keys mappingprotected KillRing
killRing
protected java.util.concurrent.locks.ReentrantLock
lock
State lockprivate static int
MARGIN_BETWEEN_COLUMNS
private static int
MARGIN_BETWEEN_DISPLAY_AND_DESC
protected MaskingCallback
maskingCallback
private static int
MENU_LIST_WIDTH
private static int
MIN_ROWS
protected java.util.Map<java.lang.Integer,java.lang.String>
modifiedHistory
protected int
mult
protected boolean
nextCommandFromHistory
protected int
nextHistoryId
static char
NULL_MASK
protected java.util.Map<LineReader.Option,java.lang.Boolean>
options
protected boolean
overTyping
protected ParsedLine
parsedLine
protected Parser
parser
protected java.util.function.Supplier<AttributedString>
post
protected AttributedString
prompt
protected boolean
reading
protected LineReader.RegionType
regionActive
protected int
regionMark
Region stateprotected int
repeatCount
protected AttributedString
rightPrompt
protected boolean
searchBackward
protected java.lang.CharSequence
searchBuffer
private int
searchDir
VI history string searchprotected boolean
searchFailing
protected int
searchIndex
private java.lang.String
searchString
protected java.lang.StringBuffer
searchTerm
protected Size
size
protected boolean
skipRedisplay
protected int
smallTerminalOffset
protected java.util.concurrent.atomic.AtomicBoolean
startedReading
protected LineReaderImpl.State
state
static int
TAB_WIDTH
protected java.lang.String
tailTip
protected Terminal
terminal
The terminal to useprotected UndoTree<Buffer>
undo
protected int
universal
protected java.util.Map<java.lang.String,java.lang.Object>
variables
protected LineReaderImpl.ViMoveMode
viMoveMode
protected java.util.Map<java.lang.String,Widget>
widgets
protected java.lang.String
yankBuffer
The vi yank buffer-
Fields inherited from interface org.jline.reader.LineReader
ACCEPT_AND_HOLD, ACCEPT_AND_INFER_NEXT_HISTORY, ACCEPT_LINE, ACCEPT_LINE_AND_DOWN_HISTORY, AMBIGUOUS_BINDING, ARGUMENT_BASE, BACKWARD_CHAR, BACKWARD_DELETE_CHAR, BACKWARD_DELETE_WORD, BACKWARD_KILL_LINE, BACKWARD_KILL_WORD, BACKWARD_WORD, BEEP, BEGIN_PASTE, BEGINNING_OF_BUFFER_OR_HISTORY, BEGINNING_OF_HISTORY, BEGINNING_OF_LINE, BEGINNING_OF_LINE_HIST, BELL_STYLE, BIND_TTY_SPECIAL_CHARS, BLINK_MATCHING_PAREN, CALLBACK_FINISH, CALLBACK_INIT, CALLBACK_KEYMAP, CAPITALIZE_WORD, CHARACTER_SEARCH, CHARACTER_SEARCH_BACKWARD, CLEAR, CLEAR_SCREEN, COMMENT_BEGIN, COMPLETE_PREFIX, COMPLETE_WORD, COMPLETION_STYLE_BACKGROUND, COMPLETION_STYLE_DESCRIPTION, COMPLETION_STYLE_GROUP, COMPLETION_STYLE_LIST_BACKGROUND, COMPLETION_STYLE_LIST_DESCRIPTION, COMPLETION_STYLE_LIST_GROUP, COMPLETION_STYLE_LIST_SELECTION, COMPLETION_STYLE_LIST_STARTING, COMPLETION_STYLE_SELECTION, COMPLETION_STYLE_STARTING, COPY_PREV_WORD, COPY_REGION_AS_KILL, DELETE_CHAR, DELETE_CHAR_OR_LIST, DELETE_WORD, DIGIT_ARGUMENT, DISABLE_COMPLETION, DISABLE_HISTORY, DO_LOWERCASE_VERSION, DOWN_CASE_WORD, DOWN_HISTORY, DOWN_LINE, DOWN_LINE_OR_HISTORY, DOWN_LINE_OR_SEARCH, EDIT_AND_EXECUTE_COMMAND, EDITING_MODE, EMACS, EMACS_BACKWARD_WORD, EMACS_EDITING_MODE, EMACS_FORWARD_WORD, END_OF_BUFFER_OR_HISTORY, END_OF_HISTORY, END_OF_LINE, END_OF_LINE_HIST, ERRORS, EXCHANGE_POINT_AND_MARK, EXECUTE_NAMED_CMD, EXPAND_HISTORY, EXPAND_OR_COMPLETE, EXPAND_OR_COMPLETE_PREFIX, EXPAND_WORD, FEATURES_MAX_BUFFER_SIZE, FOCUS_IN, FOCUS_OUT, FORWARD_CHAR, FORWARD_WORD, FRESH_LINE, HISTORY_BEGINNING_SEARCH_BACKWARD, HISTORY_BEGINNING_SEARCH_FORWARD, HISTORY_FILE, HISTORY_FILE_SIZE, HISTORY_IGNORE, HISTORY_INCREMENTAL_PATTERN_SEARCH_BACKWARD, HISTORY_INCREMENTAL_PATTERN_SEARCH_FORWARD, HISTORY_INCREMENTAL_SEARCH_BACKWARD, HISTORY_INCREMENTAL_SEARCH_FORWARD, HISTORY_SEARCH_BACKWARD, HISTORY_SEARCH_FORWARD, HISTORY_SIZE, INDENTATION, INFER_NEXT_HISTORY, INSERT_CLOSE_CURLY, INSERT_CLOSE_PAREN, INSERT_CLOSE_SQUARE, INSERT_COMMENT, INSERT_LAST_WORD, KEYMAP, KILL_BUFFER, KILL_LINE, KILL_REGION, KILL_WHOLE_LINE, KILL_WORD, LINE_OFFSET, LIST_CHOICES, LIST_EXPAND, LIST_MAX, MAGIC_SPACE, MAIN, MENU, MENU_COMPLETE, MENU_EXPAND_OR_COMPLETE, MENU_LIST_MAX, MENU_SELECT, MOUSE, NEG_ARGUMENT, ORIGINAL_GROUP_NAME, OTHERS_GROUP_NAME, OVERWRITE_MODE, PREFER_VISIBLE_BELL, PROP_SUPPORT_PARSEDLINE, PUT_REPLACE_SELECTION, QUOTED_INSERT, READ_COMMAND, RECURSIVE_EDIT, REDISPLAY, REDO, REDRAW_LINE, REMOVE_SUFFIX_CHARS, REVERSE_MENU_COMPLETE, SAFE, SEARCH_TERMINATORS, SECONDARY_PROMPT_PATTERN, SELF_INSERT, SELF_INSERT_UNMETA, SEND_BREAK, SET_LOCAL_HISTORY, SET_MARK_COMMAND, SPELL_WORD, SPLIT_UNDO, SUGGESTIONS_MIN_BUFFER_SIZE, TRANSPOSE_CHARS, TRANSPOSE_WORDS, UNDEFINED_KEY, UNDO, UNIVERSAL_ARGUMENT, UP_CASE_WORD, UP_HISTORY, UP_LINE, UP_LINE_OR_HISTORY, UP_LINE_OR_SEARCH, VI_ADD_EOL, VI_ADD_NEXT, VI_BACKWARD_BLANK_WORD, VI_BACKWARD_BLANK_WORD_END, VI_BACKWARD_CHAR, VI_BACKWARD_DELETE_CHAR, VI_BACKWARD_KILL_WORD, VI_BACKWARD_WORD, VI_BACKWARD_WORD_END, VI_BEGINNING_OF_LINE, VI_CHANGE, VI_CHANGE_EOL, VI_CHANGE_WHOLE_LINE, VI_CMD_MODE, VI_DELETE, VI_DELETE_CHAR, VI_DIGIT_OR_BEGINNING_OF_LINE, VI_DOWN_LINE_OR_HISTORY, VI_END_OF_LINE, VI_FETCH_HISTORY, VI_FIND_NEXT_CHAR, VI_FIND_NEXT_CHAR_SKIP, VI_FIND_PREV_CHAR, VI_FIND_PREV_CHAR_SKIP, VI_FIRST_NON_BLANK, VI_FORWARD_BLANK_WORD, VI_FORWARD_BLANK_WORD_END, VI_FORWARD_CHAR, VI_FORWARD_WORD, VI_FORWARD_WORD_END, VI_GOTO_COLUMN, VI_HISTORY_SEARCH_BACKWARD, VI_HISTORY_SEARCH_FORWARD, VI_INSERT, VI_INSERT_BOL, VI_INSERT_COMMENT, VI_JOIN, VI_KILL_EOL, VI_KILL_LINE, VI_MATCH_BRACKET, VI_OPEN_LINE_ABOVE, VI_OPEN_LINE_BELOW, VI_OPER_SWAP_CASE, VI_PUT_AFTER, VI_PUT_BEFORE, VI_QUOTED_INSERT, VI_REPEAT_CHANGE, VI_REPEAT_FIND, VI_REPEAT_SEARCH, VI_REPLACE, VI_REPLACE_CHARS, VI_REV_REPEAT_FIND, VI_REV_REPEAT_SEARCH, VI_SET_BUFFER, VI_SUBSTITUTE, VI_SWAP_CASE, VI_UNDO_CHANGE, VI_UP_LINE_OR_HISTORY, VI_YANK, VI_YANK_EOL, VI_YANK_WHOLE_LINE, VICMD, VIINS, VIOPP, VISUAL, VISUAL_LINE_MODE, VISUAL_MODE, WHAT_CURSOR_POSITION, WORDCHARS, YANK, YANK_POP
-
-
Constructor Summary
Constructors Constructor Description LineReaderImpl(Terminal terminal)
LineReaderImpl(Terminal terminal, java.lang.String appName)
LineReaderImpl(Terminal terminal, java.lang.String appName, java.util.Map<java.lang.String,java.lang.Object> variables)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
acceptAndHold()
protected boolean
acceptAndInferNextHistory()
protected boolean
acceptLine()
protected boolean
acceptLineAndDownHistory()
private void
addBuiltinWidget(java.util.Map<java.lang.String,Widget> widgets, java.lang.String name, Widget widget)
void
addCommandsInBuffer(java.util.Collection<java.lang.String> commands)
private AttributedString
addRightPrompt(AttributedString prompt, AttributedString line)
protected boolean
argumentBase()
protected boolean
backwardChar()
protected boolean
backwardDeleteChar()
protected boolean
backwardDeleteWord()
boolean
backwardKillLine()
protected boolean
backwardKillWord()
protected boolean
backwardWord()
boolean
beep()
Issue an audible keyboard bell.protected boolean
beginningOfBufferOrHistory()
protected boolean
beginningOfHistory()
protected boolean
beginningOfLine()
protected boolean
beginningOfLineHist()
boolean
beginPaste()
private void
bind(KeyMap<Binding> map, java.lang.String widget, java.lang.CharSequence... keySeqs)
private void
bind(KeyMap<Binding> map, java.lang.String widget, java.lang.Iterable<? extends java.lang.CharSequence> keySeqs)
private void
bind(KeyMap<Binding> map, Widget widget, java.lang.CharSequence... keySeqs)
private void
bindArrowKeys(KeyMap<Binding> map)
private void
bindConsoleChars(KeyMap<Binding> keyMap, Attributes attr)
Bind special chars defined by the terminal instead of the default bindingsprivate void
bindKeys(KeyMap<Binding> emacs)
protected AttributedStyle
buildStyle(java.lang.String str)
protected java.util.Map<java.lang.String,Widget>
builtinWidgets()
private boolean
callNeg(Widget widget)
void
callWidget(java.lang.String name)
private int
candidateStartPosition(java.util.List<Candidate> cands)
protected boolean
capitalizeWord()
protected void
cleanup()
boolean
clear()
Clean the used displayprotected boolean
clearChoices()
boolean
clearScreen()
Clear the screen by issuing the ANSI "clear screen" code.protected boolean
completePrefix()
protected boolean
completeWord()
protected LineReaderImpl.PostResult
computePost(java.util.List<Candidate> possible, Candidate selection, java.util.List<Candidate> ordered, java.lang.String completed)
protected LineReaderImpl.PostResult
computePost(java.util.List<Candidate> possible, Candidate selection, java.util.List<Candidate> ordered, java.lang.String completed, java.util.function.Function<java.lang.String,java.lang.Integer> wcwidth, int width, boolean autoGroup, boolean groupName, boolean rowsFirst)
private void
concat(java.util.List<AttributedString> lines, AttributedStringBuilder sb)
protected boolean
copyPrevWord()
boolean
copyRegionAsKill()
protected boolean
deactivateRegion()
java.util.Map<java.lang.String,KeyMap<Binding>>
defaultKeyMaps()
protected boolean
deleteChar()
protected boolean
deleteCharOrList()
protected boolean
deleteWord()
protected boolean
digitArgument()
private int
displayRows()
private int
displayRows(Status status)
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
doDisplay()
private java.lang.String
doGetSearchPattern()
protected boolean
doInsertComment(boolean isViMode)
protected boolean
doList(java.util.List<Candidate> possible, java.lang.String completed, boolean runLoop, java.util.function.BiFunction<java.lang.CharSequence,java.lang.Boolean,java.lang.CharSequence> escaper)
protected boolean
doList(java.util.List<Candidate> possible, java.lang.String completed, boolean runLoop, java.util.function.BiFunction<java.lang.CharSequence,java.lang.Boolean,java.lang.CharSequence> escaper, boolean forSuggestion)
protected boolean
doLowercaseVersion()
protected boolean
doMenu(java.util.List<Candidate> original, java.lang.String completed, java.util.function.BiFunction<java.lang.CharSequence,java.lang.Boolean,java.lang.CharSequence> escaper)
protected <T> T
doReadBinding(KeyMap<T> keys, KeyMap<T> local)
protected java.lang.String
doReadStringUntil(java.lang.String sequence)
protected boolean
doSearchHistory(boolean backward)
protected boolean
doViDeleteOrChange(int startPos, int endPos, boolean isChange)
Performs the vi "delete-to" action, deleting characters between a given span of the input line.protected boolean
doViMatchBracket()
Implements vi style bracket matching ("%" command).protected boolean
downCaseWord()
protected boolean
downHistory()
protected boolean
downLine()
protected boolean
downLineOrHistory()
protected boolean
downLineOrSearch()
void
editAndAddInBuffer(java.io.File file)
protected boolean
editAndExecute()
KeyMap<Binding>
emacs()
protected boolean
emacsBackwardWord()
protected boolean
emacsEditingMode()
protected boolean
emacsForwardWord()
protected boolean
endOfBufferOrHistory()
protected boolean
endOfHistory()
protected boolean
endOfLine()
protected boolean
endOfLineHist()
protected boolean
exchangePointAndMark()
protected boolean
expandHistory()
protected boolean
expandOrComplete()
protected boolean
expandOrCompletePrefix()
private AttributedString
expandPromptPattern(java.lang.String pattern, int padToWidth, java.lang.String message, int line)
protected boolean
expandWord()
private int
findbol()
private int
findeol()
protected java.lang.String
finish(java.lang.String str)
protected java.lang.String
finishBuffer()
Clear the buffer and add its contents to the history.void
flush()
Flush the terminal output stream.boolean
focusIn()
boolean
focusOut()
protected boolean
forwardChar()
protected boolean
forwardWord()
protected boolean
freshLine()
java.lang.String
getAppName()
LineReader.SuggestionType
getAutosuggestion()
(package private) boolean
getBoolean(java.lang.String name, boolean def)
protected int
getBracketType(int ch)
Given a character determines what type of bracket it is (paren, square, curly, or none).Buffer
getBuffer()
java.util.Map<java.lang.String,Widget>
getBuiltinWidgets()
protected java.util.Comparator<Candidate>
getCandidateComparator(boolean caseInsensitive, java.lang.String word)
Completer
getCompleter()
Returns the completer.protected AttributedStyle
getCompletionStyle(java.lang.String name, java.lang.String value)
protected AttributedStyle
getCompletionStyleBackground()
protected AttributedStyle
getCompletionStyleBackground(boolean menuList)
protected AttributedStyle
getCompletionStyleDescription()
protected AttributedStyle
getCompletionStyleDescription(boolean menuList)
protected AttributedStyle
getCompletionStyleGroup()
protected AttributedStyle
getCompletionStyleGroup(boolean menuList)
protected AttributedStyle
getCompletionStyleListBackground()
protected AttributedStyle
getCompletionStyleListDescription()
protected AttributedStyle
getCompletionStyleListGroup()
protected AttributedStyle
getCompletionStyleListSelection()
protected AttributedStyle
getCompletionStyleListStarting()
protected AttributedStyle
getCompletionStyleSelection()
protected AttributedStyle
getCompletionStyleSelection(boolean menuList)
protected AttributedStyle
getCompletionStyleStarting()
protected AttributedStyle
getCompletionStyleStarting(boolean menuList)
AttributedString
getDisplayedBufferWithPrompts(java.util.List<AttributedString> secondaryPrompts)
Compute the full string to be displayed with the left, right and secondary promptsExpander
getExpander()
private java.lang.CharSequence
getFirstWord()
protected java.util.Comparator<java.lang.String>
getGroupComparator()
private AttributedString
getHighlightedBuffer(java.lang.String buffer)
Highlighter
getHighlighter()
History
getHistory()
(package private) int
getInt(java.lang.String name, int def)
java.lang.String
getKeyMap()
Returns the name of the current key mapping.java.util.Map<java.lang.String,KeyMap<Binding>>
getKeyMaps()
KeyMap<Binding>
getKeys()
java.lang.String
getLastBinding()
(package private) long
getLong(java.lang.String name, long def)
protected java.lang.String
getOriginalGroupName()
protected java.lang.String
getOthersGroupName()
ParsedLine
getParsedLine()
Parser
getParser()
LineReader.RegionType
getRegionActive()
int
getRegionMark()
java.lang.String
getSearchTerm()
(package private) java.lang.String
getString(java.lang.String name, java.lang.String def)
java.lang.String
getTailTip()
Terminal
getTerminal()
java.lang.Object
getVariable(java.lang.String name)
java.util.Map<java.lang.String,java.lang.Object>
getVariables()
private boolean
getViSearchString()
protected Widget
getWidget(java.lang.Object binding)
java.util.Map<java.lang.String,Widget>
getWidgets()
protected void
handleSignal(Terminal.Signal signal)
protected boolean
historyIncrementalSearchBackward()
protected boolean
historyIncrementalSearchForward()
protected boolean
historySearchBackward()
protected boolean
historySearchForward()
(package private) void
indention(int nb, java.lang.StringBuilder sb)
protected boolean
insertClose(java.lang.String s)
protected boolean
insertCloseCurly()
protected boolean
insertCloseParen()
protected boolean
insertCloseSquare()
protected boolean
insertComment()
private AttributedString
insertSecondaryPrompts(AttributedString str, java.util.List<AttributedString> prompts)
private AttributedString
insertSecondaryPrompts(AttributedString strAtt, java.util.List<AttributedString> prompts, boolean computePrompts)
protected boolean
insertTab()
protected boolean
isAlpha(int c)
protected boolean
isDelimiter(int c)
Checks to see if the specified character is a delimiter.protected boolean
isInViChangeOperation()
protected boolean
isInViCmdMode()
protected boolean
isInViMoveOperation()
boolean
isKeyMap(java.lang.String name)
boolean
isReading()
Check if a thread is currently in areadLine()
call.boolean
isSet(LineReader.Option option)
private boolean
isTerminalDumb()
protected boolean
isViAlphaNum(int c)
protected boolean
isWhitespace(int c)
Checks to see if a character is a whitespace character.protected boolean
isWord(int c)
private java.lang.String
key(InfoCmp.Capability capability)
protected boolean
killBuffer()
boolean
killLine()
Kill the buffer ahead of the current cursor position.boolean
killRegion()
protected boolean
killWholeLine()
protected boolean
killWord()
protected boolean
listChoices()
private boolean
listChoices(boolean forSuggestion)
private java.util.List<LineReaderImpl.Pair<java.lang.Integer,java.lang.Integer>>
matches(java.util.regex.Pattern p, java.lang.String line, int index)
private java.lang.String
matchPreviousCommand(java.lang.String buffer)
KeyMap<Binding>
menu()
protected boolean
menuComplete()
protected boolean
menuExpandOrComplete()
private void
mergeCandidates(java.util.List<Candidate> possible)
boolean
mouse()
protected boolean
moveHistory(boolean next)
Move up or down the history tree.protected boolean
moveHistory(boolean next, int count)
Used in "vi" mode for argumented history move, to move a specific number of history entries forward or back.private Widget
namedWidget(java.lang.String name, Widget widget)
protected boolean
negArgument()
protected boolean
nextBindingIsComplete()
LineReader
option(LineReader.Option option, boolean value)
protected boolean
overwriteMode()
int
peekCharacter(long timeout)
(package private) void
print(java.lang.String str)
Raw output printing.void
printAbove(java.lang.String str)
Prints a line above the prompt and redraw everything.void
printAbove(AttributedString str)
Prints a string before the prompt and redraw everything.(package private) void
println()
Output a platform-dependant newline.(package private) void
println(java.lang.String s)
private int
promptLines()
private void
pushBackBinding()
private void
pushBackBinding(boolean skip)
void
putString(java.lang.CharSequence str)
Write out the specified string to the buffer and the output stream.protected boolean
quit()
protected boolean
quotedInsert()
Binding
readBinding(KeyMap<Binding> keys)
Read from the input stream and decode an operation from the key map.Binding
readBinding(KeyMap<Binding> keys, KeyMap<Binding> local)
int
readCharacter()
Read a character from the terminal.java.lang.String
readLine()
Read the next line and return the contents of the buffer.java.lang.String
readLine(java.lang.Character mask)
Read the next line with the specified character mask.java.lang.String
readLine(java.lang.String prompt)
Read a line from the inInputStream
, and return the line (without any trailing newlines).java.lang.String
readLine(java.lang.String prompt, java.lang.Character mask)
Read a line from the inInputStream
, and return the line (without any trailing newlines).java.lang.String
readLine(java.lang.String prompt, java.lang.Character mask, java.lang.String buffer)
Read a line from the inInputStream
, and return the line (without any trailing newlines).java.lang.String
readLine(java.lang.String prompt, java.lang.String rightPrompt, java.lang.Character mask, java.lang.String buffer)
Read a line from the inInputStream
, and return the line (without any trailing newlines).java.lang.String
readLine(java.lang.String prompt, java.lang.String rightPrompt, MaskingCallback maskingCallback, java.lang.String buffer)
Read a line from the inInputStream
, and return the line (without any trailing newlines).MouseEvent
readMouseEvent()
Read a mouse event when theInfoCmp.Capability.key_mouse
sequence has just been read on the input stream.private void
rebind(KeyMap<Binding> keyMap, java.lang.String operation, java.lang.String prevBinding, char newBinding)
boolean
redisplay()
protected void
redisplay(boolean flush)
protected boolean
redo()
boolean
redrawLine()
Clear the line and redraw it.private void
removeIndentation()
void
runMacro(java.lang.String macro)
Push back a key sequence that will be later consumed by the line reader.KeyMap<Binding>
safe()
int
searchBackwards(java.lang.String searchTerm)
Search backwards in history from the current position.int
searchBackwards(java.lang.String searchTerm, int startIndex)
Search backward in history from a given position.int
searchBackwards(java.lang.String searchTerm, int startIndex, boolean startsWith)
int
searchForwards(java.lang.String searchTerm)
Search forwards in history from the current position.int
searchForwards(java.lang.String searchTerm, int startIndex)
Search forward in history from a given position.int
searchForwards(java.lang.String searchTerm, int startIndex, boolean startsWith)
protected boolean
selfInsert()
protected boolean
selfInsertUnmeta()
protected boolean
sendBreak()
void
setAutosuggestion(LineReader.SuggestionType type)
protected void
setBuffer(java.lang.String buffer)
Set the current buffer's content to the specifiedString
.protected void
setBuffer(Buffer buffer)
void
setCompleter(Completer completer)
Set the completer.void
setCompletionMatcher(CompletionMatcher completionMatcher)
void
setExpander(Expander expander)
void
setHighlighter(Highlighter highlighter)
void
setHistory(History history)
boolean
setKeyMap(java.lang.String name)
Sets the current keymap by name.protected boolean
setMarkCommand()
void
setOpt(LineReader.Option option)
void
setParser(Parser parser)
void
setPrompt(java.lang.String prompt)
void
setRightPrompt(java.lang.String rightPrompt)
void
setTailTip(java.lang.String tailTip)
void
setVariable(java.lang.String name, java.lang.Object value)
protected int
switchCase(int ch)
protected void
toColumns(java.lang.Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, java.lang.String completed, boolean rowsFirst, boolean doMenuList, int[] out)
protected LineReaderImpl.PostResult
toColumns(java.util.List<java.lang.Object> items, Candidate selection, java.lang.String completed, java.util.function.Function<java.lang.String,java.lang.Integer> wcwidth, int width, boolean rowsFirst)
protected boolean
transposeChars()
Performs character transpose.protected boolean
transposeWords()
protected boolean
undefinedKey()
protected boolean
undo()
protected boolean
universalArgument()
void
unsetOpt(LineReader.Option option)
protected boolean
upCaseWord()
protected boolean
upHistory()
protected boolean
upLine()
protected boolean
upLineOrHistory()
protected boolean
upLineOrSearch()
LineReader
variable(java.lang.String name, java.lang.Object value)
protected boolean
viAddEol()
protected boolean
viAddNext()
protected boolean
viBackwardBlankWord()
protected boolean
viBackwardBlankWordEnd()
protected boolean
viBackwardChar()
protected boolean
viBackwardDeleteChar()
Deletes the previous character from the cursor positionprotected boolean
viBackwardKillWord()
protected boolean
viBackwardWord()
protected boolean
viBackwardWordEnd()
protected boolean
viBeginningOfLine()
protected boolean
viChange()
protected boolean
viChange(int startPos, int endPos)
protected boolean
viChangeEol()
protected boolean
viChangeWholeLine()
KeyMap<Binding>
viCmd()
protected boolean
viCmdMode()
protected boolean
viDelete()
protected java.lang.String
viDeleteChangeYankToRemap(java.lang.String 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
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
viDigitOrBeginningOfLine()
protected boolean
viDownLineOrHistory()
protected boolean
viEndOfLine()
private boolean
vifindchar(boolean repeat)
protected boolean
viFindNextChar()
protected boolean
viFindNextCharSkip()
protected boolean
viFindPrevChar()
protected boolean
viFindPrevCharSkip()
protected boolean
viFirstNonBlank()
protected boolean
viForwardBlankWord()
protected boolean
viForwardBlankWordEnd()
protected boolean
viForwardChar()
protected boolean
viForwardWord()
protected boolean
viForwardWordEnd()
private int
vigetkey()
protected boolean
viHistorySearchBackward()
protected boolean
viHistorySearchForward()
Implements vi search ("/" or "?").protected boolean
viInsert()
protected boolean
viInsertBol()
protected boolean
viInsertComment()
KeyMap<Binding>
viInsertion()
protected boolean
viJoin()
protected boolean
viKillEol()
protected boolean
viKillWholeLine()
protected boolean
viMatchBracket()
protected boolean
viOpenLineAbove()
protected boolean
viOpenLineBelow()
KeyMap<Binding>
viOpp()
protected boolean
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
viPutBefore()
protected boolean
viRepeatFind()
protected boolean
viRepeatSearch()
protected boolean
viReplaceChars()
Implements the vi change character command (in move-mode "r" followed by the character to change to).protected boolean
viRevRepeatFind()
protected boolean
viRevRepeatSearch()
KeyMap<Binding>
visual()
protected boolean
visualLineMode()
protected boolean
visualMode()
protected boolean
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
viUpLineOrHistory()
protected boolean
viYankTo()
protected boolean
viYankTo(int startPos, int endPos)
Implement the "vi" yank-to operation.protected boolean
viYankWholeLine()
protected boolean
whatCursorPosition()
protected static CompletingParsedLine
wrap(ParsedLine line)
boolean
yank()
boolean
yankPop()
-
-
-
Field Detail
-
NULL_MASK
public static final char NULL_MASK
- See Also:
- Constant Field Values
-
TAB_WIDTH
public static final int TAB_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_WORDCHARS
public static final java.lang.String DEFAULT_WORDCHARS
- See Also:
- Constant Field Values
-
DEFAULT_REMOVE_SUFFIX_CHARS
public static final java.lang.String DEFAULT_REMOVE_SUFFIX_CHARS
- See Also:
- Constant Field Values
-
DEFAULT_COMMENT_BEGIN
public static final java.lang.String DEFAULT_COMMENT_BEGIN
- See Also:
- Constant Field Values
-
DEFAULT_SEARCH_TERMINATORS
public static final java.lang.String DEFAULT_SEARCH_TERMINATORS
- See Also:
- Constant Field Values
-
DEFAULT_BELL_STYLE
public static final java.lang.String DEFAULT_BELL_STYLE
- See Also:
- Constant Field Values
-
DEFAULT_LIST_MAX
public static final int DEFAULT_LIST_MAX
- See Also:
- Constant Field Values
-
DEFAULT_MENU_LIST_MAX
public static final int DEFAULT_MENU_LIST_MAX
- See Also:
- Constant Field Values
-
DEFAULT_ERRORS
public static final int DEFAULT_ERRORS
- See Also:
- Constant Field Values
-
DEFAULT_BLINK_MATCHING_PAREN
public static final long DEFAULT_BLINK_MATCHING_PAREN
- See Also:
- Constant Field Values
-
DEFAULT_AMBIGUOUS_BINDING
public static final long DEFAULT_AMBIGUOUS_BINDING
- See Also:
- Constant Field Values
-
DEFAULT_SECONDARY_PROMPT_PATTERN
public static final java.lang.String DEFAULT_SECONDARY_PROMPT_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_OTHERS_GROUP_NAME
public static final java.lang.String DEFAULT_OTHERS_GROUP_NAME
- See Also:
- Constant Field Values
-
DEFAULT_ORIGINAL_GROUP_NAME
public static final java.lang.String DEFAULT_ORIGINAL_GROUP_NAME
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_STARTING
public static final java.lang.String DEFAULT_COMPLETION_STYLE_STARTING
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_DESCRIPTION
public static final java.lang.String DEFAULT_COMPLETION_STYLE_DESCRIPTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_GROUP
public static final java.lang.String DEFAULT_COMPLETION_STYLE_GROUP
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_SELECTION
public static final java.lang.String DEFAULT_COMPLETION_STYLE_SELECTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_BACKGROUND
public static final java.lang.String DEFAULT_COMPLETION_STYLE_BACKGROUND
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_STARTING
public static final java.lang.String DEFAULT_COMPLETION_STYLE_LIST_STARTING
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_DESCRIPTION
public static final java.lang.String DEFAULT_COMPLETION_STYLE_LIST_DESCRIPTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_GROUP
public static final java.lang.String DEFAULT_COMPLETION_STYLE_LIST_GROUP
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_SELECTION
public static final java.lang.String DEFAULT_COMPLETION_STYLE_LIST_SELECTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_BACKGROUND
public static final java.lang.String DEFAULT_COMPLETION_STYLE_LIST_BACKGROUND
- See Also:
- Constant Field Values
-
DEFAULT_INDENTATION
public static final int DEFAULT_INDENTATION
- See Also:
- Constant Field Values
-
DEFAULT_FEATURES_MAX_BUFFER_SIZE
public static final int DEFAULT_FEATURES_MAX_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_SUGGESTIONS_MIN_BUFFER_SIZE
public static final int DEFAULT_SUGGESTIONS_MIN_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MIN_ROWS
private static final int MIN_ROWS
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_ON
public static final java.lang.String BRACKETED_PASTE_ON
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_OFF
public static final java.lang.String BRACKETED_PASTE_OFF
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_BEGIN
public static final java.lang.String BRACKETED_PASTE_BEGIN
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_END
public static final java.lang.String BRACKETED_PASTE_END
- See Also:
- Constant Field Values
-
FOCUS_IN_SEQ
public static final java.lang.String FOCUS_IN_SEQ
- See Also:
- Constant Field Values
-
FOCUS_OUT_SEQ
public static final java.lang.String FOCUS_OUT_SEQ
- See Also:
- Constant Field Values
-
terminal
protected final Terminal terminal
The terminal to use
-
appName
protected final java.lang.String appName
The application name
-
keyMaps
protected final java.util.Map<java.lang.String,KeyMap<Binding>> keyMaps
The terminal keys mapping
-
variables
protected final java.util.Map<java.lang.String,java.lang.Object> variables
-
history
protected History history
-
completer
protected Completer completer
-
highlighter
protected Highlighter highlighter
-
parser
protected Parser parser
-
expander
protected Expander expander
-
completionMatcher
protected CompletionMatcher completionMatcher
-
options
protected final java.util.Map<LineReader.Option,java.lang.Boolean> options
-
buf
protected final Buffer buf
-
tailTip
protected java.lang.String tailTip
-
autosuggestion
protected LineReader.SuggestionType autosuggestion
-
size
protected final Size size
-
prompt
protected AttributedString prompt
-
rightPrompt
protected AttributedString rightPrompt
-
maskingCallback
protected MaskingCallback maskingCallback
-
modifiedHistory
protected java.util.Map<java.lang.Integer,java.lang.String> modifiedHistory
-
historyBuffer
protected Buffer historyBuffer
-
searchBuffer
protected java.lang.CharSequence searchBuffer
-
searchTerm
protected java.lang.StringBuffer searchTerm
-
searchFailing
protected boolean searchFailing
-
searchBackward
protected boolean searchBackward
-
searchIndex
protected int searchIndex
-
doAutosuggestion
protected boolean doAutosuggestion
-
bindingReader
protected final BindingReader bindingReader
-
findChar
protected int findChar
VI character find
-
findDir
protected int findDir
-
findTailAdd
protected int findTailAdd
-
searchDir
private int searchDir
VI history string search
-
searchString
private java.lang.String searchString
-
regionMark
protected int regionMark
Region state
-
regionActive
protected LineReader.RegionType regionActive
-
forceChar
private boolean forceChar
-
forceLine
private boolean forceLine
-
yankBuffer
protected java.lang.String yankBuffer
The vi yank buffer
-
viMoveMode
protected LineReaderImpl.ViMoveMode viMoveMode
-
killRing
protected KillRing killRing
-
isUndo
protected boolean isUndo
-
lock
protected final java.util.concurrent.locks.ReentrantLock lock
State lock
-
state
protected LineReaderImpl.State state
-
startedReading
protected final java.util.concurrent.atomic.AtomicBoolean startedReading
-
reading
protected boolean reading
-
post
protected java.util.function.Supplier<AttributedString> post
-
builtinWidgets
protected java.util.Map<java.lang.String,Widget> builtinWidgets
-
widgets
protected java.util.Map<java.lang.String,Widget> widgets
-
count
protected int count
-
mult
protected int mult
-
universal
protected int universal
-
repeatCount
protected int repeatCount
-
isArgDigit
protected boolean isArgDigit
-
parsedLine
protected ParsedLine parsedLine
-
skipRedisplay
protected boolean skipRedisplay
-
display
protected Display display
-
overTyping
protected boolean overTyping
-
keyMap
protected java.lang.String keyMap
-
smallTerminalOffset
protected int smallTerminalOffset
-
nextCommandFromHistory
protected boolean nextCommandFromHistory
-
nextHistoryId
protected int nextHistoryId
-
commandsBuffer
protected java.util.List<java.lang.String> commandsBuffer
-
candidateStartPosition
int candidateStartPosition
-
DESC_PREFIX
private static final java.lang.String DESC_PREFIX
- See Also:
- Constant Field Values
-
DESC_SUFFIX
private static final java.lang.String DESC_SUFFIX
- See Also:
- Constant Field Values
-
MARGIN_BETWEEN_DISPLAY_AND_DESC
private static final int MARGIN_BETWEEN_DISPLAY_AND_DESC
- See Also:
- Constant Field Values
-
MARGIN_BETWEEN_COLUMNS
private static final int MARGIN_BETWEEN_COLUMNS
- See Also:
- Constant Field Values
-
MENU_LIST_WIDTH
private static final int MENU_LIST_WIDTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LineReaderImpl
public LineReaderImpl(Terminal terminal) throws java.io.IOException
- Throws:
java.io.IOException
-
LineReaderImpl
public LineReaderImpl(Terminal terminal, java.lang.String appName) throws java.io.IOException
- Throws:
java.io.IOException
-
LineReaderImpl
public LineReaderImpl(Terminal terminal, java.lang.String appName, java.util.Map<java.lang.String,java.lang.Object> variables)
-
-
Method Detail
-
getTerminal
public Terminal getTerminal()
- Specified by:
getTerminal
in interfaceLineReader
-
getAppName
public java.lang.String getAppName()
- Specified by:
getAppName
in interfaceLineReader
-
getKeyMaps
public java.util.Map<java.lang.String,KeyMap<Binding>> getKeyMaps()
- Specified by:
getKeyMaps
in interfaceLineReader
-
getKeys
public KeyMap<Binding> getKeys()
- Specified by:
getKeys
in interfaceLineReader
-
getWidgets
public java.util.Map<java.lang.String,Widget> getWidgets()
- Specified by:
getWidgets
in interfaceLineReader
-
getBuiltinWidgets
public java.util.Map<java.lang.String,Widget> getBuiltinWidgets()
- Specified by:
getBuiltinWidgets
in interfaceLineReader
-
getBuffer
public Buffer getBuffer()
- Specified by:
getBuffer
in interfaceLineReader
-
setAutosuggestion
public void setAutosuggestion(LineReader.SuggestionType type)
- Specified by:
setAutosuggestion
in interfaceLineReader
-
getAutosuggestion
public LineReader.SuggestionType getAutosuggestion()
- Specified by:
getAutosuggestion
in interfaceLineReader
-
getTailTip
public java.lang.String getTailTip()
- Specified by:
getTailTip
in interfaceLineReader
-
setTailTip
public void setTailTip(java.lang.String tailTip)
- Specified by:
setTailTip
in interfaceLineReader
-
runMacro
public void runMacro(java.lang.String macro)
Description copied from interface:LineReader
Push back a key sequence that will be later consumed by the line reader. This method can be used after reading the cursor position usingTerminal.getCursorPosition(IntConsumer)
.- Specified by:
runMacro
in interfaceLineReader
- Parameters:
macro
- the key sequence to push back- See Also:
Terminal.getCursorPosition(IntConsumer)
,LineReader.readMouseEvent()
-
readMouseEvent
public MouseEvent readMouseEvent()
Description copied from interface:LineReader
Read a mouse event when theInfoCmp.Capability.key_mouse
sequence has just been read on the input stream. Compared toTerminal.readMouseEvent()
, this method takes into account keys that have been pushed back usingLineReader.runMacro(String)
.- Specified by:
readMouseEvent
in interfaceLineReader
- Returns:
- the mouse event
- See Also:
LineReader.runMacro(String)
,Terminal.getCursorPosition(IntConsumer)
-
setCompleter
public void setCompleter(Completer completer)
Set the completer.- Parameters:
completer
- the completer to use
-
getCompleter
public Completer getCompleter()
Returns the completer.- Returns:
- the completer
-
setHistory
public void setHistory(History history)
-
getHistory
public History getHistory()
- Specified by:
getHistory
in interfaceLineReader
-
setHighlighter
public void setHighlighter(Highlighter highlighter)
-
getHighlighter
public Highlighter getHighlighter()
- Specified by:
getHighlighter
in interfaceLineReader
-
getParser
public Parser getParser()
- Specified by:
getParser
in interfaceLineReader
-
setParser
public void setParser(Parser parser)
-
getExpander
public Expander getExpander()
- Specified by:
getExpander
in interfaceLineReader
-
setExpander
public void setExpander(Expander expander)
-
setCompletionMatcher
public void setCompletionMatcher(CompletionMatcher completionMatcher)
-
readLine
public java.lang.String readLine() throws UserInterruptException, EndOfFileException
Read the next line and return the contents of the buffer.- Specified by:
readLine
in interfaceLineReader
- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
readLine
public java.lang.String readLine(java.lang.Character mask) throws UserInterruptException, EndOfFileException
Read the next line with the specified character mask. If null, then characters will be echoed. If 0, then no characters will be echoed.- Specified by:
readLine
in interfaceLineReader
- Parameters:
mask
- The mask character,null
or0
.- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
readLine
public java.lang.String readLine(java.lang.String prompt) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream
, and return the line (without any trailing newlines).- Specified by:
readLine
in interfaceLineReader
- Parameters:
prompt
- The prompt to issue to the terminal, may be null.- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
readLine
public java.lang.String readLine(java.lang.String prompt, java.lang.Character mask) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream
, and return the line (without any trailing newlines).- Specified by:
readLine
in interfaceLineReader
- Parameters:
prompt
- The prompt to issue to the terminal, may be null.mask
- The mask character,null
or0
.- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
readLine
public java.lang.String readLine(java.lang.String prompt, java.lang.Character mask, java.lang.String buffer) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream
, and return the line (without any trailing newlines).- Specified by:
readLine
in interfaceLineReader
- Parameters:
prompt
- The prompt to issue to the terminal, may be null.mask
- The mask character,null
or0
.buffer
- A string that will be set for editing.- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
readLine
public java.lang.String readLine(java.lang.String prompt, java.lang.String rightPrompt, java.lang.Character mask, java.lang.String buffer) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream
, and return the line (without any trailing newlines).- Specified by:
readLine
in interfaceLineReader
- Parameters:
prompt
- The prompt to issue to the terminal, may be null.rightPrompt
- The prompt to issue to the right of the terminal, may be null.mask
- The mask character,null
or0
.buffer
- A string that will be set for editing.- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
readLine
public java.lang.String readLine(java.lang.String prompt, java.lang.String rightPrompt, MaskingCallback maskingCallback, java.lang.String buffer) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream
, and return the line (without any trailing newlines).- Specified by:
readLine
in interfaceLineReader
- Parameters:
prompt
- The prompt to issue to the terminal, may be null.rightPrompt
- The prompt to issue to the right of the terminal, may be null.maskingCallback
- The callback used to mask parts of the edited line.buffer
- A string that will be set for editing.- Returns:
- A line that is read from the terminal, can never be null.
- Throws:
UserInterruptException
- if readLine was interrupted (using Ctrl-C for example)EndOfFileException
- if an EOF has been found (using Ctrl-D for example)
-
isTerminalDumb
private boolean isTerminalDumb()
-
doDisplay
private void doDisplay()
-
printAbove
public void printAbove(java.lang.String str)
Description copied from interface:LineReader
Prints a line above the prompt and redraw everything. If the LineReader is not actually reading a line, the string will simply be printed to the terminal.- Specified by:
printAbove
in interfaceLineReader
- Parameters:
str
- the string to print- See Also:
LineReader.printAbove(AttributedString)
-
printAbove
public void printAbove(AttributedString str)
Description copied from interface:LineReader
Prints a string before the prompt and redraw everything. If the LineReader is not actually reading a line, the string will simply be printed to the terminal.- Specified by:
printAbove
in interfaceLineReader
- Parameters:
str
- the string to print- See Also:
LineReader.printAbove(String)
-
isReading
public boolean isReading()
Description copied from interface:LineReader
Check if a thread is currently in areadLine()
call.- Specified by:
isReading
in interfaceLineReader
- Returns:
true
if there is an ongoingreadLine()
call.
-
freshLine
protected boolean freshLine()
-
callWidget
public void callWidget(java.lang.String name)
- Specified by:
callWidget
in interfaceLineReader
-
redrawLine
public boolean redrawLine()
Clear the line and redraw it.- Returns:
true
-
putString
public void putString(java.lang.CharSequence str)
Write out the specified string to the buffer and the output stream.- Parameters:
str
- the char sequence to write in the buffer
-
flush
public void flush()
Flush the terminal output stream. This is important for printout out single characters (like a buf.backspace or keyboard) that we want the terminal to handle immediately.- Specified by:
flush
in interfacejava.io.Flushable
-
isKeyMap
public boolean isKeyMap(java.lang.String name)
-
readCharacter
public int readCharacter()
Read a character from the terminal.- Returns:
- the character, or -1 if an EOF is received.
-
peekCharacter
public int peekCharacter(long timeout)
-
doReadStringUntil
protected java.lang.String doReadStringUntil(java.lang.String sequence)
-
readBinding
public Binding readBinding(KeyMap<Binding> keys)
Read from the input stream and decode an operation from the key map. The input stream will be read character by character until a matching binding can be found. Characters that can't possibly be matched to any binding will be discarded.- Parameters:
keys
- the KeyMap to use for decoding the input stream- Returns:
- the decoded binding or
null
if the end of stream has been reached
-
getParsedLine
public ParsedLine getParsedLine()
- Specified by:
getParsedLine
in interfaceLineReader
-
getLastBinding
public java.lang.String getLastBinding()
- Specified by:
getLastBinding
in interfaceLineReader
-
getSearchTerm
public java.lang.String getSearchTerm()
- Specified by:
getSearchTerm
in interfaceLineReader
-
getRegionActive
public LineReader.RegionType getRegionActive()
- Specified by:
getRegionActive
in interfaceLineReader
-
getRegionMark
public int getRegionMark()
- Specified by:
getRegionMark
in interfaceLineReader
-
setKeyMap
public boolean setKeyMap(java.lang.String name)
Sets the current keymap by name. Supported keymaps are "emacs", "viins", "vicmd".- Specified by:
setKeyMap
in interfaceLineReader
- Parameters:
name
- The name of the keymap to switch to- Returns:
- true if the keymap was set, or false if the keymap is not recognized.
-
getKeyMap
public java.lang.String getKeyMap()
Returns the name of the current key mapping.- Specified by:
getKeyMap
in interfaceLineReader
- 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)
.
-
variable
public LineReader variable(java.lang.String name, java.lang.Object value)
- Specified by:
variable
in interfaceLineReader
-
getVariables
public java.util.Map<java.lang.String,java.lang.Object> getVariables()
- Specified by:
getVariables
in interfaceLineReader
-
getVariable
public java.lang.Object getVariable(java.lang.String name)
- Specified by:
getVariable
in interfaceLineReader
-
setVariable
public void setVariable(java.lang.String name, java.lang.Object value)
- Specified by:
setVariable
in interfaceLineReader
-
option
public LineReader option(LineReader.Option option, boolean value)
- Specified by:
option
in interfaceLineReader
-
isSet
public boolean isSet(LineReader.Option option)
- Specified by:
isSet
in interfaceLineReader
-
setOpt
public void setOpt(LineReader.Option option)
- Specified by:
setOpt
in interfaceLineReader
-
unsetOpt
public void unsetOpt(LineReader.Option option)
- Specified by:
unsetOpt
in interfaceLineReader
-
addCommandsInBuffer
public void addCommandsInBuffer(java.util.Collection<java.lang.String> commands)
- Specified by:
addCommandsInBuffer
in interfaceLineReader
-
editAndAddInBuffer
public void editAndAddInBuffer(java.io.File file) throws java.lang.Exception
- Specified by:
editAndAddInBuffer
in interfaceLineReader
- Throws:
java.lang.Exception
-
finishBuffer
protected java.lang.String finishBuffer()
Clear the buffer and add its contents to the history.- Returns:
- the former contents of the buffer.
-
finish
protected java.lang.String finish(java.lang.String str)
-
handleSignal
protected void handleSignal(Terminal.Signal signal)
-
getWidget
protected Widget getWidget(java.lang.Object binding)
-
setPrompt
public void setPrompt(java.lang.String prompt)
-
setRightPrompt
public void setRightPrompt(java.lang.String rightPrompt)
-
setBuffer
protected void setBuffer(Buffer buffer)
-
setBuffer
protected void setBuffer(java.lang.String buffer)
Set the current buffer's content to the specifiedString
. The visual terminal will be modified to show the current buffer.- Parameters:
buffer
- the new contents of the buffer.
-
viDeleteChangeYankToRemap
protected java.lang.String viDeleteChangeYankToRemap(java.lang.String 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. Any operation that isn't allow drops you back into movement mode.- Parameters:
op
- The incoming operation to remap- Returns:
- The remaped operation
-
switchCase
protected int switchCase(int ch)
-
isInViMoveOperation
protected boolean isInViMoveOperation()
- Returns:
- true if line reader is in the middle of doing a change-to delete-to or yank-to.
-
isInViChangeOperation
protected boolean isInViChangeOperation()
-
isInViCmdMode
protected boolean isInViCmdMode()
-
viForwardChar
protected boolean viForwardChar()
-
viBackwardChar
protected boolean viBackwardChar()
-
forwardWord
protected boolean forwardWord()
-
viForwardWord
protected boolean viForwardWord()
-
viForwardBlankWord
protected boolean viForwardBlankWord()
-
emacsForwardWord
protected boolean emacsForwardWord()
-
viForwardBlankWordEnd
protected boolean viForwardBlankWordEnd()
-
viForwardWordEnd
protected boolean viForwardWordEnd()
-
backwardWord
protected boolean backwardWord()
-
viBackwardWord
protected boolean viBackwardWord()
-
viBackwardBlankWord
protected boolean viBackwardBlankWord()
-
viBackwardWordEnd
protected boolean viBackwardWordEnd()
-
viBackwardBlankWordEnd
protected boolean viBackwardBlankWordEnd()
-
emacsBackwardWord
protected boolean emacsBackwardWord()
-
backwardDeleteWord
protected boolean backwardDeleteWord()
-
viBackwardKillWord
protected boolean viBackwardKillWord()
-
backwardKillWord
protected boolean backwardKillWord()
-
copyPrevWord
protected boolean copyPrevWord()
-
upCaseWord
protected boolean upCaseWord()
-
downCaseWord
protected boolean downCaseWord()
-
capitalizeWord
protected boolean capitalizeWord()
-
deleteWord
protected boolean deleteWord()
-
killWord
protected boolean killWord()
-
transposeWords
protected boolean transposeWords()
-
findbol
private int findbol()
-
findeol
private int findeol()
-
insertComment
protected boolean insertComment()
-
viInsertComment
protected boolean viInsertComment()
-
doInsertComment
protected boolean doInsertComment(boolean isViMode)
-
viFindNextChar
protected boolean viFindNextChar()
-
viFindPrevChar
protected boolean viFindPrevChar()
-
viFindNextCharSkip
protected boolean viFindNextCharSkip()
-
viFindPrevCharSkip
protected boolean viFindPrevCharSkip()
-
viRepeatFind
protected boolean viRepeatFind()
-
viRevRepeatFind
protected boolean viRevRepeatFind()
-
vigetkey
private int vigetkey()
-
vifindchar
private boolean vifindchar(boolean repeat)
-
callNeg
private boolean callNeg(Widget widget)
-
viHistorySearchForward
protected boolean viHistorySearchForward()
Implements vi search ("/" or "?").- Returns:
true
if the search was successful
-
viHistorySearchBackward
protected boolean viHistorySearchBackward()
-
viRepeatSearch
protected boolean viRepeatSearch()
-
viRevRepeatSearch
protected boolean viRevRepeatSearch()
-
getViSearchString
private boolean getViSearchString()
-
insertCloseCurly
protected boolean insertCloseCurly()
-
insertCloseParen
protected boolean insertCloseParen()
-
insertCloseSquare
protected boolean insertCloseSquare()
-
insertClose
protected boolean insertClose(java.lang.String s)
-
removeIndentation
private void removeIndentation()
-
viMatchBracket
protected boolean viMatchBracket()
-
undefinedKey
protected boolean undefinedKey()
-
doViMatchBracket
protected boolean doViMatchBracket()
Implements vi style bracket matching ("%" command). The matching bracket for the current bracket type that you are sitting on is matched.- Returns:
- true if it worked, false if the cursor was not on a bracket character or if there was no matching bracket.
-
getBracketType
protected int getBracketType(int ch)
Given a character determines what type of bracket it is (paren, square, curly, or none).- Parameters:
ch
- The character to check- 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.
-
transposeChars
protected boolean transposeChars()
Performs character transpose. The character prior to the cursor and the character under the cursor are swapped and the cursor is advanced one. Do not cross line breaks.- Returns:
- true
-
undo
protected boolean undo()
-
redo
protected boolean redo()
-
sendBreak
protected boolean sendBreak()
-
backwardChar
protected boolean backwardChar()
-
forwardChar
protected boolean forwardChar()
-
viDigitOrBeginningOfLine
protected boolean viDigitOrBeginningOfLine()
-
universalArgument
protected boolean universalArgument()
-
argumentBase
protected boolean argumentBase()
-
negArgument
protected boolean negArgument()
-
digitArgument
protected boolean digitArgument()
-
viDelete
protected boolean viDelete()
-
viYankTo
protected boolean viYankTo()
-
viYankWholeLine
protected boolean viYankWholeLine()
-
viChange
protected boolean viChange()
-
cleanup
protected void cleanup()
-
doCleanup
protected void doCleanup(boolean nl)
-
historyIncrementalSearchForward
protected boolean historyIncrementalSearchForward()
-
historyIncrementalSearchBackward
protected boolean historyIncrementalSearchBackward()
-
doSearchHistory
protected boolean doSearchHistory(boolean backward)
-
matches
private java.util.List<LineReaderImpl.Pair<java.lang.Integer,java.lang.Integer>> matches(java.util.regex.Pattern p, java.lang.String line, int index)
-
doGetSearchPattern
private java.lang.String doGetSearchPattern()
-
pushBackBinding
private void pushBackBinding()
-
pushBackBinding
private void pushBackBinding(boolean skip)
-
historySearchForward
protected boolean historySearchForward()
-
getFirstWord
private java.lang.CharSequence getFirstWord()
-
historySearchBackward
protected boolean historySearchBackward()
-
searchBackwards
public int searchBackwards(java.lang.String searchTerm, int startIndex)
Search backward in history from a given position.- Parameters:
searchTerm
- substring to search for.startIndex
- the index from which on to search- Returns:
- index where this substring has been found, or -1 else.
-
searchBackwards
public int searchBackwards(java.lang.String searchTerm)
Search backwards in history from the current position.- Parameters:
searchTerm
- substring to search for.- Returns:
- index where the substring has been found, or -1 else.
-
searchBackwards
public int searchBackwards(java.lang.String searchTerm, int startIndex, boolean startsWith)
-
searchForwards
public int searchForwards(java.lang.String searchTerm, int startIndex, boolean startsWith)
-
searchForwards
public int searchForwards(java.lang.String searchTerm, int startIndex)
Search forward in history from a given position.- Parameters:
searchTerm
- substring to search for.startIndex
- the index from which on to search- Returns:
- index where this substring has been found, or -1 else.
-
searchForwards
public int searchForwards(java.lang.String searchTerm)
Search forwards in history from the current position.- Parameters:
searchTerm
- substring to search for.- Returns:
- index where the substring has been found, or -1 else.
-
quit
protected boolean quit()
-
acceptAndHold
protected boolean acceptAndHold()
-
acceptLineAndDownHistory
protected boolean acceptLineAndDownHistory()
-
acceptAndInferNextHistory
protected boolean acceptAndInferNextHistory()
-
acceptLine
protected boolean acceptLine()
-
indention
void indention(int nb, java.lang.StringBuilder sb)
-
selfInsert
protected boolean selfInsert()
-
selfInsertUnmeta
protected boolean selfInsertUnmeta()
-
overwriteMode
protected boolean overwriteMode()
-
beginningOfBufferOrHistory
protected boolean beginningOfBufferOrHistory()
-
beginningOfHistory
protected boolean beginningOfHistory()
-
endOfBufferOrHistory
protected boolean endOfBufferOrHistory()
-
endOfHistory
protected boolean endOfHistory()
-
beginningOfLineHist
protected boolean beginningOfLineHist()
-
endOfLineHist
protected boolean endOfLineHist()
-
upHistory
protected boolean upHistory()
-
downHistory
protected boolean downHistory()
-
viUpLineOrHistory
protected boolean viUpLineOrHistory()
-
viDownLineOrHistory
protected boolean viDownLineOrHistory()
-
upLine
protected boolean upLine()
-
downLine
protected boolean downLine()
-
upLineOrHistory
protected boolean upLineOrHistory()
-
upLineOrSearch
protected boolean upLineOrSearch()
-
downLineOrHistory
protected boolean downLineOrHistory()
-
downLineOrSearch
protected boolean downLineOrSearch()
-
viCmdMode
protected boolean viCmdMode()
-
viInsert
protected boolean viInsert()
-
viAddNext
protected boolean viAddNext()
-
viAddEol
protected boolean viAddEol()
-
emacsEditingMode
protected boolean emacsEditingMode()
-
viChangeWholeLine
protected boolean viChangeWholeLine()
-
viChangeEol
protected boolean viChangeEol()
-
viKillEol
protected boolean viKillEol()
-
quotedInsert
protected boolean quotedInsert()
-
viJoin
protected boolean viJoin()
-
viKillWholeLine
protected boolean viKillWholeLine()
-
viInsertBol
protected boolean viInsertBol()
-
backwardDeleteChar
protected boolean backwardDeleteChar()
-
viFirstNonBlank
protected boolean viFirstNonBlank()
-
viBeginningOfLine
protected boolean viBeginningOfLine()
-
viEndOfLine
protected boolean viEndOfLine()
-
beginningOfLine
protected boolean beginningOfLine()
-
endOfLine
protected boolean endOfLine()
-
deleteChar
protected boolean deleteChar()
-
viBackwardDeleteChar
protected boolean viBackwardDeleteChar()
Deletes the previous character from the cursor position- Returns:
true
if it succeeded,false
otherwise
-
viDeleteChar
protected boolean viDeleteChar()
Deletes the character you are sitting on and sucks the rest of the line in from the right.- Returns:
true
if it succeeded,false
otherwise
-
viSwapCase
protected boolean 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.- Returns:
true
if it succeeded,false
otherwise
-
viReplaceChars
protected boolean viReplaceChars()
Implements the vi change character command (in move-mode "r" followed by the character to change to).- Returns:
true
if it succeeded,false
otherwise
-
viChange
protected boolean viChange(int startPos, int endPos)
-
viDeleteTo
protected boolean viDeleteTo(int startPos, int endPos)
-
doViDeleteOrChange
protected boolean doViDeleteOrChange(int startPos, int endPos, boolean isChange)
Performs the vi "delete-to" action, deleting characters between a given span of the input line.- Parameters:
startPos
- The start positionendPos
- The end position.isChange
- 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- Returns:
true
if it succeeded,false
otherwise
-
viYankTo
protected boolean viYankTo(int startPos, int endPos)
Implement the "vi" yank-to operation. This operation allows you to yank the contents of the current line based upon a move operation, for example "yw" yanks the current word, "3yw" yanks 3 words, etc.- Parameters:
startPos
- The starting position from which to yankendPos
- The ending position to which to yank- Returns:
true
if the yank succeeded
-
viOpenLineAbove
protected boolean viOpenLineAbove()
-
viOpenLineBelow
protected boolean viOpenLineBelow()
-
viPutAfter
protected boolean viPutAfter()
Pasts the yank buffer to the right of the current cursor position and moves the cursor to the end of the pasted region.- Returns:
true
-
viPutBefore
protected boolean viPutBefore()
-
doLowercaseVersion
protected boolean doLowercaseVersion()
-
setMarkCommand
protected boolean setMarkCommand()
-
exchangePointAndMark
protected boolean exchangePointAndMark()
-
visualMode
protected boolean visualMode()
-
visualLineMode
protected boolean visualLineMode()
-
deactivateRegion
protected boolean deactivateRegion()
-
whatCursorPosition
protected boolean whatCursorPosition()
-
editAndExecute
protected boolean editAndExecute()
-
builtinWidgets
protected java.util.Map<java.lang.String,Widget> builtinWidgets()
-
addBuiltinWidget
private void addBuiltinWidget(java.util.Map<java.lang.String,Widget> widgets, java.lang.String name, Widget widget)
-
redisplay
public boolean redisplay()
-
redisplay
protected void redisplay(boolean flush)
-
concat
private void concat(java.util.List<AttributedString> lines, AttributedStringBuilder sb)
-
matchPreviousCommand
private java.lang.String matchPreviousCommand(java.lang.String buffer)
-
getDisplayedBufferWithPrompts
public AttributedString getDisplayedBufferWithPrompts(java.util.List<AttributedString> secondaryPrompts)
Compute the full string to be displayed with the left, right and secondary prompts- Parameters:
secondaryPrompts
- a list to store the secondary prompts- Returns:
- the displayed string including the buffer, left prompts and the help below
-
getHighlightedBuffer
private AttributedString getHighlightedBuffer(java.lang.String buffer)
-
expandPromptPattern
private AttributedString expandPromptPattern(java.lang.String pattern, int padToWidth, java.lang.String message, int line)
-
insertSecondaryPrompts
private AttributedString insertSecondaryPrompts(AttributedString str, java.util.List<AttributedString> prompts)
-
insertSecondaryPrompts
private AttributedString insertSecondaryPrompts(AttributedString strAtt, java.util.List<AttributedString> prompts, boolean computePrompts)
-
addRightPrompt
private AttributedString addRightPrompt(AttributedString prompt, AttributedString line)
-
insertTab
protected boolean insertTab()
-
expandHistory
protected boolean expandHistory()
-
expandWord
protected boolean expandWord()
-
expandOrComplete
protected boolean expandOrComplete()
-
expandOrCompletePrefix
protected boolean expandOrCompletePrefix()
-
completeWord
protected boolean completeWord()
-
menuComplete
protected boolean menuComplete()
-
menuExpandOrComplete
protected boolean menuExpandOrComplete()
-
completePrefix
protected boolean completePrefix()
-
listChoices
protected boolean listChoices()
-
listChoices
private boolean listChoices(boolean forSuggestion)
-
deleteCharOrList
protected boolean deleteCharOrList()
-
doComplete
protected boolean doComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix)
-
doComplete
protected boolean doComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix, boolean forSuggestion)
-
wrap
protected static CompletingParsedLine wrap(ParsedLine line)
-
getCandidateComparator
protected java.util.Comparator<Candidate> getCandidateComparator(boolean caseInsensitive, java.lang.String word)
-
getOthersGroupName
protected java.lang.String getOthersGroupName()
-
getOriginalGroupName
protected java.lang.String getOriginalGroupName()
-
getGroupComparator
protected java.util.Comparator<java.lang.String> getGroupComparator()
-
mergeCandidates
private void mergeCandidates(java.util.List<Candidate> possible)
-
nextBindingIsComplete
protected boolean nextBindingIsComplete()
-
displayRows
private int displayRows()
-
displayRows
private int displayRows(Status status)
-
promptLines
private int promptLines()
-
doMenu
protected boolean doMenu(java.util.List<Candidate> original, java.lang.String completed, java.util.function.BiFunction<java.lang.CharSequence,java.lang.Boolean,java.lang.CharSequence> escaper)
-
clearChoices
protected boolean clearChoices()
-
doList
protected boolean doList(java.util.List<Candidate> possible, java.lang.String completed, boolean runLoop, java.util.function.BiFunction<java.lang.CharSequence,java.lang.Boolean,java.lang.CharSequence> escaper)
-
doList
protected boolean doList(java.util.List<Candidate> possible, java.lang.String completed, boolean runLoop, java.util.function.BiFunction<java.lang.CharSequence,java.lang.Boolean,java.lang.CharSequence> escaper, boolean forSuggestion)
-
computePost
protected LineReaderImpl.PostResult computePost(java.util.List<Candidate> possible, Candidate selection, java.util.List<Candidate> ordered, java.lang.String completed)
-
computePost
protected LineReaderImpl.PostResult computePost(java.util.List<Candidate> possible, Candidate selection, java.util.List<Candidate> ordered, java.lang.String completed, java.util.function.Function<java.lang.String,java.lang.Integer> wcwidth, int width, boolean autoGroup, boolean groupName, boolean rowsFirst)
-
candidateStartPosition
private int candidateStartPosition(java.util.List<Candidate> cands)
-
toColumns
protected LineReaderImpl.PostResult toColumns(java.util.List<java.lang.Object> items, Candidate selection, java.lang.String completed, java.util.function.Function<java.lang.String,java.lang.Integer> wcwidth, int width, boolean rowsFirst)
-
toColumns
protected void toColumns(java.lang.Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, java.lang.String completed, boolean rowsFirst, boolean doMenuList, int[] out)
-
getCompletionStyleStarting
protected AttributedStyle getCompletionStyleStarting(boolean menuList)
-
getCompletionStyleDescription
protected AttributedStyle getCompletionStyleDescription(boolean menuList)
-
getCompletionStyleGroup
protected AttributedStyle getCompletionStyleGroup(boolean menuList)
-
getCompletionStyleSelection
protected AttributedStyle getCompletionStyleSelection(boolean menuList)
-
getCompletionStyleBackground
protected AttributedStyle getCompletionStyleBackground(boolean menuList)
-
getCompletionStyleStarting
protected AttributedStyle getCompletionStyleStarting()
-
getCompletionStyleDescription
protected AttributedStyle getCompletionStyleDescription()
-
getCompletionStyleGroup
protected AttributedStyle getCompletionStyleGroup()
-
getCompletionStyleSelection
protected AttributedStyle getCompletionStyleSelection()
-
getCompletionStyleBackground
protected AttributedStyle getCompletionStyleBackground()
-
getCompletionStyleListStarting
protected AttributedStyle getCompletionStyleListStarting()
-
getCompletionStyleListDescription
protected AttributedStyle getCompletionStyleListDescription()
-
getCompletionStyleListGroup
protected AttributedStyle getCompletionStyleListGroup()
-
getCompletionStyleListSelection
protected AttributedStyle getCompletionStyleListSelection()
-
getCompletionStyleListBackground
protected AttributedStyle getCompletionStyleListBackground()
-
getCompletionStyle
protected AttributedStyle getCompletionStyle(java.lang.String name, java.lang.String value)
-
buildStyle
protected AttributedStyle buildStyle(java.lang.String str)
-
moveHistory
protected boolean moveHistory(boolean next, int count)
Used in "vi" mode for argumented history move, to move a specific number of history entries forward or back.- Parameters:
next
- If true, move forwardcount
- The number of entries to move- Returns:
- true if the move was successful
-
moveHistory
protected boolean moveHistory(boolean next)
Move up or down the history tree.- Parameters:
next
-true
to go to the next,false
for the previous.- Returns:
true
if successful,false
otherwise
-
print
void print(java.lang.String str)
Raw output printing.- Parameters:
str
- the string to print to the terminal
-
println
void println(java.lang.String s)
-
println
void println()
Output a platform-dependant newline.
-
killBuffer
protected boolean killBuffer()
-
killWholeLine
protected boolean killWholeLine()
-
killLine
public boolean killLine()
Kill the buffer ahead of the current cursor position.- Returns:
- true if successful
-
backwardKillLine
public boolean backwardKillLine()
-
killRegion
public boolean killRegion()
-
copyRegionAsKill
public boolean copyRegionAsKill()
-
doCopyKillRegion
private boolean doCopyKillRegion(boolean kill)
-
yank
public boolean yank()
-
yankPop
public boolean yankPop()
-
mouse
public boolean mouse()
-
beginPaste
public boolean beginPaste()
-
focusIn
public boolean focusIn()
-
focusOut
public boolean focusOut()
-
clear
public boolean clear()
Clean the used display- Returns:
true
-
clearScreen
public boolean clearScreen()
Clear the screen by issuing the ANSI "clear screen" code.- Returns:
true
-
beep
public boolean beep()
Issue an audible keyboard bell.- Returns:
true
-
isDelimiter
protected boolean isDelimiter(int c)
Checks to see if the specified character is a delimiter. We consider a character a delimiter if it is anything but a letter or digit.- Parameters:
c
- The character to test- Returns:
- True if it is a delimiter
-
isWhitespace
protected boolean isWhitespace(int c)
Checks to see if a character is a whitespace character. Currently this delegates toCharacter.isWhitespace(char)
, however eventually it should be hooked up so that the definition of whitespace can be configured, as readline does.- Parameters:
c
- The character to check- Returns:
- true if the character is a whitespace
-
isViAlphaNum
protected boolean isViAlphaNum(int c)
-
isAlpha
protected boolean isAlpha(int c)
-
isWord
protected boolean isWord(int c)
-
getString
java.lang.String getString(java.lang.String name, java.lang.String def)
-
getBoolean
boolean getBoolean(java.lang.String name, boolean def)
-
getInt
int getInt(java.lang.String name, int def)
-
getLong
long getLong(java.lang.String name, long def)
-
defaultKeyMaps
public java.util.Map<java.lang.String,KeyMap<Binding>> defaultKeyMaps()
- Specified by:
defaultKeyMaps
in interfaceLineReader
-
bind
private void bind(KeyMap<Binding> map, java.lang.String widget, java.lang.Iterable<? extends java.lang.CharSequence> keySeqs)
-
bind
private void bind(KeyMap<Binding> map, java.lang.String widget, java.lang.CharSequence... keySeqs)
-
key
private java.lang.String key(InfoCmp.Capability capability)
-
bindConsoleChars
private void bindConsoleChars(KeyMap<Binding> keyMap, Attributes attr)
Bind special chars defined by the terminal instead of the default bindings
-
-