Class CompletionHandler<C extends CompleteOperation>

java.lang.Object
org.aesh.readline.completion.CompletionHandler<C>
Type Parameters:
C - the type of complete operation this handler works with
Direct Known Subclasses:
SimpleCompletionHandler

public abstract class CompletionHandler<C extends CompleteOperation> extends Object
Abstract handler that manages tab-completion for command line input.
Author:
Ståle W. Pedersen
  • Constructor Details

    • CompletionHandler

      public CompletionHandler()
      Creates a new CompletionHandler with an empty completion list.
  • Method Details

    • addCompletion

      public void addCompletion(Completion completion)
      Adds a completion to the completion list.
      Parameters:
      completion - the completion to add
    • removeCompletion

      public void removeCompletion(Completion completion)
      Removes a completion from the completion list.
      Parameters:
      completion - the completion to remove
    • clear

      public void clear()
      Clears all completions from the completion list.
    • completionStatus

      public CompletionHandler.CompletionStatus completionStatus()
      Returns the current completion status.
      Returns:
      the current completion status
    • setCompletionStatus

      public void setCompletionStatus(CompletionHandler.CompletionStatus status)
      Sets the completion status.
      Parameters:
      status - the completion status to set
    • setAskCompletionSize

      public void setAskCompletionSize(int size)
      Sets the size threshold for asking before displaying completions.
      Parameters:
      size - the number of completions that triggers confirmation
    • getAskCompletionSize

      public int getAskCompletionSize()
      Returns the size threshold for asking before displaying completions.
      Returns:
      the completion size threshold
    • setAliasHandler

      public void setAliasHandler(Function<Buffer,C> aliasHandler)
      Sets the alias handler function for buffer completion.
      Parameters:
      aliasHandler - the function to handle alias expansion
    • addCompletions

      public void addCompletions(List<Completion> completions)
      Adds a list of completions to the completion list.
      Parameters:
      completions - the list of completions to add
    • createCompleteOperation

      public abstract C createCompleteOperation(String buffer, int cursor)
      Creates a complete operation for the given buffer and cursor position.
      Parameters:
      buffer - the input buffer string
      cursor - the cursor position in the buffer
      Returns:
      the complete operation instance
    • complete

      public void complete(InputProcessor inputProcessor)
      Display possible completions. 1. Find all possible completions 2. If we find only one, display it. 3. If we find more than one, display them, but not more than 100 at once
      Parameters:
      inputProcessor - the input processor handling the completion
    • findStartsWithOperation

      public static String findStartsWithOperation(List<? extends CompleteOperation> coList)
      If there is any common start string in the completion list, return it
      Parameters:
      coList - completion list
      Returns:
      common start string