Package org.pkl.core.util
Class AnsiStringBuilder
java.lang.Object
org.pkl.core.util.AnsiStringBuilder
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char value) Append the string representation ofvalueto the string.append(int value) Append the string representation ofvalueto the string.Append the string representation ofvalueto the string.Appendvalueto the string.append(Set<AnsiStringBuilder.AnsiCode> codes, String value) Appendvalueto the string, ensuring it is formatted withcodes.append(AnsiStringBuilder.AnsiCode code, int value) Appendvalueto the string, ensuring it is formatted withcodes.append(AnsiStringBuilder.AnsiCode code, Runnable runnable) Applycodeto every appended element withinrunnable.append(AnsiStringBuilder.AnsiCode code, String value) Appendvalueto the string, ensuring it is formatted withcodes.appendUntrusted(String value) Append a string whose contents are unknown, and might contain ANSI color codes.Returns a fresh instance of this string builder.toString()Builds the data represented by this builder into aString.
-
Constructor Details
-
AnsiStringBuilder
public AnsiStringBuilder(boolean usingColor)
-
-
Method Details
-
append
Appendvalueto the string, ensuring it is formatted withcodes. -
append
Appendvalueto the string, ensuring it is formatted withcodes. -
append
Appendvalueto the string, ensuring it is formatted withcodes. -
append
Applycodeto every appended element withinrunnable.This is a helper method. With this:
- There is no need to repeat the same style for multiple appends in a row.
- The parent style is added to any styles added applied in the children.
For example, in the following snippet,
"hello"is formatted in both bold and red:var sb = new AnsiCodingStringBuilder(true); sb.append(AnsiCode.RED, () -> { sb.append(AnsiCode.BOLD, "hello"); });
-
appendUntrusted
Append a string whose contents are unknown, and might contain ANSI color codes.Always add a reset and re-apply all colors after appending the string.
-
append
Appendvalueto the string.If called within
append(AnsiCode, Runnable), applies any styles in the current context. -
append
Append the string representation ofvalueto the string.If called within
append(AnsiCode, Runnable), applies any styles in the current context. -
append
Append the string representation ofvalueto the string.If called within
append(AnsiCode, Runnable), applies any styles in the current context. -
append
Append the string representation ofvalueto the string.If called within
append(AnsiCode, Runnable), applies any styles in the current context. -
newInstance
Returns a fresh instance of this string builder. -
toPrintWriter
-
toString
Builds the data represented by this builder into aString.
-