Package net.kyori.ansi
Interface ANSIComponentRenderer<S>
-
- Type Parameters:
S
- style type
- All Known Subinterfaces:
ANSIComponentRenderer.ToString<S>
,ANSIComponentRenderer.ToStringBuilder<S>
@NonExtendable public interface ANSIComponentRenderer<S>
A renderer converting a flattened component into ANSI.Renderer instances are reusable, but are not thread-safe.
- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ANSIComponentRenderer.ToString<S>
A sub-interface that simply provides a string output.static interface
ANSIComponentRenderer.ToStringBuilder<S>
A mutable sub-interface that allows targeting an existing string builder.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull ANSIComponentRenderer<S>
complete()
Indicate to the renderer that a complete component has been provided, and any finalizing output should be appended.@NotNull ANSIComponentRenderer<S>
popStyle(S style)
Pop the top style from the stack, so it will no longer affect output.@NotNull ANSIComponentRenderer<S>
pushStyle(S style)
Push a style onto the stack to format upcoming invocations oftext(String)
.@NotNull ANSIComponentRenderer<S>
text(@NotNull java.lang.String text)
Append text to the buffer.static <T> @NotNull ANSIComponentRenderer.ToString<T>
toString(@NotNull StyleOps<T> ops)
Create a new renderer that produces aString
, with a color level inferred from the current environment.static <T> @NotNull ANSIComponentRenderer.ToString<T>
toString(@NotNull StyleOps<T> ops, @NotNull ColorLevel colorLevel)
Create a new renderer that produces aString
.static <T> @NotNull ANSIComponentRenderer.ToStringBuilder<T>
toStringBuilder(@NotNull StyleOps<T> ops)
Create a new renderer that will write to a specificStringBuilder
, with a color level inferred from the current environment.static <T> @NotNull ANSIComponentRenderer.ToStringBuilder<T>
toStringBuilder(@NotNull StyleOps<T> ops, @NotNull ColorLevel colorLevel)
Create a new renderer that will write to a specificStringBuilder
.
-
-
-
Method Detail
-
toString
@NotNull static <T> @NotNull ANSIComponentRenderer.ToString<T> toString(@NotNull @NotNull StyleOps<T> ops)
Create a new renderer that produces aString
, with a color level inferred from the current environment.- Type Parameters:
T
- the style type- Parameters:
ops
- an implementation that can work on certain styles.- Returns:
- the renderer
- Since:
- 1.0.0
-
toString
@NotNull static <T> @NotNull ANSIComponentRenderer.ToString<T> toString(@NotNull @NotNull StyleOps<T> ops, @NotNull @NotNull ColorLevel colorLevel)
Create a new renderer that produces aString
.- Type Parameters:
T
- the style type- Parameters:
ops
- an implementation that can work on certain styles.colorLevel
- the color support level to emit to- Returns:
- the renderer
- Since:
- 1.0.0
-
toStringBuilder
@NotNull static <T> @NotNull ANSIComponentRenderer.ToStringBuilder<T> toStringBuilder(@NotNull @NotNull StyleOps<T> ops)
Create a new renderer that will write to a specificStringBuilder
, with a color level inferred from the current environment.- Type Parameters:
T
- the style type- Parameters:
ops
- an implementation that can work on the provided style type- Returns:
- the renderer
- Since:
- 1.0.0
-
toStringBuilder
@NotNull static <T> @NotNull ANSIComponentRenderer.ToStringBuilder<T> toStringBuilder(@NotNull @NotNull StyleOps<T> ops, @NotNull @NotNull ColorLevel colorLevel)
Create a new renderer that will write to a specificStringBuilder
.- Type Parameters:
T
- the style type- Parameters:
ops
- an implementation that can work on the provided style typecolorLevel
- the color support level to emit to- Returns:
- the renderer
- Since:
- 1.0.0
-
pushStyle
@NotNull @NotNull ANSIComponentRenderer<S> pushStyle(@NotNull S style)
Push a style onto the stack to format upcoming invocations oftext(String)
.This push must be balanced by an equivalent pop where this style ceases to apply.
- Parameters:
style
- the style to apply- Returns:
- this renderer
- Throws:
java.lang.IllegalStateException
- if the style stack exceeds a depth of 1024- Since:
- 1.0.0
-
text
@NotNull @NotNull ANSIComponentRenderer<S> text(@NotNull @NotNull java.lang.String text)
Append text to the buffer.Any pending style will be emitted here as well.
- Parameters:
text
- text to append- Returns:
- this renderer
- Since:
- 1.0.0
-
popStyle
@NotNull @NotNull ANSIComponentRenderer<S> popStyle(@NotNull S style)
Pop the top style from the stack, so it will no longer affect output.- Parameters:
style
- the style to pop- Returns:
- this renderer
- Throws:
java.lang.IllegalStateException
- if attempting to pop when no style is remaining on the stack- Since:
- 1.0.0
-
complete
@NotNull @NotNull ANSIComponentRenderer<S> complete()
Indicate to the renderer that a complete component has been provided, and any finalizing output should be appended.- Returns:
- this renderer
- Since:
- 1.0.0
-
-