Interface ColorFormatter

All Known Implementing Classes:
AnsiColorFormatter

public interface ColorFormatter
Styles text using color codes.
See Also:
  • Method Details

    • style

      String style(String text, Style... styles)
      Styles text using the given styles.
      Parameters:
      text - Text to style.
      styles - Styles to apply.
      Returns:
      Returns the styled text.
    • style

      void style(Appendable appendable, String text, Style... styles)
      Styles text using the given styles and writes it to an Appendable.
      Parameters:
      appendable - Where to write styled text.
      text - Text to write.
      styles - Styles to apply.
    • println

      default void println(CliPrinter printer, String text, Style... styles)
      Print a styled line of text to the given printer.
      Parameters:
      printer - Printer to write to.
      text - Text to write.
      styles - Styles to apply.
    • printerBuffer

      default ColorFormatter.PrinterBuffer printerBuffer(CliPrinter printer)
      Creates a ColorFormatter.PrinterBuffer used to build up a long string of styled text.

      Call ColorFormatter.PrinterBuffer.close() or use try-with-resources to write to the printer.

      Returns:
      Returns the buffer.