Interface ANSIComponentRenderer<S>

    • Method Detail

      • toString

        @NotNull
        static <T> @NotNull ANSIComponentRenderer.ToString<T> toString​(@NotNull
                                                                       @NotNull StyleOps<T> ops)
        Create a new renderer that produces a String, 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 a String.
        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 specific StringBuilder, 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 specific StringBuilder.
        Type Parameters:
        T - the style type
        Parameters:
        ops - an implementation that can work on the provided style type
        colorLevel - 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 of text(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