Class Readline

java.lang.Object
org.aesh.readline.Readline

public class Readline extends Object
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 Details

    • Readline

      public Readline()
      Creates a new Readline instance with default edit mode, in-memory history, and simple completion handler.
    • Readline

      public Readline(EditMode editMode)
      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

      public Readline(EditMode editMode, History history, CompletionHandler completionHandler)
      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 history
      completionHandler - the completion handler for tab completion, or null for default
  • Method Details

    • getInputProcessor

      protected InputProcessor getInputProcessor()
      Returns the current input processor.
      Returns:
      the input processor, or null if not currently reading input
    • readline

      public void readline(Connection conn, String prompt, Consumer<String> requestHandler)
      Reads a line of input from the connection with a string prompt.
      Parameters:
      conn - the terminal connection to read from
      prompt - the prompt string to display
      requestHandler - 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 from
      prompt - the prompt string to display
      requestHandler - the callback to receive the completed input line
      completions - the list of completions for tab completion
    • readline

      public void readline(Connection conn, Prompt prompt, Consumer<String> requestHandler)
      Reads a line of input from the connection with a Prompt object.
      Parameters:
      conn - the terminal connection to read from
      prompt - the prompt to display
      requestHandler - 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 from
      prompt - the prompt to display
      requestHandler - the callback to receive the completed input line
      completions - 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 from
      prompt - the prompt to display
      requestHandler - the callback to receive the completed input line
      completions - the list of completions for tab completion
      preProcessors - 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 from
      prompt - the prompt to display
      requestHandler - the callback to receive the completed input line
      completions - the list of completions for tab completion
      preProcessors - the list of input pre-processors
      history - 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 from
      prompt - the prompt to display
      requestHandler - the callback to receive the completed input line
      completions - the list of completions for tab completion
      preProcessors - the list of input pre-processors
      history - the history instance to use for this readline operation
      listener - 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 from
      prompt - the prompt to display
      requestHandler - the callback to receive the completed input line
      completions - the list of completions for tab completion
      preProcessors - the list of input pre-processors
      history - the history instance to use for this readline operation
      listener - the cursor listener to receive cursor movement events
      flags - the readline flags controlling behavior
      Throws:
      IllegalStateException - if already reading a line