Text-style-type
TextStyle is the public value type used to describe foreground color, background color, and emphasis flags for formatter styling. It is a direct alias to the style model used by tag registries, formatter config maps, and inline-style resolution.
Interface
pub type TextStyle = @utils.TextStyleoutput
TextStyle- Public style value containingfg,bg,bold,dim,italic, andunderline.
Explanation
Detailed rules explaining key parameters and behaviors
- This is a type alias, not a formatter instance or registry.
- The current fields are
fg : String?,bg : String?,bold : Bool,dim : Bool,italic : Bool, andunderline : Bool. text_style(...)constructs this type as the normal handwritten entry point.- The same value type is stored in
StyleTagRegistryentries and inTextFormatterConfigstyle-tag maps.
How to Use
Here are some specific examples provided.
When Need A Typed Style Value For Reuse
When one style should be defined once and reused across tag registrations or config assembly:
let accent : TextStyle = text_style(fg=Some("#4cc9f0"), bold=true)In this example, the style stays as structured data instead of being tied to one formatter immediately.
When Need To Pass A Style Through Formatter Configuration
When style values should be assembled first and attached later:
let warning = text_style(fg=Some("yellow"), bold=true)In this example, the alias makes it explicit that the value can travel through config or registry code unchanged.
Error Case
e.g.:
TextStyleitself does not have a runtime failure mode.A style value can still produce no visible ANSI effect if the chosen formatter disables color or style markup.
Notes
Use
text_style(...)when you need a value of this type in code.Use
StyleTagRegistrywhen named reusable style lookup is needed instead of one standalone style value.