FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
examples/dom/size.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni。保留所有权利。
2// 此源代码的使用受 MIT 许可证的约束,该许可证可在 LICENSE 文件中找到。
3#include <ftxui/dom/elements.hpp> // for operator|, text, Element, hcenter, Fit, hbox, size, window, Elements, bold, dim, EQUAL, WIDTH
4#include <ftxui/screen/screen.hpp> // for Screen
5#include <memory> // for allocator, shared_ptr
6#include <string> // for string, to_string
7#include <utility> // for move
8
9#include "ftxui/dom/node.hpp" // for Render
10#include "ftxui/screen/color.hpp" // for ftxui
11
12int main() {
13 using namespace ftxui;
14 auto make_box = [](const std::string& title) {
15 return window(text(title) | hcenter | bold,
16 text("content") | hcenter | dim);
17 };
18
19 Elements content;
20 for (int x = 3; x < 30; ++x) {
21 content.push_back(make_box(std::to_string(x)) | size(WIDTH, EQUAL, x));
22 }
23
24 auto document = hbox(std::move(content));
25 auto screen = Screen::Create(Dimension::Fit(document));
26 Render(screen, document);
27 screen.Print();
28
29 return 0;
30}
Element make_box(int x, int y)
Element window(Element title, Element content, BorderStyle border)
绘制带有标题和边框的窗口。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::vector< Element > Elements