Package org.jline.style

JLine Style package provides a comprehensive styling system for terminal output.

This package contains classes and interfaces for defining, managing, and applying styles to text displayed in the terminal. It supports:

  • Style specifications using a simple syntax (e.g., "bold,fg:red")
  • Named styles that can be referenced and reused
  • Style expressions with the format @{style text}
  • Style bundles using Java interfaces and proxies
  • Style sources for storing and retrieving style definitions

The styling system integrates with JLine's AttributedString and AttributedStyle classes to provide rich text formatting capabilities.

Key components of this package include:

Example usage:

 // Using StyleFactory
 StyleFactory factory = Styler.factory("mygroup");
 AttributedString text = factory.style("bold,fg:red", "Important message");

 // Using StyleExpression
 StyleExpression expr = new StyleExpression(Styler.resolver("mygroup"));
 AttributedString text = expr.evaluate("Normal text with @{bold,fg:red important} parts");

 // Using StyleBundle
 @StyleBundle.StyleGroup("mygroup")
 interface MyStyles extends StyleBundle {
     @DefaultStyle("bold,fg:red")
     AttributedString important(String text);
 }
 MyStyles styles = Styler.bundle(MyStyles.class);
 AttributedString text = styles.important("Important message");
 
Since:
3.4