Class LineReaderImpl
- All Implemented Interfaces:
Flushable, LineReader
LineReader interface.
This class provides a comprehensive implementation of line editing capabilities for interactive terminal applications, including:
- Command history navigation and management
- Tab completion with customizable completion strategies
- Syntax highlighting
- Emacs and Vi editing modes
- Key binding customization
- Cut and paste with kill ring
- Undo/redo functionality
- Search through history
- Multi-line editing
- Character masking for password input
This implementation is highly configurable through options and variables that control various aspects of its behavior. It also provides a rich set of widgets (editing functions) that can be bound to key sequences.
Most applications should not create instances of this class directly, but instead
use the LineReaderBuilder to create properly configured instances.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumprotected static enumprotected static classprotected static enumPossible states in which the current readline operation may be in.protected static enumNested classes/interfaces inherited from interface LineReader
LineReader.Option, LineReader.RegionType, LineReader.SuggestionType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected final StringThe application nameprotected LineReader.SuggestionTypeprotected final BindingReaderstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected final Bufferprotected intprotected Completerprotected CompletionMatcherprotected intprotected intstatic final longstatic final Stringstatic final longstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringprotected Displayprotected booleanprotected Expanderprotected intVI character findprotected intprotected intstatic final Stringstatic final Stringprotected Highlighterprotected Historyprotected Bufferprotected booleanprotected booleanprotected StringThe terminal keys mappingprotected KillRingprotected intprotected final ReentrantLockState lockprotected MaskingCallbackprotected Threadprotected intprotected booleanprotected intstatic final charprotected final Map<LineReader.Option, Boolean> protected booleanprotected ParsedLineprotected Parserprotected Supplier<AttributedString> protected AttributedStringprotected booleanprotected LineReader.RegionTypeprotected intRegion stateprotected intprotected AttributedStringprotected booleanprotected CharSequenceprotected booleanprotected intprotected StringBufferprotected final Sizeprotected booleanprotected intprotected final AtomicBooleanprotected LineReaderImpl.Statestatic final intDeprecated.protected Stringprotected final TerminalThe terminal to useprotected intprotected LineReaderImpl.ViMoveModeprotected StringThe vi yank bufferFields inherited from interface 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, DUMB, 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, INPUT_RC_FILE_NAME, 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, MAX_REPEAT_COUNT, 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, SYSTEM_PROPERTY_PREFIX, 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
ConstructorsConstructorDescriptionLineReaderImpl(Terminal terminal) LineReaderImpl(Terminal terminal, String appName) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected booleanprotected booleanprotected booleanvoidaddCommandsInBuffer(Collection<String> commands) Adds a collection of commands to the input buffer for execution.protected booleanprotected booleanprotected booleanprotected booleanbooleanprotected booleanprotected booleanbooleanbeep()Issue an audible keyboard bell.protected booleanprotected booleanprotected booleanprotected booleanbooleanprotected AttributedStylebuildStyle(String str) voidcallWidget(String name) Calls a widget by name.protected booleanprotected voidcleanup()booleanclear()Clean the used displayprotected booleanbooleanClear the screen by issuing the ANSI "clear screen" code.protected booleanprotected booleanprotected 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 booleanbooleanprotected booleanReturns the default key maps used by the LineReader.protected booleanprotected booleanprotected booleanprotected booleanprotected 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 booleanprotected 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 booleanImplements vi style bracket matching ("%" command).protected booleanprotected booleanprotected booleandownLine()protected booleanprotected booleandumb()voideditAndAddInBuffer(Path file) Opens a file in an external editor and adds its contents to the input buffer.protected booleanemacs()protected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected Stringprotected StringClear the buffer and add its contents to the history.voidflush()Flush the terminal output stream.booleanfocusIn()booleanfocusOut()protected booleanprotected booleanprotected booleanReturns the application name associated with this LineReader.Returns the current auto-suggestion type.protected intgetBracketType(int ch) Given a character determines what type of bracket it is (paren, square, curly, or none).Returns the current line buffer.Returns a map of all built-in widgets provided by the LineReader.protected Comparator<Candidate> getCandidateComparator(boolean caseInsensitive, String word) Returns the completer.protected AttributedStylegetCompletionStyle(String name, String value) protected AttributedStyleprotected AttributedStylegetCompletionStyleBackground(boolean menuList) protected AttributedStyleprotected AttributedStylegetCompletionStyleDescription(boolean menuList) protected AttributedStyleprotected AttributedStylegetCompletionStyleGroup(boolean menuList) protected AttributedStyleprotected AttributedStyleprotected AttributedStyleprotected AttributedStyleprotected AttributedStyleprotected AttributedStyleprotected AttributedStylegetCompletionStyleSelection(boolean menuList) protected AttributedStyleprotected AttributedStylegetCompletionStyleStarting(boolean menuList) getDisplayedBufferWithPrompts(List<AttributedString> secondaryPrompts) Compute the full string to be displayed with the left, right and secondary promptsReturns the expander associated with this LineReader.protected Comparator<String> Returns the highlighter associated with this LineReader.Returns the history associated with this LineReader.Returns the name of the current key mapping.Returns all key maps registered with this LineReader.getKeys()Returns the currently active key map.Returns the last key binding that was processed.protected Stringprotected StringReturns the parsed representation of the current line.Returns the parser associated with this LineReader.Returns the type of the currently active region selection.intReturns the mark position of the currently active region.Returns the current search term when in history search mode.protected intReturns the current tail tip text.Returns the terminal associated with this LineReader.getVariable(String name) Returns the value of a variable.Returns a map of all variables set in the LineReader.protected WidgetReturns a map of all widgets registered with this LineReader.protected voidhandleSignal(Terminal.Signal signal) protected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanisAlpha(int c) protected booleanisDelimiter(int c) Checks to see if the specified character is a delimiter.protected booleanprotected booleanprotected booleanbooleanbooleanCheck if a thread is currently in areadLine()call.booleanisSet(LineReader.Option option) Checks if an option is set.protected booleanisViAlphaNum(int c) protected booleanisWhitespace(int c) Checks to see if a character is a whitespace character.protected booleanisWord(int c) protected booleanbooleankillLine()Kill the buffer ahead of the current cursor position.booleanprotected booleanprotected booleankillWord()protected booleanmenu()protected booleanprotected booleanbooleanmouse()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 booleanprotected booleanoption(LineReader.Option option, boolean value) Sets an option in the LineReader and returns the LineReader for method chaining.protected booleanintpeekCharacter(long timeout) voidprintAbove(String str) Prints a line above the prompt and redraw everything.voidPrints 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 booleanreadBinding(KeyMap<Binding> keys) Read from the input stream and decode an operation from the key map.readBinding(KeyMap<Binding> keys, KeyMap<Binding> local) intRead a character from the terminal.readLine()Read the next line and return the contents of the buffer.Read the next line with the specified character mask.Read a line from the inInputStream, and return the line (without any trailing newlines).Read a line from the inInputStream, and return the line (without any trailing newlines).Read a line from the inInputStream, and return the line (without any trailing newlines).Read a line from the inInputStream, and return the line (without any trailing newlines).readLine(String prompt, String rightPrompt, MaskingCallback maskingCallback, String buffer) Read a line from the inInputStream, and return the line (without any trailing newlines).Read a mouse event when theInfoCmp.Capability.key_mousesequence has just been read on the input stream.booleanprotected voidredisplay(boolean flush) protected booleanredo()booleanClear the line and redraw it.voidPush back a key sequence that will be later consumed by the line reader.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 booleanprotected booleanprotected booleanvoidSets the type of auto-suggestion to use.protected voidSet the current buffer's content to the specifiedString.protected voidvoidsetCompleter(Completer completer) Set the completer.voidsetCompletionMatcher(CompletionMatcher completionMatcher) voidsetExpander(Expander expander) voidsetHighlighter(Highlighter highlighter) voidsetHistory(History history) booleanSets the current keymap by name.protected booleanvoidsetOpt(LineReader.Option option) Sets an option to true.voidvoidvoidsetRightPrompt(String rightPrompt) voidsetTailTip(String tailTip) Sets the tail tip text.voidsetVariable(String name, Object value) Sets a variable in the LineReader.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 booleanPerforms character transpose.protected booleanprotected booleanprotected booleanundo()protected booleanvoidunsetOpt(LineReader.Option option) Sets an option to false.protected booleanprotected booleanprotected booleanupLine()protected booleanprotected booleanSets a variable in the LineReader and returns the LineReader for method chaining.protected booleanviAddEol()protected booleanprotected booleanprotected booleanprotected booleanprotected booleanDeletes the previous character from the cursor positionprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanviChange()protected booleanviChange(int startPos, int endPos) protected booleanprotected booleanviCmd()protected booleanprotected booleanviDelete()protected StringThis 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 booleanDeletes the character you are sitting on and sucks the rest of the line in from the right.protected booleanviDeleteTo(int startPos, int endPos) protected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanImplements vi search ("/" or "?").protected booleanviInsert()protected booleanprotected booleanprotected booleanviJoin()protected booleanprotected booleanprotected booleanprotected booleanprotected booleanviOpp()protected booleanPasts the yank buffer to the right of the current cursor position and moves the cursor to the end of the pasted region.protected booleanprotected booleanprotected booleanprotected booleanImplements the vi change character command (in move-mode "r" followed by the character to change to).protected booleanprotected booleanvisual()protected booleanprotected booleanprotected booleanSwitches 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 booleanprotected booleanviYankTo()protected booleanviYankTo(int startPos, int endPos) Implement the "vi" yank-to operation.protected booleanprotected booleanprotected static CompletingParsedLinewrap(ParsedLine line) booleanyank()booleanyankPop()voidzeroOut()Clears any internal buffers and sensitive data.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface LineReader
editAndAddInBuffer
-
Field Details
-
NULL_MASK
public static final char NULL_MASK- See Also:
-
TAB_WIDTH
Deprecated.useDEFAULT_TAB_WIDTHandgetTabWidth()- See Also:
-
DEFAULT_TAB_WIDTH
public static final int DEFAULT_TAB_WIDTH- See Also:
-
DEFAULT_WORDCHARS
- See Also:
-
DEFAULT_REMOVE_SUFFIX_CHARS
- See Also:
-
DEFAULT_COMMENT_BEGIN
- See Also:
-
DEFAULT_SEARCH_TERMINATORS
- See Also:
-
DEFAULT_BELL_STYLE
- See Also:
-
DEFAULT_LIST_MAX
public static final int DEFAULT_LIST_MAX- See Also:
-
DEFAULT_MENU_LIST_MAX
public static final int DEFAULT_MENU_LIST_MAX- See Also:
-
DEFAULT_ERRORS
public static final int DEFAULT_ERRORS- See Also:
-
DEFAULT_BLINK_MATCHING_PAREN
public static final long DEFAULT_BLINK_MATCHING_PAREN- See Also:
-
DEFAULT_AMBIGUOUS_BINDING
public static final long DEFAULT_AMBIGUOUS_BINDING- See Also:
-
DEFAULT_SECONDARY_PROMPT_PATTERN
- See Also:
-
DEFAULT_OTHERS_GROUP_NAME
- See Also:
-
DEFAULT_ORIGINAL_GROUP_NAME
- See Also:
-
DEFAULT_COMPLETION_STYLE_STARTING
- See Also:
-
DEFAULT_COMPLETION_STYLE_DESCRIPTION
- See Also:
-
DEFAULT_COMPLETION_STYLE_GROUP
- See Also:
-
DEFAULT_COMPLETION_STYLE_SELECTION
- See Also:
-
DEFAULT_COMPLETION_STYLE_BACKGROUND
- See Also:
-
DEFAULT_COMPLETION_STYLE_LIST_STARTING
- See Also:
-
DEFAULT_COMPLETION_STYLE_LIST_DESCRIPTION
- See Also:
-
DEFAULT_COMPLETION_STYLE_LIST_GROUP
- See Also:
-
DEFAULT_COMPLETION_STYLE_LIST_SELECTION
- See Also:
-
DEFAULT_COMPLETION_STYLE_LIST_BACKGROUND
- See Also:
-
DEFAULT_INDENTATION
public static final int DEFAULT_INDENTATION- See Also:
-
DEFAULT_FEATURES_MAX_BUFFER_SIZE
public static final int DEFAULT_FEATURES_MAX_BUFFER_SIZE- See Also:
-
DEFAULT_SUGGESTIONS_MIN_BUFFER_SIZE
public static final int DEFAULT_SUGGESTIONS_MIN_BUFFER_SIZE- See Also:
-
DEFAULT_SYSTEM_PROPERTY_PREFIX
- See Also:
-
BRACKETED_PASTE_ON
- See Also:
-
BRACKETED_PASTE_OFF
- See Also:
-
BRACKETED_PASTE_BEGIN
- See Also:
-
BRACKETED_PASTE_END
- See Also:
-
FOCUS_IN_SEQ
- See Also:
-
FOCUS_OUT_SEQ
- See Also:
-
DEFAULT_MAX_REPEAT_COUNT
public static final int DEFAULT_MAX_REPEAT_COUNT- See Also:
-
terminal
The terminal to use -
appName
The application name -
keyMaps
-
variables
-
history
-
completer
-
highlighter
-
parser
-
expander
-
completionMatcher
-
options
-
maskThread
-
buf
-
tailTip
-
autosuggestion
-
size
-
prompt
-
rightPrompt
-
maskingCallback
-
modifiedHistory
-
historyBuffer
-
searchBuffer
-
searchTerm
-
searchFailing
protected boolean searchFailing -
searchBackward
protected boolean searchBackward -
searchIndex
protected int searchIndex -
doAutosuggestion
protected boolean doAutosuggestion -
bindingReader
-
findChar
protected int findCharVI character find -
findDir
protected int findDir -
findTailAdd
protected int findTailAdd -
regionMark
protected int regionMarkRegion state -
regionActive
-
yankBuffer
The vi yank buffer -
viMoveMode
-
killRing
-
undo
-
isUndo
protected boolean isUndo -
lock
State lock -
state
-
startedReading
-
reading
protected boolean reading -
post
-
builtinWidgets
-
widgets
-
count
protected int count -
mult
protected int mult -
universal
protected int universal -
repeatCount
protected int repeatCount -
isArgDigit
protected boolean isArgDigit -
parsedLine
-
skipRedisplay
protected boolean skipRedisplay -
display
-
lastStatusSize
protected int lastStatusSize -
overTyping
protected boolean overTyping -
keyMap
-
smallTerminalOffset
protected int smallTerminalOffset -
nextCommandFromHistory
protected boolean nextCommandFromHistory -
nextHistoryId
protected int nextHistoryId -
commandsBuffer
-
candidateStartPosition
protected int candidateStartPosition -
alternateIn
-
alternateOut
-
currentLine
protected int currentLine
-
-
Constructor Details
-
LineReaderImpl
- Throws:
IOException
-
LineReaderImpl
- Throws:
IOException
-
LineReaderImpl
-
-
Method Details
-
getTerminal
Description copied from interface:LineReaderReturns the terminal associated with this LineReader.The terminal is used for input/output operations and provides information about the terminal capabilities and size.
- Specified by:
getTerminalin interfaceLineReader- Returns:
- the terminal
-
getAppName
Description copied from interface:LineReaderReturns the application name associated with this LineReader.The application name is used for various purposes, such as naming history files and identifying the application in terminal titles.
- Specified by:
getAppNamein interfaceLineReader- Returns:
- the application name
-
getKeyMaps
Description copied from interface:LineReaderReturns all key maps registered with this LineReader.Key maps define the mappings from key sequences to actions for different editing modes (e.g., Emacs mode, Vi command mode, Vi insert mode).
- Specified by:
getKeyMapsin interfaceLineReader- Returns:
- a map of key map names to key maps
-
getKeys
Description copied from interface:LineReaderReturns the currently active key map.The active key map determines how key presses are interpreted and which actions they trigger.
- Specified by:
getKeysin interfaceLineReader- Returns:
- the active key map
-
getWidgets
Description copied from interface:LineReaderReturns a map of all widgets registered with this LineReader.Widgets are functions that perform editing operations and can be bound to key sequences.
- Specified by:
getWidgetsin interfaceLineReader- Returns:
- a map of widget names to widgets
-
getBuiltinWidgets
Description copied from interface:LineReaderReturns a map of all built-in widgets provided by the LineReader.Built-in widgets implement standard editing operations like cursor movement, text deletion, history navigation, etc.
- Specified by:
getBuiltinWidgetsin interfaceLineReader- Returns:
- a map of built-in widget names to widgets
-
getBuffer
Description copied from interface:LineReaderReturns the current line buffer.The buffer contains the text that the user is currently editing. It provides methods for manipulating the text and cursor position.
- Specified by:
getBufferin interfaceLineReader- Returns:
- the current line buffer
-
setAutosuggestion
Description copied from interface:LineReaderSets the type of auto-suggestion to use.Auto-suggestions provide inline completion suggestions as the user types, based on history, completers, or other sources.
- Specified by:
setAutosuggestionin interfaceLineReader- Parameters:
type- the type of auto-suggestion to use
-
getAutosuggestion
Description copied from interface:LineReaderReturns the current auto-suggestion type.Auto-suggestions provide inline completion suggestions as the user types, based on history, completers, or other sources.
- Specified by:
getAutosuggestionin interfaceLineReader- Returns:
- the current auto-suggestion type
-
getTailTip
Description copied from interface:LineReaderReturns the current tail tip text.The tail tip is a hint or suggestion displayed at the end of the current line, typically showing command syntax or parameter information.
- Specified by:
getTailTipin interfaceLineReader- Returns:
- the current tail tip text, or null if no tail tip is set
-
setTailTip
Description copied from interface:LineReaderSets the tail tip text.The tail tip is a hint or suggestion displayed at the end of the current line, typically showing command syntax or parameter information.
- Specified by:
setTailTipin interfaceLineReader- Parameters:
tailTip- the tail tip text to display, or null to clear the tail tip
-
runMacro
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:
-
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:
-
setCompleter
Set the completer.- Parameters:
completer- the completer to use
-
getCompleter
-
setHistory
-
getHistory
Description copied from interface:LineReaderReturns the history associated with this LineReader.The history stores previously entered command lines and provides methods for navigating, searching, and managing history entries.
- Specified by:
getHistoryin interfaceLineReader- Returns:
- the command history
-
setHighlighter
-
getHighlighter
Description copied from interface:LineReaderReturns the highlighter associated with this LineReader.The highlighter is responsible for applying syntax highlighting to the command line as the user types.
- Specified by:
getHighlighterin interfaceLineReader- Returns:
- the highlighter
-
getParser
Description copied from interface:LineReaderReturns the parser associated with this LineReader.The parser is responsible for breaking command lines into tokens according to the syntax rules of the shell or application.
- Specified by:
getParserin interfaceLineReader- Returns:
- the parser
-
setParser
-
getExpander
Description copied from interface:LineReaderReturns the expander associated with this LineReader.The expander is responsible for expanding special syntax in the command line, such as history references (e.g., !!, !$) and variables (e.g., $HOME).
- Specified by:
getExpanderin interfaceLineReader- Returns:
- the expander
-
setExpander
-
setCompletionMatcher
-
readLine
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
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
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
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:
-
printAbove
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:
-
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
Description copied from interface:LineReaderCalls a widget by name.Widgets are functions that perform editing operations. This method allows invoking a widget programmatically rather than through a key binding.
- Specified by:
callWidgetin interfaceLineReader- Parameters:
name- the name of the widget to call
-
redrawLine
public boolean redrawLine()Clear the line and redraw it.- Returns:
true
-
putString
Write out the specified string to the buffer and the output stream.- Parameters:
str- the char sequence to write in the buffer
-
flush
-
isKeyMap
-
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
-
doReadStringUntil
-
readBinding
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
-
readBinding
-
getParsedLine
Description copied from interface:LineReaderReturns the parsed representation of the current line.The parsed line contains the tokenized form of the current input line, broken down according to the syntax rules of the parser.
- Specified by:
getParsedLinein interfaceLineReader- Returns:
- the parsed line, or null if the line has not been parsed yet
-
getLastBinding
Description copied from interface:LineReaderReturns the last key binding that was processed.This is the string representation of the last key sequence that triggered an action.
- Specified by:
getLastBindingin interfaceLineReader- Returns:
- the last key binding, or null if no binding has been processed
-
getSearchTerm
Description copied from interface:LineReaderReturns the current search term when in history search mode.This is the string that the user is searching for in the command history.
- Specified by:
getSearchTermin interfaceLineReader- Returns:
- the current search term, or null if not in search mode
-
getRegionActive
Description copied from interface:LineReaderReturns the type of the currently active region selection.The region is a selected portion of text in the buffer, similar to a selection in a text editor.
- Specified by:
getRegionActivein interfaceLineReader- Returns:
- the type of the active region, or
LineReader.RegionType.NONEif no region is active
-
getRegionMark
public int getRegionMark()Description copied from interface:LineReaderReturns the mark position of the currently active region.The mark is one endpoint of the selected region, with the cursor being the other endpoint.
- Specified by:
getRegionMarkin interfaceLineReader- Returns:
- the position of the mark, or -1 if no region is active
-
setKeyMap
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
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
Description copied from interface:LineReaderSets a variable in the LineReader and returns the LineReader for method chaining.Variables control various aspects of the LineReader's behavior. See the various variable constants defined in this interface for available options.
- Specified by:
variablein interfaceLineReader- Parameters:
name- the variable namevalue- the variable value- Returns:
- this LineReader
-
getVariables
Description copied from interface:LineReaderReturns a map of all variables set in the LineReader.Variables control various aspects of the LineReader's behavior. See the various variable constants defined in this interface for available options.
- Specified by:
getVariablesin interfaceLineReader- Returns:
- a map of variable names to their values
-
getVariable
Description copied from interface:LineReaderReturns the value of a variable.Variables control various aspects of the LineReader's behavior. See the various variable constants defined in this interface for available options.
- Specified by:
getVariablein interfaceLineReader- Parameters:
name- the variable name- Returns:
- the variable value, or null if the variable is not set
-
setVariable
Description copied from interface:LineReaderSets a variable in the LineReader.Variables control various aspects of the LineReader's behavior. See the various variable constants defined in this interface for available options.
- Specified by:
setVariablein interfaceLineReader- Parameters:
name- the variable namevalue- the variable value
-
option
Description copied from interface:LineReaderSets an option in the LineReader and returns the LineReader for method chaining.Options control various aspects of the LineReader's behavior. See the
LineReader.Optionenum for available options.- Specified by:
optionin interfaceLineReader- Parameters:
option- the option to setvalue- the option value- Returns:
- this LineReader
-
isSet
Description copied from interface:LineReaderChecks if an option is set.Options control various aspects of the LineReader's behavior. See the
LineReader.Optionenum for available options.- Specified by:
isSetin interfaceLineReader- Parameters:
option- the option to check- Returns:
- true if the option is set, false otherwise
-
setOpt
Description copied from interface:LineReaderSets an option to true.Options control various aspects of the LineReader's behavior. See the
LineReader.Optionenum for available options.- Specified by:
setOptin interfaceLineReader- Parameters:
option- the option to set
-
unsetOpt
Description copied from interface:LineReaderSets an option to false.Options control various aspects of the LineReader's behavior. See the
LineReader.Optionenum for available options.- Specified by:
unsetOptin interfaceLineReader- Parameters:
option- the option to unset
-
addCommandsInBuffer
Description copied from interface:LineReaderAdds a collection of commands to the input buffer for execution.These commands will be executed one by one when the user accepts the current line. This is useful for implementing features like command scripts or macros.
- Specified by:
addCommandsInBufferin interfaceLineReader- Parameters:
commands- the commands to add to the buffer
-
editAndAddInBuffer
Description copied from interface:LineReaderOpens a file in an external editor and adds its contents to the input buffer.This method allows the user to edit a file in their preferred text editor and then have its contents added to the input buffer for execution.
- Specified by:
editAndAddInBufferin interfaceLineReader- Parameters:
file- the file to edit, or null to create a temporary file- Throws:
Exception- if an error occurs while editing the file
-
getTabWidth
protected int getTabWidth() -
finishBuffer
Clear the buffer and add its contents to the history.- Returns:
- the former contents of the buffer.
-
finish
-
handleSignal
-
getWidget
-
setPrompt
-
setRightPrompt
-
setBuffer
-
setBuffer
-
viDeleteChangeYankToRemap
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
-
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
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
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
-
searchForwards
-
searchForwards
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
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() -
builtinWidgets
-
redisplay
public boolean redisplay() -
redisplay
protected void redisplay(boolean flush) -
getDisplayedBufferWithPrompts
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() -
completePrefix
protected boolean completePrefix() -
listChoices
protected boolean listChoices() -
deleteCharOrList
protected boolean deleteCharOrList() -
doComplete
-
doComplete
protected boolean doComplete(LineReaderImpl.CompletionType lst, boolean useMenu, boolean prefix, boolean forSuggestion) -
wrap
-
getCandidateComparator
-
getOthersGroupName
-
getOriginalGroupName
-
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
-
computePost
-
toColumns
-
toColumns
protected void toColumns(Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, String completed, boolean rowsFirst, boolean doMenuList, int[] out) -
getCompletionStyleStarting
-
getCompletionStyleDescription
-
getCompletionStyleGroup
-
getCompletionStyleSelection
-
getCompletionStyleBackground
-
getCompletionStyleStarting
-
getCompletionStyleDescription
-
getCompletionStyleGroup
-
getCompletionStyleSelection
-
getCompletionStyleBackground
-
getCompletionStyleListStarting
-
getCompletionStyleListDescription
-
getCompletionStyleListGroup
-
getCompletionStyleListSelection
-
getCompletionStyleListBackground
-
getCompletionStyle
-
buildStyle
-
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
Description copied from interface:LineReaderReturns the default key maps used by the LineReader.These key maps define the standard key bindings for different editing modes such as Emacs mode, Vi command mode, Vi insert mode, etc.
- Specified by:
defaultKeyMapsin interfaceLineReader- Returns:
- a map of key map names to key maps
-
emacs
-
viInsertion
-
viCmd
-
safe
-
dumb
-
visual
-
viOpp
-
zeroOut
public void zeroOut()Description copied from interface:LineReaderClears any internal buffers and sensitive data.This method is used to ensure that sensitive information, such as passwords or other confidential data, is removed from memory when it's no longer needed. It should be called when the LineReader is no longer in use or before reading sensitive information.
- Specified by:
zeroOutin interfaceLineReader
-
DEFAULT_TAB_WIDTHandgetTabWidth()