template<class F = NoColorT, class B = NoColorT>
Rodin::Alert::Text class

Templated text class with foreground and background color support.

Template parameters
F Foreground color type (defaults to NoColorT).
B Background color type (defaults to NoColorT).

A flexible text formatting class that supports foreground colors, background colors, and various text attributes for rich terminal output. The class uses template parameters to specify color types at compile time for type safety.

Example usage:

auto redText = Text<RedT>("Error message");
auto boldText = Text("Important").setBold();
auto styledText = Text<RedT, BlueT>(RedT{}, BlueT{}, "Styled text");

Public types

using Foreground = F
Foreground color type alias.
using Background = B
Background color type alias.

Constructors, destructors, conversion operators

Text(const char* text)
Constructs text from a C-style string.
Text(const Foreground& fg, const char* text)
Constructs text with foreground color from a C-style string.
Text(const Foreground& fg, const Background& bg, const char* text)
Constructs text with foreground and background colors from a C-style string.
Text(const std::string& text)
Constructs text from a string.
Text(const Foreground& fg, const std::string& text)
Constructs text with foreground color from a string.
Text(const Foreground& fg, const Background& bg, const std::string& text)
Constructs text with foreground and background colors from a string.

Public functions

auto Text(const Text&) -> constexpr defaulted constexpr
Copy constructor.
auto Text(Text&&) -> constexpr defaulted constexpr
Move constructor.
auto getString() const -> const std::string&
Gets the text string content.
auto getForeground() const -> const Foreground&
Gets the foreground color.
auto getBackground() const -> const Background&
Gets the background color.
auto setAttribute(Attribute a) -> Text&
Sets a text formatting attribute.
auto setBold() -> Text&
Sets bold text formatting.
auto setDark() -> Text&
Sets dark text formatting.
auto setItalic() -> Text&
Sets italic text formatting.
auto setUnderline() -> Text&
Sets underlined text formatting.
auto setBlink() -> Text&
Sets blinking text effect.
auto setReverse() -> Text&
Sets reverse video formatting (inverted colors).
auto setConcealed() -> Text&
Sets concealed/hidden text formatting.
auto setCrossed() -> Text&
Sets crossed-out text formatting.
auto getAttributes() const -> const FlatSet<Attribute>&
Gets the set of applied text attributes.

Function documentation

template<class F, class B>
Rodin::Alert::Text<F, B>::Text(const char* text)

Constructs text from a C-style string.

Parameters
text The text content as a null-terminated string.

template<class F, class B>
Rodin::Alert::Text<F, B>::Text(const Foreground& fg, const char* text)

Constructs text with foreground color from a C-style string.

Parameters
fg The foreground color.
text The text content as a null-terminated string.

template<class F, class B>
Rodin::Alert::Text<F, B>::Text(const Foreground& fg, const Background& bg, const char* text)

Constructs text with foreground and background colors from a C-style string.

Parameters
fg The foreground color.
bg The background color.
text The text content as a null-terminated string.

template<class F, class B>
Rodin::Alert::Text<F, B>::Text(const std::string& text)

Constructs text from a string.

Parameters
text The text content as a std::string.

template<class F, class B>
Rodin::Alert::Text<F, B>::Text(const Foreground& fg, const std::string& text)

Constructs text with foreground color from a string.

Parameters
fg The foreground color.
text The text content as a std::string.

template<class F, class B>
Rodin::Alert::Text<F, B>::Text(const Foreground& fg, const Background& bg, const std::string& text)

Constructs text with foreground and background colors from a string.

Parameters
fg The foreground color.
bg The background color.
text The text content as a std::string.

template<class F, class B>
const std::string& Rodin::Alert::Text<F, B>::getString() const

Gets the text string content.

Returns Const reference to the text string.

template<class F, class B>
const Foreground& Rodin::Alert::Text<F, B>::getForeground() const

Gets the foreground color.

Returns Const reference to the foreground color.

template<class F, class B>
const Background& Rodin::Alert::Text<F, B>::getBackground() const

Gets the background color.

Returns Const reference to the background color.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setAttribute(Attribute a)

Sets a text formatting attribute.

Parameters
a The attribute to set.
Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setBold()

Sets bold text formatting.

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setDark()

Sets dark text formatting.

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setItalic()

Sets italic text formatting.

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setUnderline()

Sets underlined text formatting.

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setBlink()

Sets blinking text effect.

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setReverse()

Sets reverse video formatting (inverted colors).

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setConcealed()

Sets concealed/hidden text formatting.

Returns Reference to this Text object for method chaining.

template<class F, class B>
Text& Rodin::Alert::Text<F, B>::setCrossed()

Sets crossed-out text formatting.

Returns Reference to this Text object for method chaining.

template<class F, class B>
const FlatSet<Attribute>& Rodin::Alert::Text<F, B>::getAttributes() const

Gets the set of applied text attributes.

Returns Const reference to the set of attributes.