16Elements Split(std::string_view the_text) {
19 size_t end = the_text.find(
' ');
20 while (end != std::string_view::npos) {
21 output.push_back(
text(the_text.substr(start, end - start)));
23 end = the_text.find(
' ', start);
25 output.push_back(
text(the_text.substr(start)));
29Element Split(std::string_view paragraph,
30 const std::function<
Element(std::string_view)>& f) {
33 size_t end = paragraph.find(
'\n');
34 while (end != std::string_view::npos) {
35 output.push_back(f(paragraph.substr(start, end - start)));
37 end = paragraph.find(
'\n', start);
39 output.push_back(f(paragraph.substr(start)));
40 return vbox(std::move(output));
57 return Split(the_text, [](std::string_view line) {
58 static const auto config = FlexboxConfig().SetGap(1, 0);
59 return flexbox(Split(line), config);
68 return Split(the_text, [](std::string_view line) {
69 static const auto config = FlexboxConfig().SetGap(1, 0).Set(
70 FlexboxConfig::JustifyContent::FlexEnd);
71 return flexbox(Split(line), config);
80 return Split(the_text, [](std::string_view line) {
81 static const auto config =
82 FlexboxConfig().SetGap(1, 0).Set(FlexboxConfig::JustifyContent::Center);
83 return flexbox(Split(line), config);
93 return Split(the_text, [](std::string_view line) {
94 static const auto config = FlexboxConfig().SetGap(1, 0).Set(
95 FlexboxConfig::JustifyContent::SpaceBetween);
97 words.push_back(
text(
"") | xflex);
98 return flexbox(std::move(words), config);
Element text(std::string_view text)
Display a piece of UTF8 encoded unicode text.
Element paragraphAlignLeft(std::string_view the_text)
Return an element drawing the paragraph on multiple lines, aligned on the left.
Element paragraphAlignJustify(std::string_view the_text)
Return an element drawing the paragraph on multiple lines, aligned using a justified alignment....
Element paragraphAlignCenter(std::string_view the_text)
Return an element drawing the paragraph on multiple lines, aligned on the center.
Element paragraph(std::string_view the_text)
Return an element drawing the paragraph on multiple lines.
Element paragraphAlignRight(std::string_view the_text)
Return an element drawing the paragraph on multiple lines, aligned on the right.
Element vbox(Elements children)
A container displaying elements vertically one by one.
The FTXUI ftxui:: namespace.
Element flexbox(Elements, FlexboxConfig config=FlexboxConfig())
A container displaying elements on row/columns and capable of wrapping on the next column/row when fu...
std::shared_ptr< Node > Element
std::vector< Element > Elements