FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
hflow.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni. 保留所有权利。
2// 此源代码的使用受 MIT 许可证的管辖,MIT 许可证可在
3// LICENSE 文件中找到。
4#include <stdio.h> // for getchar
5#include <ftxui/dom/elements.hpp> // for operator|, size, Element, text, hcenter, Decorator, Fit, WIDTH, hflow, window, EQUAL, GREATER_THAN, HEIGHT, bold, border, dim, LESS_THAN
6#include <ftxui/screen/screen.hpp> // for Full, Screen
7#include <string> // for allocator, char_traits, operator+, to_string, string
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 = [](int dimx, int dimy) {
15 std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
16 return window(text(title) | hcenter | bold,
17 text("content") | hcenter | dim) |
18 size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
19 };
20
21 auto style = size(WIDTH, GREATER_THAN, 20) | border |
22 size(HEIGHT, GREATER_THAN, 30) | size(WIDTH, LESS_THAN, 50);
23
24 auto document = hflow({
25 make_box(7, 7),
26 make_box(7, 5),
27 make_box(5, 7),
28 make_box(10, 4),
29 make_box(10, 4),
30 make_box(10, 4),
31 make_box(10, 4),
32 make_box(11, 4),
33 make_box(11, 4),
34 make_box(11, 4),
35 make_box(11, 4),
36 make_box(12, 4),
37 make_box(12, 5),
38 make_box(12, 4),
39 make_box(13, 4),
40 make_box(13, 3),
41 make_box(13, 3),
42 make_box(10, 3),
43 }) |
44 style;
45
46 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
47 Render(screen, document);
48 screen.Print();
49 getchar();
50
51 return 0;
52}
Element make_box(int x, int y)
Element window(Element title, Element content, BorderStyle border)
绘制带有标题和边框的窗口。
int main()
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase