15Elements Split(
const std::string& the_text) {
17 std::stringstream ss(the_text);
19 while (std::getline(ss, word,
' ')) {
20 output.push_back(
text(word));
25Element Split(
const std::string& paragraph,
26 const std::function<
Element(std::string)>& f) {
28 std::stringstream ss(paragraph);
30 while (std::getline(ss, line,
'\n')) {
31 output.push_back(f(line));
33 return vbox(std::move(output));
49 return Split(the_text, [](
const std::string& line) {
51 return flexbox(Split(line), config);
59 return Split(the_text, [](
const std::string& line) {
62 return flexbox(Split(line), config);
70 return Split(the_text, [](
const std::string& line) {
71 static const auto config =
73 return flexbox(Split(line), config);
82 return Split(the_text, [](
const std::string& line) {
86 words.push_back(
text(
"") | xflex);
87 return flexbox(std::move(words), config);
FlexboxConfig & SetGap(int gap_x, int gap_y)
设置 flexbox flex direction。
@ SpaceBetween
项目在线上均匀分布;第一个项目在起始线,最后一个项目在结束线
FlexboxConfig & Set(FlexboxConfig::Direction)
设置 flexbox 方向。
Element paragraphAlignRight(const std::string &text)
返回一个在多行上绘制段落并右对齐的元素。
Element paragraphAlignCenter(const std::string &text)
返回一个在多行上绘制段落并居中对齐的元素。
Element text(std::wstring text)
显示一段Unicode文本。
Element paragraphAlignLeft(const std::string &text)
返回一个在多行上绘制段落并左对齐的元素。
Element paragraphAlignJustify(const std::string &text)
返回一个在多行上绘制段落并使用两端对齐方式的元素。 居中对齐。
Element vbox(Elements)
垂直一个接一个显示元素的容器。
FlexboxConfig 是一个配置结构体,定义了弹性盒子容器的布局属性。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
Element flexbox(Elements, FlexboxConfig config=FlexboxConfig())
一个容器,用于在行/列中显示元素,并且在填满时能够换行到下一列/行。
std::shared_ptr< Node > Element
std::vector< Element > Elements
Elements paragraph(std::wstring text)