Class AttributedCharSequence

java.lang.Object
org.jline.utils.AttributedCharSequence
All Implemented Interfaces:
CharSequence
Direct Known Subclasses:
AttributedString, AttributedStringBuilder

public abstract class AttributedCharSequence extends Object implements CharSequence
A character sequence with ANSI style attributes.

The AttributedCharSequence class is an abstract base class for character sequences that have ANSI style attributes (colors, bold, underline, etc.) associated with each character. It provides methods for rendering the character sequence with its attributes to various outputs, such as ANSI terminals, non-ANSI terminals, and plain text.

This class serves as the foundation for styled text in JLine, allowing for rich text formatting in terminal applications. It is extended by concrete classes like AttributedString and AttributedStringBuilder that provide specific implementations for different use cases.

The class provides methods to:

  • Convert the sequence to a plain string without attributes
  • Render the sequence with ANSI escape codes for compatible terminals
  • Render the sequence for terminals with limited attribute support
  • Calculate the visible length of the sequence (excluding escape codes)
  • Extract substrings while preserving attributes