Class 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.
    Author:
    Marc Prud'hommeaux, Jason Dillon, Guillaume Nodet
    • Field Detail

      • 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_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_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
      • DEFAULT_SYSTEM_PROPERTY_PREFIX

        public static final java.lang.String DEFAULT_SYSTEM_PROPERTY_PREFIX
        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
      • DEFAULT_MAX_REPEAT_COUNT

        public static final int DEFAULT_MAX_REPEAT_COUNT
        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
      • parser

        protected Parser parser
      • options

        protected final java.util.Map<LineReader.Option,​java.lang.Boolean> options
      • buf

        protected final Buffer buf
      • tailTip

        protected java.lang.String tailTip
      • size

        protected final Size size
      • 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
      • findChar

        protected int findChar
        VI character find
      • findDir

        protected int findDir
      • findTailAdd

        protected int findTailAdd
      • regionMark

        protected int regionMark
        Region state
      • yankBuffer

        protected java.lang.String yankBuffer
        The vi yank buffer
      • isUndo

        protected boolean isUndo
      • lock

        protected final java.util.concurrent.locks.ReentrantLock lock
        State lock
      • startedReading

        protected final java.util.concurrent.atomic.AtomicBoolean startedReading
      • reading

        protected boolean reading
      • 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
      • 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

        protected int candidateStartPosition
      • alternateIn

        protected java.lang.String alternateIn
      • alternateOut

        protected java.lang.String alternateOut
    • 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

      • getAppName

        public java.lang.String getAppName()
        Specified by:
        getAppName in interface LineReader
      • getTailTip

        public java.lang.String getTailTip()
        Specified by:
        getTailTip in interface LineReader
      • setTailTip

        public void setTailTip​(java.lang.String tailTip)
        Specified by:
        setTailTip in interface LineReader
      • 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)
      • setHighlighter

        public void setHighlighter​(Highlighter highlighter)
      • setParser

        public void setParser​(Parser parser)
      • setExpander

        public void setExpander​(Expander expander)
      • setCompletionMatcher

        public void setCompletionMatcher​(CompletionMatcher completionMatcher)
      • 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 interface LineReader
        Parameters:
        mask - The mask character, null or 0.
        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 in InputStream, and return the line (without any trailing newlines).
        Specified by:
        readLine in interface LineReader
        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 in InputStream, and return the line (without any trailing newlines).
        Specified by:
        readLine in interface LineReader
        Parameters:
        prompt - The prompt to issue to the terminal, may be null.
        mask - The mask character, null or 0.
        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 in InputStream, and return the line (without any trailing newlines).
        Specified by:
        readLine in interface LineReader
        Parameters:
        prompt - The prompt to issue to the terminal, may be null.
        mask - The mask character, null or 0.
        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 in InputStream, and return the line (without any trailing newlines).
        Specified by:
        readLine in interface LineReader
        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 or 0.
        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 in InputStream, and return the line (without any trailing newlines).
        Specified by:
        readLine in interface LineReader
        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​(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 interface LineReader
        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 interface LineReader
        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 a readLine() call.
        Specified by:
        isReading in interface LineReader
        Returns:
        true if there is an ongoing readLine() call.
      • freshLine

        protected boolean freshLine()
      • callWidget

        public void callWidget​(java.lang.String name)
        Specified by:
        callWidget in interface LineReader
      • 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 interface java.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)
      • doReadBinding

        protected <T> T doReadBinding​(KeyMap<T> keys,
                                      KeyMap<T> local)
      • 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
      • setKeyMap

        public boolean setKeyMap​(java.lang.String name)
        Sets the current keymap by name. Supported keymaps are "emacs", "viins", "vicmd".
        Specified by:
        setKeyMap in interface LineReader
        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 interface LineReader
        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 interface LineReader
      • getVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getVariables()
        Specified by:
        getVariables in interface LineReader
      • getVariable

        public java.lang.Object getVariable​(java.lang.String name)
        Specified by:
        getVariable in interface LineReader
      • setVariable

        public void setVariable​(java.lang.String name,
                                java.lang.Object value)
        Specified by:
        setVariable in interface LineReader
      • addCommandsInBuffer

        public void addCommandsInBuffer​(java.util.Collection<java.lang.String> commands)
        Specified by:
        addCommandsInBuffer in interface LineReader
      • editAndAddInBuffer

        public void editAndAddInBuffer​(java.nio.file.Path file)
                                throws java.lang.Exception
        Specified by:
        editAndAddInBuffer in interface LineReader
        Throws:
        java.lang.Exception
      • getTabWidth

        protected int getTabWidth()
      • 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)
      • 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 specified String. 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()
      • 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:
        true if 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​(java.lang.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​(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()
      • 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 position
        endPos - 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 yank
        endPos - 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()
      • redisplay

        public boolean redisplay()
      • redisplay

        protected void redisplay​(boolean flush)
      • 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
      • 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()
      • 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()
      • nextBindingIsComplete

        protected boolean nextBindingIsComplete()
      • 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,
                                                        java.util.function.Function<java.lang.String,​java.lang.Integer> wcwidth,
                                                        int width,
                                                        boolean autoGroup,
                                                        boolean groupName,
                                                        boolean rowsFirst)
      • 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 forward
        count - 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
      • 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 to Character.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)
      • zeroOut

        public void zeroOut()
        Description copied from interface: LineReader
        Clear any internal buffers.
        Specified by:
        zeroOut in interface LineReader