- java.lang.Object
-
- org.jline.reader.impl.LineReaderImpl
-
- All Implemented Interfaces:
Flushable,LineReader
public class LineReaderImpl extends Object implements LineReader, Flushable
A reader for terminal applications. It supports custom tab-completion, saveable command history, and command line editing.- Author:
- Marc Prud'hommeaux, Jason Dillon, Guillaume Nodet
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLineReaderImpl.BellTypeprotected static classLineReaderImpl.CompletionTypeprotected static classLineReaderImpl.PostResultprotected static classLineReaderImpl.StatePossible states in which the current readline operation may be in.protected static classLineReaderImpl.ViMoveMode-
Nested classes/interfaces inherited from interface org.jline.reader.LineReader
LineReader.Option, LineReader.RegionType, LineReader.SuggestionType
-
-
Field Summary
-
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, String appName)LineReaderImpl(Terminal terminal, String appName, Map<String,Object> variables)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanacceptAndHold()protected booleanacceptAndInferNextHistory()protected booleanacceptLine()protected booleanacceptLineAndDownHistory()voidaddCommandsInBuffer(Collection<String> commands)protected booleanargumentBase()protected booleanbackwardChar()protected booleanbackwardDeleteChar()protected booleanbackwardDeleteWord()booleanbackwardKillLine()protected booleanbackwardKillWord()protected booleanbackwardWord()booleanbeep()Issue an audible keyboard bell.protected booleanbeginningOfBufferOrHistory()protected booleanbeginningOfHistory()protected booleanbeginningOfLine()protected booleanbeginningOfLineHist()booleanbeginPaste()protected AttributedStylebuildStyle(String str)protected Map<String,Widget>builtinWidgets()voidcallWidget(String name)protected booleancapitalizeWord()protected voidcleanup()booleanclear()Clean the used displayprotected booleanclearChoices()booleanclearScreen()Clear the screen by issuing the ANSI "clear screen" code.protected booleancompletePrefix()protected booleancompleteWord()protected LineReaderImpl.PostResultcomputePost(List<Candidate> possible, Candidate selection, List<Candidate> ordered, String completed)protected LineReaderImpl.PostResultcomputePost(List<Candidate> possible, Candidate selection, List<Candidate> ordered, String completed, Function<String,Integer> wcwidth, int width, boolean autoGroup, boolean groupName, boolean rowsFirst)protected booleancopyPrevWord()booleancopyRegionAsKill()protected booleandeactivateRegion()Map<String,KeyMap<Binding>>defaultKeyMaps()protected booleandeleteChar()protected booleandeleteCharOrList()protected booleandeleteWord()protected booleandigitArgument()protected voiddoCleanup(boolean nl)protected booleandoComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix)protected booleandoComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix, boolean forSuggestion)protected booleandoInsertComment(boolean isViMode)protected booleandoList(List<Candidate> possible, String completed, boolean runLoop, BiFunction<CharSequence,Boolean,CharSequence> escaper)protected booleandoList(List<Candidate> possible, String completed, boolean runLoop, BiFunction<CharSequence,Boolean,CharSequence> escaper, boolean forSuggestion)protected booleandoLowercaseVersion()protected booleandoMenu(List<Candidate> original, String completed, BiFunction<CharSequence,Boolean,CharSequence> escaper)protected <T> TdoReadBinding(KeyMap<T> keys, KeyMap<T> local)protected StringdoReadStringUntil(String sequence)protected booleandoSearchHistory(boolean backward)protected booleandoViDeleteOrChange(int startPos, int endPos, boolean isChange)Performs the vi "delete-to" action, deleting characters between a given span of the input line.protected booleandoViMatchBracket()Implements vi style bracket matching ("%" command).protected booleandownCaseWord()protected booleandownHistory()protected booleandownLine()protected booleandownLineOrHistory()protected booleandownLineOrSearch()voideditAndAddInBuffer(File file)protected booleaneditAndExecute()KeyMap<Binding>emacs()protected booleanemacsBackwardWord()protected booleanemacsEditingMode()protected booleanemacsForwardWord()protected booleanendOfBufferOrHistory()protected booleanendOfHistory()protected booleanendOfLine()protected booleanendOfLineHist()protected booleanexchangePointAndMark()protected booleanexpandHistory()protected booleanexpandOrComplete()protected booleanexpandOrCompletePrefix()protected booleanexpandWord()protected Stringfinish(String str)protected StringfinishBuffer()Clear the buffer and add its contents to the history.voidflush()Flush the terminal output stream.booleanfocusIn()booleanfocusOut()protected booleanforwardChar()protected booleanforwardWord()protected booleanfreshLine()StringgetAppName()LineReader.SuggestionTypegetAutosuggestion()protected intgetBracketType(int ch)Given a character determines what type of bracket it is (paren, square, curly, or none).BuffergetBuffer()Map<String,Widget>getBuiltinWidgets()protected Comparator<Candidate>getCandidateComparator(boolean caseInsensitive, String word)CompletergetCompleter()Returns the completer.protected AttributedStylegetCompletionStyle(String name, String value)protected AttributedStylegetCompletionStyleBackground()protected AttributedStylegetCompletionStyleBackground(boolean menuList)protected AttributedStylegetCompletionStyleDescription()protected AttributedStylegetCompletionStyleDescription(boolean menuList)protected AttributedStylegetCompletionStyleGroup()protected AttributedStylegetCompletionStyleGroup(boolean menuList)protected AttributedStylegetCompletionStyleListBackground()protected AttributedStylegetCompletionStyleListDescription()protected AttributedStylegetCompletionStyleListGroup()protected AttributedStylegetCompletionStyleListSelection()protected AttributedStylegetCompletionStyleListStarting()protected AttributedStylegetCompletionStyleSelection()protected AttributedStylegetCompletionStyleSelection(boolean menuList)protected AttributedStylegetCompletionStyleStarting()protected AttributedStylegetCompletionStyleStarting(boolean menuList)AttributedStringgetDisplayedBufferWithPrompts(List<AttributedString> secondaryPrompts)Compute the full string to be displayed with the left, right and secondary promptsExpandergetExpander()protected Comparator<String>getGroupComparator()HighlightergetHighlighter()HistorygetHistory()StringgetKeyMap()Returns the name of the current key mapping.Map<String,KeyMap<Binding>>getKeyMaps()KeyMap<Binding>getKeys()StringgetLastBinding()protected StringgetOriginalGroupName()protected StringgetOthersGroupName()ParsedLinegetParsedLine()ParsergetParser()LineReader.RegionTypegetRegionActive()intgetRegionMark()StringgetSearchTerm()StringgetTailTip()TerminalgetTerminal()ObjectgetVariable(String name)Map<String,Object>getVariables()protected WidgetgetWidget(Object binding)Map<String,Widget>getWidgets()protected voidhandleSignal(Terminal.Signal signal)protected booleanhistoryIncrementalSearchBackward()protected booleanhistoryIncrementalSearchForward()protected booleanhistorySearchBackward()protected booleanhistorySearchForward()protected booleaninsertClose(String s)protected booleaninsertCloseCurly()protected booleaninsertCloseParen()protected booleaninsertCloseSquare()protected booleaninsertComment()protected booleaninsertTab()protected booleanisAlpha(int c)protected booleanisDelimiter(int c)Checks to see if the specified character is a delimiter.protected booleanisInViChangeOperation()protected booleanisInViCmdMode()protected booleanisInViMoveOperation()booleanisKeyMap(String name)booleanisReading()Check if a thread is currently in areadLine()call.booleanisSet(LineReader.Option option)protected booleanisViAlphaNum(int c)protected booleanisWhitespace(int c)Checks to see if a character is a whitespace character.protected booleanisWord(int c)protected booleankillBuffer()booleankillLine()Kill the buffer ahead of the current cursor position.booleankillRegion()protected booleankillWholeLine()protected booleankillWord()protected booleanlistChoices()KeyMap<Binding>menu()protected booleanmenuComplete()protected booleanmenuExpandOrComplete()booleanmouse()protected booleanmoveHistory(boolean next)Move up or down the history tree.protected booleanmoveHistory(boolean next, int count)Used in "vi" mode for argumented history move, to move a specific number of history entries forward or back.protected booleannegArgument()protected booleannextBindingIsComplete()LineReaderoption(LineReader.Option option, boolean value)protected booleanoverwriteMode()intpeekCharacter(long timeout)voidprintAbove(String str)Prints a line above the prompt and redraw everything.voidprintAbove(AttributedString str)Prints a string before the prompt and redraw everything.voidputString(CharSequence str)Write out the specified string to the buffer and the output stream.protected booleanquit()protected booleanquotedInsert()BindingreadBinding(KeyMap<Binding> keys)Read from the input stream and decode an operation from the key map.BindingreadBinding(KeyMap<Binding> keys, KeyMap<Binding> local)intreadCharacter()Read a character from the terminal.StringreadLine()Read the next line and return the contents of the buffer.StringreadLine(Character mask)Read the next line with the specified character mask.StringreadLine(String prompt)Read a line from the inInputStream, and return the line (without any trailing newlines).StringreadLine(String prompt, Character mask)Read a line from the inInputStream, and return the line (without any trailing newlines).StringreadLine(String prompt, Character mask, String buffer)Read a line from the inInputStream, and return the line (without any trailing newlines).StringreadLine(String prompt, String rightPrompt, Character mask, String buffer)Read a line from the inInputStream, and return the line (without any trailing newlines).StringreadLine(String prompt, String rightPrompt, MaskingCallback maskingCallback, String buffer)Read a line from the inInputStream, and return the line (without any trailing newlines).MouseEventreadMouseEvent()Read a mouse event when theInfoCmp.Capability.key_mousesequence has just been read on the input stream.booleanredisplay()protected voidredisplay(boolean flush)protected booleanredo()booleanredrawLine()Clear the line and redraw it.voidrunMacro(String macro)Push back a key sequence that will be later consumed by the line reader.KeyMap<Binding>safe()intsearchBackwards(String searchTerm)Search backwards in history from the current position.intsearchBackwards(String searchTerm, int startIndex)Search backward in history from a given position.intsearchBackwards(String searchTerm, int startIndex, boolean startsWith)intsearchForwards(String searchTerm)Search forwards in history from the current position.intsearchForwards(String searchTerm, int startIndex)Search forward in history from a given position.intsearchForwards(String searchTerm, int startIndex, boolean startsWith)protected booleanselfInsert()protected booleanselfInsertUnmeta()protected booleansendBreak()voidsetAutosuggestion(LineReader.SuggestionType type)protected voidsetBuffer(String buffer)Set the current buffer's content to the specifiedString.protected voidsetBuffer(Buffer buffer)voidsetCompleter(Completer completer)Set the completer.voidsetCompletionMatcher(CompletionMatcher completionMatcher)voidsetExpander(Expander expander)voidsetHighlighter(Highlighter highlighter)voidsetHistory(History history)booleansetKeyMap(String name)Sets the current keymap by name.protected booleansetMarkCommand()voidsetOpt(LineReader.Option option)voidsetParser(Parser parser)voidsetPrompt(String prompt)voidsetRightPrompt(String rightPrompt)voidsetTailTip(String tailTip)voidsetVariable(String name, Object value)protected intswitchCase(int ch)protected voidtoColumns(Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, String completed, boolean rowsFirst, boolean doMenuList, int[] out)protected LineReaderImpl.PostResulttoColumns(List<Object> items, Candidate selection, String completed, Function<String,Integer> wcwidth, int width, boolean rowsFirst)protected booleantransposeChars()Performs character transpose.protected booleantransposeWords()protected booleanundefinedKey()protected booleanundo()protected booleanuniversalArgument()voidunsetOpt(LineReader.Option option)protected booleanupCaseWord()protected booleanupHistory()protected booleanupLine()protected booleanupLineOrHistory()protected booleanupLineOrSearch()LineReadervariable(String name, Object value)protected booleanviAddEol()protected booleanviAddNext()protected booleanviBackwardBlankWord()protected booleanviBackwardBlankWordEnd()protected booleanviBackwardChar()protected booleanviBackwardDeleteChar()Deletes the previous character from the cursor positionprotected booleanviBackwardKillWord()protected booleanviBackwardWord()protected booleanviBackwardWordEnd()protected booleanviBeginningOfLine()protected booleanviChange()protected booleanviChange(int startPos, int endPos)protected booleanviChangeEol()protected booleanviChangeWholeLine()KeyMap<Binding>viCmd()protected booleanviCmdMode()protected booleanviDelete()protected StringviDeleteChangeYankToRemap(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 booleanviDeleteChar()Deletes the character you are sitting on and sucks the rest of the line in from the right.protected booleanviDeleteTo(int startPos, int endPos)protected booleanviDigitOrBeginningOfLine()protected booleanviDownLineOrHistory()protected booleanviEndOfLine()protected booleanviFindNextChar()protected booleanviFindNextCharSkip()protected booleanviFindPrevChar()protected booleanviFindPrevCharSkip()protected booleanviFirstNonBlank()protected booleanviForwardBlankWord()protected booleanviForwardBlankWordEnd()protected booleanviForwardChar()protected booleanviForwardWord()protected booleanviForwardWordEnd()protected booleanviHistorySearchBackward()protected booleanviHistorySearchForward()Implements vi search ("/" or "?").protected booleanviInsert()protected booleanviInsertBol()protected booleanviInsertComment()KeyMap<Binding>viInsertion()protected booleanviJoin()protected booleanviKillEol()protected booleanviKillWholeLine()protected booleanviMatchBracket()protected booleanviOpenLineAbove()protected booleanviOpenLineBelow()KeyMap<Binding>viOpp()protected booleanviPutAfter()Pasts the yank buffer to the right of the current cursor position and moves the cursor to the end of the pasted region.protected booleanviPutBefore()protected booleanviRepeatFind()protected booleanviRepeatSearch()protected booleanviReplaceChars()Implements the vi change character command (in move-mode "r" followed by the character to change to).protected booleanviRevRepeatFind()protected booleanviRevRepeatSearch()KeyMap<Binding>visual()protected booleanvisualLineMode()protected booleanvisualMode()protected booleanviSwapCase()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 booleanviUpLineOrHistory()protected booleanviYankTo()protected booleanviYankTo(int startPos, int endPos)Implement the "vi" yank-to operation.protected booleanviYankWholeLine()protected booleanwhatCursorPosition()protected static CompletingParsedLinewrap(ParsedLine line)booleanyank()booleanyankPop()
-
-
-
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 String DEFAULT_WORDCHARS
- See Also:
- Constant Field Values
-
DEFAULT_REMOVE_SUFFIX_CHARS
public static final String DEFAULT_REMOVE_SUFFIX_CHARS
- See Also:
- Constant Field Values
-
DEFAULT_COMMENT_BEGIN
public static final String DEFAULT_COMMENT_BEGIN
- See Also:
- Constant Field Values
-
DEFAULT_SEARCH_TERMINATORS
public static final String DEFAULT_SEARCH_TERMINATORS
- See Also:
- Constant Field Values
-
DEFAULT_BELL_STYLE
public static final 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 String DEFAULT_SECONDARY_PROMPT_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_OTHERS_GROUP_NAME
public static final String DEFAULT_OTHERS_GROUP_NAME
- See Also:
- Constant Field Values
-
DEFAULT_ORIGINAL_GROUP_NAME
public static final String DEFAULT_ORIGINAL_GROUP_NAME
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_STARTING
public static final String DEFAULT_COMPLETION_STYLE_STARTING
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_DESCRIPTION
public static final String DEFAULT_COMPLETION_STYLE_DESCRIPTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_GROUP
public static final String DEFAULT_COMPLETION_STYLE_GROUP
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_SELECTION
public static final String DEFAULT_COMPLETION_STYLE_SELECTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_BACKGROUND
public static final String DEFAULT_COMPLETION_STYLE_BACKGROUND
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_STARTING
public static final String DEFAULT_COMPLETION_STYLE_LIST_STARTING
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_DESCRIPTION
public static final String DEFAULT_COMPLETION_STYLE_LIST_DESCRIPTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_GROUP
public static final String DEFAULT_COMPLETION_STYLE_LIST_GROUP
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_SELECTION
public static final String DEFAULT_COMPLETION_STYLE_LIST_SELECTION
- See Also:
- Constant Field Values
-
DEFAULT_COMPLETION_STYLE_LIST_BACKGROUND
public static final 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
-
BRACKETED_PASTE_ON
public static final String BRACKETED_PASTE_ON
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_OFF
public static final String BRACKETED_PASTE_OFF
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_BEGIN
public static final String BRACKETED_PASTE_BEGIN
- See Also:
- Constant Field Values
-
BRACKETED_PASTE_END
public static final String BRACKETED_PASTE_END
- See Also:
- Constant Field Values
-
FOCUS_IN_SEQ
public static final String FOCUS_IN_SEQ
- See Also:
- Constant Field Values
-
FOCUS_OUT_SEQ
public static final String FOCUS_OUT_SEQ
- See Also:
- Constant Field Values
-
terminal
protected final Terminal terminal
The terminal to use
-
appName
protected final String appName
The application name
-
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 Map<LineReader.Option,Boolean> options
-
buf
protected final Buffer buf
-
tailTip
protected String tailTip
-
autosuggestion
protected LineReader.SuggestionType autosuggestion
-
size
protected final Size size
-
prompt
protected AttributedString prompt
-
rightPrompt
protected AttributedString rightPrompt
-
maskingCallback
protected MaskingCallback maskingCallback
-
historyBuffer
protected Buffer historyBuffer
-
searchBuffer
protected CharSequence searchBuffer
-
searchTerm
protected 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
-
regionMark
protected int regionMark
Region state
-
regionActive
protected LineReader.RegionType regionActive
-
yankBuffer
protected String yankBuffer
The vi yank buffer
-
viMoveMode
protected LineReaderImpl.ViMoveMode viMoveMode
-
killRing
protected KillRing killRing
-
isUndo
protected boolean isUndo
-
lock
protected final ReentrantLock lock
State lock
-
state
protected LineReaderImpl.State state
-
startedReading
protected final AtomicBoolean startedReading
-
reading
protected boolean reading
-
post
protected Supplier<AttributedString> post
-
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 String keyMap
-
smallTerminalOffset
protected int smallTerminalOffset
-
nextCommandFromHistory
protected boolean nextCommandFromHistory
-
nextHistoryId
protected int nextHistoryId
-
-
Constructor Detail
-
LineReaderImpl
public LineReaderImpl(Terminal terminal) throws IOException
- Throws:
IOException
-
LineReaderImpl
public LineReaderImpl(Terminal terminal, String appName) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getTerminal
public Terminal getTerminal()
- Specified by:
getTerminalin interfaceLineReader
-
getAppName
public String getAppName()
- Specified by:
getAppNamein interfaceLineReader
-
getKeyMaps
public Map<String,KeyMap<Binding>> getKeyMaps()
- Specified by:
getKeyMapsin interfaceLineReader
-
getKeys
public KeyMap<Binding> getKeys()
- Specified by:
getKeysin interfaceLineReader
-
getWidgets
public Map<String,Widget> getWidgets()
- Specified by:
getWidgetsin interfaceLineReader
-
getBuiltinWidgets
public Map<String,Widget> getBuiltinWidgets()
- Specified by:
getBuiltinWidgetsin interfaceLineReader
-
getBuffer
public Buffer getBuffer()
- Specified by:
getBufferin interfaceLineReader
-
setAutosuggestion
public void setAutosuggestion(LineReader.SuggestionType type)
- Specified by:
setAutosuggestionin interfaceLineReader
-
getAutosuggestion
public LineReader.SuggestionType getAutosuggestion()
- Specified by:
getAutosuggestionin interfaceLineReader
-
getTailTip
public String getTailTip()
- Specified by:
getTailTipin interfaceLineReader
-
setTailTip
public void setTailTip(String tailTip)
- Specified by:
setTailTipin interfaceLineReader
-
runMacro
public void runMacro(String macro)
Description copied from interface:LineReaderPush 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:
runMacroin interfaceLineReader- Parameters:
macro- the key sequence to push back- See Also:
Terminal.getCursorPosition(IntConsumer),LineReader.readMouseEvent()
-
readMouseEvent
public MouseEvent readMouseEvent()
Description copied from interface:LineReaderRead a mouse event when theInfoCmp.Capability.key_mousesequence 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:
readMouseEventin 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:
getHistoryin interfaceLineReader
-
setHighlighter
public void setHighlighter(Highlighter highlighter)
-
getHighlighter
public Highlighter getHighlighter()
- Specified by:
getHighlighterin interfaceLineReader
-
getParser
public Parser getParser()
- Specified by:
getParserin interfaceLineReader
-
setParser
public void setParser(Parser parser)
-
getExpander
public Expander getExpander()
- Specified by:
getExpanderin interfaceLineReader
-
setExpander
public void setExpander(Expander expander)
-
setCompletionMatcher
public void setCompletionMatcher(CompletionMatcher completionMatcher)
-
readLine
public String readLine() throws UserInterruptException, EndOfFileException
Read the next line and return the contents of the buffer.- Specified by:
readLinein 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 String readLine(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:
readLinein interfaceLineReader- Parameters:
mask- The mask character,nullor0.- 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 String readLine(String prompt) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream, and return the line (without any trailing newlines).- Specified by:
readLinein 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 String readLine(String prompt, Character mask) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream, and return the line (without any trailing newlines).- Specified by:
readLinein interfaceLineReader- Parameters:
prompt- The prompt to issue to the terminal, may be null.mask- The mask character,nullor0.- 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 String readLine(String prompt, Character mask, String buffer) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream, and return the line (without any trailing newlines).- Specified by:
readLinein interfaceLineReader- Parameters:
prompt- The prompt to issue to the terminal, may be null.mask- The mask character,nullor0.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 String readLine(String prompt, String rightPrompt, Character mask, String buffer) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream, and return the line (without any trailing newlines).- Specified by:
readLinein 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,nullor0.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 String readLine(String prompt, String rightPrompt, MaskingCallback maskingCallback, String buffer) throws UserInterruptException, EndOfFileException
Read a line from the inInputStream, and return the line (without any trailing newlines).- Specified by:
readLinein 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)
-
printAbove
public void printAbove(String str)
Description copied from interface:LineReaderPrints 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:
printAbovein interfaceLineReader- Parameters:
str- the string to print- See Also:
LineReader.printAbove(AttributedString)
-
printAbove
public void printAbove(AttributedString str)
Description copied from interface:LineReaderPrints 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:
printAbovein interfaceLineReader- Parameters:
str- the string to print- See Also:
LineReader.printAbove(String)
-
isReading
public boolean isReading()
Description copied from interface:LineReaderCheck if a thread is currently in areadLine()call.- Specified by:
isReadingin interfaceLineReader- Returns:
trueif there is an ongoingreadLine()call.
-
freshLine
protected boolean freshLine()
-
callWidget
public void callWidget(String name)
- Specified by:
callWidgetin interfaceLineReader
-
redrawLine
public boolean redrawLine()
Clear the line and redraw it.- Returns:
true
-
putString
public void putString(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.
-
isKeyMap
public boolean isKeyMap(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)
-
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
nullif the end of stream has been reached
-
getParsedLine
public ParsedLine getParsedLine()
- Specified by:
getParsedLinein interfaceLineReader
-
getLastBinding
public String getLastBinding()
- Specified by:
getLastBindingin interfaceLineReader
-
getSearchTerm
public String getSearchTerm()
- Specified by:
getSearchTermin interfaceLineReader
-
getRegionActive
public LineReader.RegionType getRegionActive()
- Specified by:
getRegionActivein interfaceLineReader
-
getRegionMark
public int getRegionMark()
- Specified by:
getRegionMarkin interfaceLineReader
-
setKeyMap
public boolean setKeyMap(String name)
Sets the current keymap by name. Supported keymaps are "emacs", "viins", "vicmd".- Specified by:
setKeyMapin 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 String getKeyMap()
Returns the name of the current key mapping.- Specified by:
getKeyMapin 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(String name, Object value)
- Specified by:
variablein interfaceLineReader
-
getVariables
public Map<String,Object> getVariables()
- Specified by:
getVariablesin interfaceLineReader
-
getVariable
public Object getVariable(String name)
- Specified by:
getVariablein interfaceLineReader
-
setVariable
public void setVariable(String name, Object value)
- Specified by:
setVariablein interfaceLineReader
-
option
public LineReader option(LineReader.Option option, boolean value)
- Specified by:
optionin interfaceLineReader
-
isSet
public boolean isSet(LineReader.Option option)
- Specified by:
isSetin interfaceLineReader
-
setOpt
public void setOpt(LineReader.Option option)
- Specified by:
setOptin interfaceLineReader
-
unsetOpt
public void unsetOpt(LineReader.Option option)
- Specified by:
unsetOptin interfaceLineReader
-
addCommandsInBuffer
public void addCommandsInBuffer(Collection<String> commands)
- Specified by:
addCommandsInBufferin interfaceLineReader
-
editAndAddInBuffer
public void editAndAddInBuffer(File file) throws Exception
- Specified by:
editAndAddInBufferin interfaceLineReader- Throws:
Exception
-
finishBuffer
protected String finishBuffer()
Clear the buffer and add its contents to the history.- Returns:
- the former contents of the buffer.
-
handleSignal
protected void handleSignal(Terminal.Signal signal)
-
setPrompt
public void setPrompt(String prompt)
-
setRightPrompt
public void setRightPrompt(String rightPrompt)
-
setBuffer
protected void setBuffer(Buffer buffer)
-
setBuffer
protected void setBuffer(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 String viDeleteChangeYankToRemap(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()
-
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()
-
viHistorySearchForward
protected boolean viHistorySearchForward()
Implements vi search ("/" or "?").- Returns:
trueif the search was successful
-
viHistorySearchBackward
protected boolean viHistorySearchBackward()
-
viRepeatSearch
protected boolean viRepeatSearch()
-
viRevRepeatSearch
protected boolean viRevRepeatSearch()
-
insertCloseCurly
protected boolean insertCloseCurly()
-
insertCloseParen
protected boolean insertCloseParen()
-
insertCloseSquare
protected boolean insertCloseSquare()
-
insertClose
protected boolean insertClose(String s)
-
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)
-
historySearchForward
protected boolean historySearchForward()
-
historySearchBackward
protected boolean historySearchBackward()
-
searchBackwards
public int searchBackwards(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(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(String searchTerm, int startIndex, boolean startsWith)
-
searchForwards
public int searchForwards(String searchTerm, int startIndex, boolean startsWith)
-
searchForwards
public int searchForwards(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(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()
-
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:
trueif it succeeded,falseotherwise
-
viDeleteChar
protected boolean viDeleteChar()
Deletes the character you are sitting on and sucks the rest of the line in from the right.- Returns:
trueif it succeeded,falseotherwise
-
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:
trueif it succeeded,falseotherwise
-
viReplaceChars
protected boolean viReplaceChars()
Implements the vi change character command (in move-mode "r" followed by the character to change to).- Returns:
trueif it succeeded,falseotherwise
-
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:
trueif it succeeded,falseotherwise
-
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:
trueif 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()
-
redisplay
public boolean redisplay()
-
redisplay
protected void redisplay(boolean flush)
-
getDisplayedBufferWithPrompts
public AttributedString getDisplayedBufferWithPrompts(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
-
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()
-
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 Comparator<Candidate> getCandidateComparator(boolean caseInsensitive, String word)
-
getOthersGroupName
protected String getOthersGroupName()
-
getOriginalGroupName
protected String getOriginalGroupName()
-
getGroupComparator
protected Comparator<String> getGroupComparator()
-
nextBindingIsComplete
protected boolean nextBindingIsComplete()
-
doMenu
protected boolean doMenu(List<Candidate> original, String completed, BiFunction<CharSequence,Boolean,CharSequence> escaper)
-
clearChoices
protected boolean clearChoices()
-
doList
protected boolean doList(List<Candidate> possible, String completed, boolean runLoop, BiFunction<CharSequence,Boolean,CharSequence> escaper)
-
doList
protected boolean doList(List<Candidate> possible, String completed, boolean runLoop, BiFunction<CharSequence,Boolean,CharSequence> escaper, boolean forSuggestion)
-
computePost
protected LineReaderImpl.PostResult computePost(List<Candidate> possible, Candidate selection, List<Candidate> ordered, String completed)
-
computePost
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)
-
toColumns
protected LineReaderImpl.PostResult toColumns(List<Object> items, Candidate selection, String completed, Function<String,Integer> wcwidth, int width, boolean rowsFirst)
-
toColumns
protected void toColumns(Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, 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(String name, String value)
-
buildStyle
protected AttributedStyle buildStyle(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-trueto go to the next,falsefor the previous.- Returns:
trueif successful,falseotherwise
-
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()
-
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)
-
defaultKeyMaps
public Map<String,KeyMap<Binding>> defaultKeyMaps()
- Specified by:
defaultKeyMapsin interfaceLineReader
-
-