Class AttributedStyle

java.lang.Object
org.jline.utils.AttributedStyle

public class AttributedStyle extends Object
Text styling for terminal output with support for colors, fonts, and other attributes.

The AttributedStyle class represents the styling attributes that can be applied to text in a terminal. It supports various text attributes such as bold, italic, underline, as well as foreground and background colors. The class uses a bit-packed long value to efficiently store multiple attributes.

This class provides a fluent API for building styles by chaining method calls. Styles are immutable, so each method returns a new instance with the requested modifications.

Color support includes:

  • 8 standard ANSI colors (black, red, green, yellow, blue, magenta, cyan, white)
  • 8 bright variants of the standard colors
  • 256-color indexed mode
  • 24-bit true color (RGB) mode

Text attributes include bold, faint, italic, underline, blink, inverse, conceal, and crossed-out.

Example usage:

 // Create a style with red foreground, bold, and underline
 AttributedStyle style = AttributedStyle.DEFAULT
     .foreground(AttributedStyle.RED)
     .bold()
     .underline();

 // Create a string with this style
 AttributedString str = new AttributedString("Error message", style);
 
See Also: