Class StyledWriter

java.lang.Object
java.io.Writer
java.io.PrintWriter
org.jline.style.StyledWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class StyledWriter extends PrintWriter
A PrintWriter extension that understands and evaluates StyleExpression syntax.

This class extends PrintWriter to provide automatic evaluation of style expressions in the format @{style value} when writing strings. It uses a StyleExpression to evaluate the expressions and a Terminal to convert the resulting AttributedStrings to ANSI escape sequences appropriate for the terminal.

Example usage:

 Terminal terminal = ...; // Get a Terminal instance
 StyleResolver resolver = Styler.resolver("mygroup");

 // Create a StyledWriter that writes to System.out
 StyledWriter writer = new StyledWriter(System.out, terminal, resolver, true);

 // Write styled text
 writer.println("Normal text with @{bold,fg:red important} parts");
 writer.printf("@{bold %s}: @{fg:blue %s}", "Name", "John Doe");
 
Since:
3.4
See Also: