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:
StyleBundle
- Interface for proxy-based style bundlesStyleExpression
- Evaluates style expressionsStyleFactory
- Creates styled stringsStyleResolver
- Resolves named stylesStyleSource
- Interface for style storageStyler
- Facade for style operations
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
-
Interface Summary Interface Description StyleBundle Marker interface for proxy-based style bundles.StyleSource Interface for sources of style configuration. -
Class Summary Class Description InterpolationHelper Interpolation.MemoryStyleSource In-memory implementation ofStyleSource
.NopStyleSource A no-operation implementation ofStyleSource
that always returnsnull
.StyledWriter APrintWriter
extension that understands and evaluatesStyleExpression
syntax.StyleExpression Provides evaluation of style expressions in the format@{style value}
.StyleFactory Factory for creating styled strings using a specific style group.Styler Style facade that provides static utility methods for working with styles.StyleResolver Resolves named (or source-referenced)AttributedStyle
for a specific style group. -
Enum Summary Enum Description StyleColor Deprecated. useColors.rgbColor(String)
instead -
Annotation Types Summary Annotation Type Description StyleBundle.DefaultStyle Annotation that provides a default style specification for a method in a StyleBundle interface.StyleBundle.StyleGroup Annotation that specifies the style group name for a StyleBundle interface.StyleBundle.StyleName Annotation that allows overriding the style name for a method in a StyleBundle interface.