FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/dom/size.cpp
Go to the documentation of this file.
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)
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上顯示元素。
Definition node.cpp:82
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
std::vector< Element > Elements
Definition elements.hpp:23