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
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. |
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. |
const Foreground& Rodin:: Alert:: Text<F, B>:: getForeground() const
Gets the foreground color.
Returns | Const reference to the foreground color. |
---|
const Background& Rodin:: Alert:: Text<F, B>:: getBackground() const
Gets the background color.
Returns | Const reference to the background color. |
---|
Text& Rodin:: Alert:: Text<F, B>:: setUnderline()
Sets underlined text formatting.
Returns | Reference to this Text object for method chaining. |
---|
Text& Rodin:: Alert:: Text<F, B>:: setReverse()
Sets reverse video formatting (inverted colors).
Returns | Reference to this Text object for method chaining. |
---|
Text& Rodin:: Alert:: Text<F, B>:: setConcealed()
Sets concealed/hidden text formatting.
Returns | Reference to this Text object for method chaining. |
---|
Text& Rodin:: Alert:: Text<F, B>:: setCrossed()
Sets crossed-out text formatting.
Returns | Reference to this Text object for method chaining. |
---|