Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
uni20::presentation::text_style Class Reference

Callable style wrapper that builds styled presentation text. More...

#include <presentation.hpp>

Public Member Functions

styled_text operator() (char const *text) const
 Build a styled text span from literal text.
 
template<typename... Args>
requires (sizeof...(Args) > 0)
styled_text operator() (fmt::format_string< Args... > format, Args &&... args) const
 Format text with fmt and apply this style.
 
styled_text operator() (semantic_glyph glyph) const
 Build a styled semantic glyph span.
 
styled_text operator() (semantic_glyph glyph, char const *text) const
 Build a styled semantic glyph followed by styled literal text.
 
template<typename... Args>
requires (sizeof...(Args) > 0)
styled_text operator() (semantic_glyph glyph, fmt::format_string< Args... > format, Args &&... args) const
 Build a styled semantic glyph followed by formatted styled text.
 
styled_text operator() (semantic_glyph glyph, std::string_view text) const
 Build a styled semantic glyph followed by styled literal text.
 
styled_text operator() (std::string_view text) const
 Build a styled text span from literal text.
 
template<typename T >
requires (!std::is_convertible_v<T &&, std::string_view> && !std::same_as<std::remove_cvref_t<T>, semantic_glyph>)
styled_text operator() (T &&value) const
 Format one non-string value with fmt and apply this style.
 
terminal::TerminalStyle const & terminal_style () const noexcept
 Return the terminal style metadata carried by this wrapper.
 
 text_style ()=default
 Construct an empty style wrapper.
 
 text_style (char const *spec)
 Construct from a terminal style specification string.
 
 text_style (std::string_view spec)
 Construct from a terminal style specification string.
 
 text_style (terminal::TerminalStyle style)
 Construct from an existing terminal style.
 

Detailed Description

Callable style wrapper that builds styled presentation text.

text_style keeps style metadata attached to spans without rendering ANSI escape sequences. Final renderers still apply color, charset, glyph, and display-width policy.

Constructor & Destructor Documentation

◆ text_style() [1/4]

uni20::presentation::text_style::text_style ( )
default

Construct an empty style wrapper.

◆ text_style() [2/4]

uni20::presentation::text_style::text_style ( terminal::TerminalStyle  style)
inlineexplicit

Construct from an existing terminal style.

Parameters
styleTerminal style metadata to apply to generated spans.

◆ text_style() [3/4]

uni20::presentation::text_style::text_style ( std::string_view  spec)
inlineexplicit

Construct from a terminal style specification string.

Parameters
specStyle specification such as "Red;Bold".

◆ text_style() [4/4]

uni20::presentation::text_style::text_style ( char const *  spec)
inlineexplicit

Construct from a terminal style specification string.

Parameters
specStyle specification such as "Red;Bold".

Member Function Documentation

◆ operator()() [1/8]

styled_text uni20::presentation::text_style::operator() ( char const *  text) const
inline

Build a styled text span from literal text.

Parameters
textNull-terminated text payload encoded as UTF-8.
Returns
Styled presentation text.

◆ operator()() [2/8]

template<typename... Args>
requires (sizeof...(Args) > 0)
styled_text uni20::presentation::text_style::operator() ( fmt::format_string< Args... >  format,
Args &&...  args 
) const
inline

Format text with fmt and apply this style.

Template Parameters
ArgsFormat argument types.
Parameters
formatCompile-time checked format string.
argsFormat arguments.
Returns
Styled presentation text.

◆ operator()() [3/8]

styled_text uni20::presentation::text_style::operator() ( semantic_glyph  glyph) const
inline

Build a styled semantic glyph span.

Parameters
glyphSemantic glyph to render according to policy.
Returns
Styled presentation text.

◆ operator()() [4/8]

styled_text uni20::presentation::text_style::operator() ( semantic_glyph  glyph,
char const *  text 
) const
inline

Build a styled semantic glyph followed by styled literal text.

Parameters
glyphSemantic glyph to render according to policy.
textNull-terminated text payload encoded as UTF-8.
Returns
Styled presentation text.

◆ operator()() [5/8]

template<typename... Args>
requires (sizeof...(Args) > 0)
styled_text uni20::presentation::text_style::operator() ( semantic_glyph  glyph,
fmt::format_string< Args... >  format,
Args &&...  args 
) const
inline

Build a styled semantic glyph followed by formatted styled text.

Template Parameters
ArgsFormat argument types.
Parameters
glyphSemantic glyph to render according to policy.
formatCompile-time checked format string.
argsFormat arguments.
Returns
Styled presentation text.

◆ operator()() [6/8]

styled_text uni20::presentation::text_style::operator() ( semantic_glyph  glyph,
std::string_view  text 
) const
inline

Build a styled semantic glyph followed by styled literal text.

Parameters
glyphSemantic glyph to render according to policy.
textText payload encoded as UTF-8.
Returns
Styled presentation text.

◆ operator()() [7/8]

styled_text uni20::presentation::text_style::operator() ( std::string_view  text) const
inline

Build a styled text span from literal text.

Parameters
textText payload encoded as UTF-8.
Returns
Styled presentation text.

◆ operator()() [8/8]

template<typename T >
requires (!std::is_convertible_v<T &&, std::string_view> && !std::same_as<std::remove_cvref_t<T>, semantic_glyph>)
styled_text uni20::presentation::text_style::operator() ( T &&  value) const
inline

Format one non-string value with fmt and apply this style.

Template Parameters
TValue type.
Parameters
valueValue to format with the default {} formatter.
Returns
Styled presentation text.

◆ terminal_style()

terminal::TerminalStyle const & uni20::presentation::text_style::terminal_style ( ) const
inlinenoexcept

Return the terminal style metadata carried by this wrapper.

Returns
Terminal style metadata.

The documentation for this class was generated from the following file: