Class Readline
java.lang.Object
org.aesh.readline.Readline
Readline is a simple way to read a single input line from the terminal/shell/console.
Readline reads/writes from/to a
Connection.
Readline is thread safe and will not accept new readline(Connection, String, Consumer) calls
while currently reading input.-
Constructor Summary
ConstructorsConstructorDescriptionReadline()Creates a new Readline instance with default edit mode, in-memory history, and simple completion handler.Creates a new Readline instance with the specified edit mode and in-memory history.Readline(EditMode editMode, History history, CompletionHandler completionHandler) Creates a new Readline instance with the specified edit mode, history, and completion handler. -
Method Summary
Modifier and TypeMethodDescriptionprotected InputProcessorReturns the current input processor.voidreadline(Connection conn, String prompt, Consumer<String> requestHandler) Reads a line of input from the connection with a string prompt.voidreadline(Connection conn, String prompt, Consumer<String> requestHandler, List<Completion> completions) Reads a line of input from the connection with a string prompt and completions.voidreadline(Connection conn, Prompt prompt, Consumer<String> requestHandler) Reads a line of input from the connection with a Prompt object.voidreadline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions) Reads a line of input from the connection with a Prompt object and completions.voidreadline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors) Reads a line of input from the connection with completions and pre-processors.voidreadline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors, History history) Reads a line of input from the connection with completions, pre-processors, and custom history.voidreadline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors, History history, CursorListener listener) Reads a line of input from the connection with completions, pre-processors, custom history, and cursor listener.voidreadline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors, History history, CursorListener listener, EnumMap<ReadlineFlag, Integer> flags) Reads a line of input from the connection with all configuration options.
-
Constructor Details
-
Readline
public Readline()Creates a new Readline instance with default edit mode, in-memory history, and simple completion handler. -
Readline
Creates a new Readline instance with the specified edit mode and in-memory history.- Parameters:
editMode- the edit mode to use (e.g., Emacs or Vi mode)
-
Readline
Creates a new Readline instance with the specified edit mode, history, and completion handler.- Parameters:
editMode- the edit mode to use (e.g., Emacs or Vi mode)history- the history implementation to use for command historycompletionHandler- the completion handler for tab completion, or null for default
-
-
Method Details
-
getInputProcessor
Returns the current input processor.- Returns:
- the input processor, or null if not currently reading input
-
readline
Reads a line of input from the connection with a string prompt.- Parameters:
conn- the terminal connection to read fromprompt- the prompt string to displayrequestHandler- the callback to receive the completed input line
-
readline
public void readline(Connection conn, String prompt, Consumer<String> requestHandler, List<Completion> completions) Reads a line of input from the connection with a string prompt and completions.- Parameters:
conn- the terminal connection to read fromprompt- the prompt string to displayrequestHandler- the callback to receive the completed input linecompletions- the list of completions for tab completion
-
readline
Reads a line of input from the connection with a Prompt object.- Parameters:
conn- the terminal connection to read fromprompt- the prompt to displayrequestHandler- the callback to receive the completed input line
-
readline
public void readline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions) Reads a line of input from the connection with a Prompt object and completions.- Parameters:
conn- the terminal connection to read fromprompt- the prompt to displayrequestHandler- the callback to receive the completed input linecompletions- the list of completions for tab completion
-
readline
public void readline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors) Reads a line of input from the connection with completions and pre-processors.- Parameters:
conn- the terminal connection to read fromprompt- the prompt to displayrequestHandler- the callback to receive the completed input linecompletions- the list of completions for tab completionpreProcessors- the list of input pre-processors
-
readline
public void readline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors, History history) Reads a line of input from the connection with completions, pre-processors, and custom history.- Parameters:
conn- the terminal connection to read fromprompt- the prompt to displayrequestHandler- the callback to receive the completed input linecompletions- the list of completions for tab completionpreProcessors- the list of input pre-processorshistory- the history instance to use for this readline operation
-
readline
public void readline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors, History history, CursorListener listener) Reads a line of input from the connection with completions, pre-processors, custom history, and cursor listener.- Parameters:
conn- the terminal connection to read fromprompt- the prompt to displayrequestHandler- the callback to receive the completed input linecompletions- the list of completions for tab completionpreProcessors- the list of input pre-processorshistory- the history instance to use for this readline operationlistener- the cursor listener to receive cursor movement events
-
readline
public void readline(Connection conn, Prompt prompt, Consumer<String> requestHandler, List<Completion> completions, List<Function<String, Optional<String>>> preProcessors, History history, CursorListener listener, EnumMap<ReadlineFlag, Integer> flags) Reads a line of input from the connection with all configuration options.- Parameters:
conn- the terminal connection to read fromprompt- the prompt to displayrequestHandler- the callback to receive the completed input linecompletions- the list of completions for tab completionpreProcessors- the list of input pre-processorshistory- the history instance to use for this readline operationlistener- the cursor listener to receive cursor movement eventsflags- the readline flags controlling behavior- Throws:
IllegalStateException- if already reading a line
-