Class Prompt
java.lang.Object
org.aesh.readline.Prompt
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
ConstructorsConstructorDescriptionPrompt()Creates an empty prompt.Creates a prompt with the specified code points and input masking character.Creates a prompt with the specified text.Creates a prompt with the specified text and input masking character.Creates a prompt with the specified text and ANSI formatting.Creates a prompt with the specified text, ANSI formatting, and input masking character.Prompt(List<TerminalCharacter> characters) 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.Creates a copy of the specified prompt.Prompt(TerminalString terminalString) Creates a prompt from a TerminalString with ANSI formatting. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of this prompt.booleanint[]getANSI()Returns the ANSI-formatted prompt string, or the plain prompt if no ANSI formatting exists.intReturns the length of the prompt in characters.getMask()Returns the masking character used for hiding input.int[]Returns the prompt text as an array of Unicode code points.booleanhasANSI()Checks if the prompt has ANSI formatting.inthashCode()booleanChecks if input masking is enabled.
-
Constructor Details
-
Prompt
public Prompt()Creates an empty prompt. -
Prompt
Creates a prompt with the specified text.- Parameters:
prompt- the prompt text, or null for an empty prompt
-
Prompt
Creates a copy of the specified prompt.- Parameters:
prompt- the prompt to copy
-
Prompt
-
Prompt
-
Prompt
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 promptansiString- the ANSI-formatted string for displaymask- the character to use for masking input (e.g., for passwords)
-
Prompt
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 promptmask- the character to use for masking input (e.g., for passwords)
-
Prompt
Creates a prompt from a TerminalString with ANSI formatting.- Parameters:
terminalString- the terminal string containing the prompt, or null for an empty prompt
-
Prompt
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
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 promptmask- the character to use for masking input (e.g., for passwords)
-
-
Method Details
-
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
Creates a copy of this prompt.- Returns:
- a new Prompt instance with the same values
-
equals
-
hashCode
-