public class CommandLine.Help.Ansi.Text extends Object implements Cloneable
@|bg(red),white,underline some text|@
, and this class converts the markup to ANSI
escape codes.
Internally keeps both an enriched and a plain text representation to allow layout components to calculate text width while remaining unaware of the embedded ANSI escape codes.
Constructor and Description |
---|
Text(CommandLine.Help.Ansi.Text other)
Copy constructor.
|
Text(int maxLength)
Constructs a Text with the specified max length (for use in a TextTable Column).
|
Text(int maxLength,
CommandLine.Help.ColorScheme colorScheme)
Constructs a Text with the specified max length (for use in a TextTable Column).
|
Text(String input)
Constructs a Text with the specified String, which may contain markup like
@|bg(red),white,underline some text|@ . |
Text(String input,
CommandLine.Help.ColorScheme colorScheme)
Constructs a Text with the specified String (which may contain markup), and ColorScheme.
|
Modifier and Type | Method and Description |
---|---|
CommandLine.Help.Ansi.Text |
append(CommandLine.Help.Ansi.Text text)
Deprecated.
use
concat(CommandLine.Help.Ansi.Text) instead |
CommandLine.Help.Ansi.Text |
append(String string)
Deprecated.
use
concat(String) instead |
Object |
clone() |
CommandLine.Help.Ansi.Text |
concat(CommandLine.Help.Ansi.Text other)
Returns a copy of this
Text instance with the specified text concatenated to the end. |
CommandLine.Help.Ansi.Text |
concat(String string)
Returns a copy of this
Text instance with the specified text concatenated to the end. |
boolean |
equals(Object obj) |
int |
getCJKAdjustedLength()
Returns the number of columns this Text will occupy on the console, adjusted for wide CJK characters.
|
int |
getCJKAdjustedLength(int fromPosition,
int charCount)
Returns the number of columns that the specified portion of this Text will occupy on the console, adjusted for wide CJK characters.
|
void |
getStyledChars(int from,
int length,
CommandLine.Help.Ansi.Text destination,
int offset)
Copies the specified substring of this Text into the specified destination, preserving the markup.
|
int |
hashCode() |
String |
plainString()
Returns the plain text without any formatting.
|
CommandLine.Help.Ansi.Text[] |
splitLines() |
CommandLine.Help.Ansi.Text |
substring(int start)
Returns a new
Text instance that is a substring of this Text. |
CommandLine.Help.Ansi.Text |
substring(int start,
int end)
Returns a new
Text instance that is a substring of this Text. |
String |
toString()
Returns a String representation of the text with ANSI escape codes embedded, unless ANSI is
CommandLine.Help.Ansi.enabled() not enabled}, in which case the plain text is returned.
|
public Text(int maxLength)
maxLength
- max length of this textpublic Text(int maxLength, CommandLine.Help.ColorScheme colorScheme)
maxLength
- max length of this textcolorScheme
- the colorScheme to usepublic Text(CommandLine.Help.Ansi.Text other)
public Text(String input)
@|bg(red),white,underline some text|@
.input
- the string with markup to parsepublic Text(String input, CommandLine.Help.ColorScheme colorScheme)
input
- the string with markup like @|bg(red),white,underline some text|@
to parsecolorScheme
- the ColorScheme to use to map markup to replacement stringspublic CommandLine.Help.Ansi.Text[] splitLines()
public CommandLine.Help.Ansi.Text substring(int start)
Text
instance that is a substring of this Text. Does not modify this instance!start
- index in the plain text where to start the substringpublic CommandLine.Help.Ansi.Text substring(int start, int end)
Text
instance that is a substring of this Text. Does not modify this instance!start
- index in the plain text where to start the substringend
- index in the plain text where to end the substring@Deprecated public CommandLine.Help.Ansi.Text append(String string)
concat(String)
instead@Deprecated public CommandLine.Help.Ansi.Text append(CommandLine.Help.Ansi.Text text)
concat(CommandLine.Help.Ansi.Text)
insteadpublic CommandLine.Help.Ansi.Text concat(String string)
Text
instance with the specified text concatenated to the end. Does not modify this instance!string
- the text to concatenate to the end of this Textpublic CommandLine.Help.Ansi.Text concat(CommandLine.Help.Ansi.Text other)
Text
instance with the specified text concatenated to the end. Does not modify this instance!other
- the text to concatenate to the end of this Textpublic void getStyledChars(int from, int length, CommandLine.Help.Ansi.Text destination, int offset)
from
- start of the substringlength
- length of the substringdestination
- destination Text to modifyoffset
- indentation (padding)public String plainString()
public String toString()
public int getCJKAdjustedLength()
public int getCJKAdjustedLength(int fromPosition, int charCount)
fromPosition
- the position to start countingcharCount
- the number of characters in this Text to consider