Multiple formatters can be concatenated together. This is useful for when you want to format a string that has multiple parts that need to be formatted differently.
| Modifier and Type | Field and Description |
|---|---|
| private @Nullable Color | |
| private @Nullable String | |
| private final @NotNull List | concatList
A list of all the values that should be concatenated to this formatter. |
| private @NotNull String | |
| public static boolean | debug
When set to |
| public static @NotNull Color | defaultColor
The default color that should be used when no foreground color is specified (if |
| public static boolean | enableSequences
When set to |
| private @Nullable Color | |
| private final @NotNull ArrayList | formatOptions
A list of all the formatting options that should be applied to the text. |
| private @Nullable TextFormatter | parent
The parent formatter. |
| public static boolean | startWithDefaultColorIfNotDefined
When set to |
| Access | Constructor and Description |
|---|---|
| protected | TextFormatter(@NotNull String
The contents of the formatter. contents)Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public TextFormatter | addFormat(@NotNull FormatOption...
The formatting options to add. options)Adds the specified formatting options to the formatter. |
| public TextFormatter | |
| private void | concatFormatter(@NotNull TextFormatter
The formatter to concatenate. formatter)Properly concatenates the specified formatter to this formatter by also linking both formatters together. |
| public static TextFormatter | Returns: a newTextFormatter with empty contentsCreates a new |
| public static @NotNull TextFormatter | Returns: a newTextFormatter with the specified contents and the error formattingThe contents of the formatter. msg)Returns a new |
| private @NotNull String | Returns: the end sequences to add to the contents of the formatterReturns the end sequences to add to the contents of the formatter. |
| private @Nullable Color | Returns: theColor that should properly reset the background colorReturns the |
| private @Nullable Color | Returns: theColor that should properly reset the foreground colorReturns the |
| public static @NotNull String | Returns: a string with a terminal sequence with the specified valuesThe values to add to the terminal sequence. values)Returns a string with a terminal sequence with the specified values, separated by a semicolon. |
| private @NotNull String | Returns: the start sequences to add to the contents of the formatterReturns the start sequences to add to the contents of the formatter. |
| public static boolean | Returns: true if the terminal supports colorReturns whether there is an environment variable that specifies that the terminal does not support color. |
| public boolean | Returns: true if the formatter has no formatting options, no foreground color, and no background colorReturns whether the formatter has no formatting options, no foreground color, and no background color. |
| public boolean | |
| public static TextFormatter | of(@NotNull String
The contents of the formatter. contents)Creates a new |
| public static TextFormatter | |
| public static TextFormatter | |
| public TextFormatter | removeFormat(@NotNull FormatOption...
The formatting options to remove. options)Removes the specified formatting options from the formatter. |
| public @NotNull String | toString()
Overrides java. Creates a new |
| public TextFormatter | withBackgroundColor(@Nullable Color
The background color of the formatter. background)Sets the background color of the formatter. |
| public TextFormatter | withColors(@Nullable Color
The foreground color of the formatter. foreground, @Nullable Color The background color of the formatter. background)Sets the foreground and background color of the formatter. |
| public TextFormatter | withConcatGap(@Nullable String
The gap between concatenated formatters. gap)Sets the gap between concatenated formatters. |
| public TextFormatter | withContents(@NotNull String
The contents of the formatter. contents)Sets the contents of the formatter. |
| public TextFormatter | withForegroundColor(@Nullable Color
The foreground color of the formatter. foreground)Sets the foreground color of the formatter. |
| backgroundColor | back to summary |
|---|---|
| private @Nullable Color backgroundColor
| |
| concatGap | back to summary |
|---|---|
| private @Nullable String concatGap
| |
| concatList | back to summary |
|---|---|
| private final @NotNull List<Object> concatList A list of all the values that should be concatenated to this formatter. | |
| contents | back to summary |
|---|---|
| private @NotNull String contents
| |
| debug | back to summary |
|---|---|
| public static boolean debug When set to | |
| defaultColor | back to summary |
|---|---|
| public static @NotNull Color defaultColor The default color that should be used when no foreground color is specified (if | |
| enableSequences | back to summary |
|---|---|
| public static boolean enableSequences When set to
This will be set to
| |
| foregroundColor | back to summary |
|---|---|
| private @Nullable Color foregroundColor
| |
| formatOptions | back to summary |
|---|---|
| private final @NotNull ArrayList<FormatOption> formatOptions A list of all the formatting options that should be applied to the text. | |
| parent | back to summary |
|---|---|
| private @Nullable TextFormatter parent The parent formatter. Used when being concatenated to another formatter. | |
| startWithDefaultColorIfNotDefined | back to summary |
|---|---|
| public static boolean startWithDefaultColorIfNotDefined When set to | |
| TextFormatter | back to summary |
|---|---|
| protected TextFormatter(@NotNull String contents) Creates a new | |
| addFormat | back to summary |
|---|---|
| public TextFormatter addFormat(@NotNull FormatOption... options) Adds the specified formatting options to the formatter.
| |
| concat | back to summary |
|---|---|
| public TextFormatter concat(@NotNull Object... objects) Concatenates the specified values to the formatter. Another | |
| concatFormatter | back to summary |
|---|---|
| private void concatFormatter(@NotNull TextFormatter formatter) Properly concatenates the specified formatter to this formatter by also linking both formatters together.
| |
| create | back to summary |
|---|---|
| public static TextFormatter create() Creates a new
| |
| error | back to summary |
|---|---|
| public static @NotNull TextFormatter error(@NotNull String msg) Returns a new The error formatting is a bold, black text with a bright red background.
| |
| getEndSequences | back to summary |
|---|---|
| private @NotNull String getEndSequences() Returns the end sequences to add to the contents of the formatter. This should properly reset the foreground color, the background color, and all the formatting options. | |
| getResetBgColor | back to summary |
|---|---|
| private @Nullable Color getResetBgColor() Returns the | |
| getResetFgColor | back to summary |
|---|---|
| private @Nullable Color getResetFgColor() Returns the | |
| getSequence | back to summary |
|---|---|
| public static @NotNull String getSequence(@NotNull Object... values) Returns a string with a terminal sequence with the specified values, separated by a semicolon.
(e.g.
If enableSequences is set to false, then an empty string will be returned.
| |
| getStartSequences | back to summary |
|---|---|
| private @NotNull String getStartSequences() Returns the start sequences to add to the contents of the formatter. This includes the foreground color, the background color, and all the formatting options. | |
| isColorDisabledEnv | back to summary |
|---|---|
| public static boolean isColorDisabledEnv() Returns whether there is an environment variable that specifies that the terminal does not support color. NO_COLOR.org
| |
| isFormattingNotDefined | back to summary |
|---|---|
| public boolean isFormattingNotDefined() Returns whether the formatter has no formatting options, no foreground color, and no background color.
| |
| isSimple | back to summary |
|---|---|
| public boolean isSimple() Returns whether the formatter is simple. A formatter is simple if it has no formatting options, no foreground color, no background color, and no concatenated formatters.
| |
| of | back to summary |
|---|---|
| public static TextFormatter of(@NotNull String contents) Creates a new | |
| of | back to summary |
|---|---|
| public static TextFormatter of(@NotNull String contents, @NotNull Color foreground) Creates a new | |
| of | back to summary |
|---|---|
| public static TextFormatter of(@NotNull String contents, @NotNull Color foreground, @NotNull Color background) Creates a new | |
| removeFormat | back to summary |
|---|---|
| public TextFormatter removeFormat(@NotNull FormatOption... options) Removes the specified formatting options from the formatter.
| |
| toString | back to summary |
|---|---|
| public @NotNull String toString() Overrides java. Creates a new | |
| withBackgroundColor | back to summary |
|---|---|
| public TextFormatter withBackgroundColor(@Nullable Color background) Sets the background color of the formatter. | |
| withColors | back to summary |
|---|---|
| public TextFormatter withColors(@Nullable Color foreground, @Nullable Color background) Sets the foreground and background color of the formatter. | |
| withConcatGap | back to summary |
|---|---|
| public TextFormatter withConcatGap(@Nullable String gap) Sets the gap between concatenated formatters.
By default, this is | |
| withContents | back to summary |
|---|---|
| public TextFormatter withContents(@NotNull String contents) Sets the contents of the formatter. | |
| withForegroundColor | back to summary |
|---|---|
| public TextFormatter withForegroundColor(@Nullable Color foreground) Sets the foreground color of the formatter. | |