Skip to content

Text

The Text widget is used for creating normal text!

INFO

If you want to have multi color text and inline markup syntax use: MarkupText

Examples

cpp
auto text = tuipp::widgets::Text("Just plain text!");

tuipp::Console::println(text);
cpp
auto text = tuipp::widgets::Text("Colored text!");

text.foreground = tuipp::styles::Foreground::GREEN;
text.background = tuipp::styles::Background::GREY;

tuipp::Console::println(text);
cpp
auto text = tuipp::widgets::Text("Justified text!");

text.justification = tuipp::styles::Justification::CENTER;

tuipp::Console::println(text);
cpp
auto text = tuipp::widgets::Text("Styled text!");

text.foreground    = tuipp::styles::Foreground::GREEN;
text.background    = tuipp::styles::Background::GREY;
text.justification = tuipp::styles::Justification::CENTER;
text.effects       = { tuipp::styles::Effects::BOLD, tuipp::styles::Effects::UNDERLINE };

tuipp::Console::println(text);
cpp
auto panel = tuipp::widgets::Panel(" Panel ");

auto text = tuipp::widgets::Text("Text inside a panel");

panel.add_element(text);

tuipp::Console::println(panel);

Reference

Constructor
cpp
Text(std::string content,
     styles::Justification justification  = styles::Justification::LEFT,
     styles::Foreground foreground        = styles::Foreground::NONE,
     styles::Background background        = styles::Background::NONE,
     std::vector<styles::Effects> effects = { styles::Effects::NONE })

Parameters

  • content (string)
    The text
  • justification (tuipp::styles::Justification)
    The justification of the text.
  • foreground (tuipp::styles::Foreground)
    The foreground of the text.
  • background (tuipp::styles::Background)
    The background of the text.
  • effects (std::vector<styles::Effects>)
    The effects of the text.
Methods

render(const int& width) --> void
Renders the component.


get_length(const int& width = 0) --> int
Returns the width of the text.