Class Prompt

java.lang.Object
org.aesh.readline.Prompt

public class Prompt extends Object
The Prompt: If created with a String value that value will be the prompt with the default back and foreground colors. If created with TerminalCharacters the colors can be set individually.
Author:
Ståle W. Pedersen
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty prompt.
    Prompt(int[] prompt, Character mask)
    Creates a prompt with the specified code points and input masking character.
    Prompt(String prompt)
    Creates a prompt with the specified text.
    Prompt(String prompt, Character mask)
    Creates a prompt with the specified text and input masking character.
    Prompt(String prompt, String ansiString)
    Creates a prompt with the specified text and ANSI formatting.
    Prompt(String prompt, String ansiString, Character mask)
    Creates a prompt with the specified text, ANSI formatting, and input masking character.
    Creates a prompt from a list of terminal characters with individual formatting.
    Prompt(List<TerminalCharacter> characters, Character mask)
    Creates a prompt from a list of terminal characters with individual formatting and an input masking character.
    Prompt(Prompt prompt)
    Creates a copy of the specified prompt.
    Prompt(TerminalString terminalString)
    Creates a prompt from a TerminalString with ANSI formatting.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a copy of this prompt.
    boolean
     
    int[]
    Returns the ANSI-formatted prompt string, or the plain prompt if no ANSI formatting exists.
    int
    Returns the length of the prompt in characters.
    Returns the masking character used for hiding input.
    int[]
    Returns the prompt text as an array of Unicode code points.
    boolean
    Checks if the prompt has ANSI formatting.
    int
     
    boolean
    Checks if input masking is enabled.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Prompt

      public Prompt()
      Creates an empty prompt.
    • Prompt

      public Prompt(String prompt)
      Creates a prompt with the specified text.
      Parameters:
      prompt - the prompt text, or null for an empty prompt
    • Prompt

      public Prompt(Prompt prompt)
      Creates a copy of the specified prompt.
      Parameters:
      prompt - the prompt to copy
    • Prompt

      public Prompt(String prompt, String ansiString)
      Creates a prompt with the specified text and ANSI formatting.
      Parameters:
      prompt - the prompt text for length calculation, or null for an empty prompt
      ansiString - the ANSI-formatted string for display
    • Prompt

      public Prompt(String prompt, Character mask)
      Creates a prompt with the specified text and input masking character.
      Parameters:
      prompt - the prompt text, or null for an empty prompt
      mask - the character to use for masking input (e.g., for passwords)
    • Prompt

      public Prompt(String prompt, String ansiString, Character mask)
      Creates a prompt with the specified text, ANSI formatting, and input masking character.
      Parameters:
      prompt - the prompt text for length calculation, or null for an empty prompt
      ansiString - the ANSI-formatted string for display
      mask - the character to use for masking input (e.g., for passwords)
    • Prompt

      public Prompt(int[] prompt, Character mask)
      Creates a prompt with the specified code points and input masking character.
      Parameters:
      prompt - the prompt as an array of Unicode code points, or null for an empty prompt
      mask - the character to use for masking input (e.g., for passwords)
    • Prompt

      public Prompt(TerminalString terminalString)
      Creates a prompt from a TerminalString with ANSI formatting.
      Parameters:
      terminalString - the terminal string containing the prompt, or null for an empty prompt
    • Prompt

      public Prompt(List<TerminalCharacter> characters)
      Creates a prompt from a list of terminal characters with individual formatting.
      Parameters:
      characters - the list of terminal characters that make up the prompt
    • Prompt

      public Prompt(List<TerminalCharacter> characters, Character mask)
      Creates a prompt from a list of terminal characters with individual formatting and an input masking character.
      Parameters:
      characters - the list of terminal characters that make up the prompt
      mask - the character to use for masking input (e.g., for passwords)
  • Method Details

    • getMask

      public Character getMask()
      Returns the masking character used for hiding input.
      Returns:
      the mask character, or null if masking is not enabled
    • isMasking

      public boolean isMasking()
      Checks if input masking is enabled.
      Returns:
      true if a mask character is set, false otherwise
    • getPromptAsString

      public int[] getPromptAsString()
      Returns the prompt text as an array of Unicode code points.
      Returns:
      the prompt as code points
    • getLength

      public int getLength()
      Returns the length of the prompt in characters.
      Returns:
      the prompt length
    • hasANSI

      public boolean hasANSI()
      Checks if the prompt has ANSI formatting.
      Returns:
      true if ANSI formatting is present, false otherwise
    • getANSI

      public int[] getANSI()
      Returns the ANSI-formatted prompt string, or the plain prompt if no ANSI formatting exists.
      Returns:
      the ANSI string as code points, or the plain prompt if no ANSI formatting
    • copy

      public Prompt copy()
      Creates a copy of this prompt.
      Returns:
      a new Prompt instance with the same values
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object