#include <string>
return vbox({
text("FTXUI:一个用于构建用户界面的强大库。"),
text("享受丰富的组件集和声明式风格。"),
text("以最小的努力创建美观且响应迅速的 UI。"),
text("加入社区,体验 FTXUI 的强大功能。"),
});
}
auto screen = ScreenInteractive::TerminalOutput();
auto quit =
Button("退出", screen.ExitLoopClosure(), ButtonOption::Animated());
int selection_change_counter = 0;
std::string selection_content = "";
screen.SelectionChange([&] {
selection_change_counter++;
selection_content = screen.GetSelection();
});
return vbox({
text("选择已更改:" + std::to_string(selection_change_counter) +
" 次"),
text("当前选中:"),
paragraph(selection_content) | vscroll_indicator | frame | border |
size(HEIGHT, EQUAL, 10),
separator(),
separator(),
})),
separator(),
separator(),
})),
vbox({
hbox({
separator(),
| selectionBackgroundColor(Color::Yellow)
| selectionColor(Color::Black)
| selectionStyleReset,
separator(),
}),
separator(),
hbox({
separator(),
}),
separator(),
}),
})),
quit->Render(),
});
});
}
Element window(Element title, Element content, BorderStyle border)
绘制带有标题和边框的窗口。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::shared_ptr< Node > Element