FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
examples/dom/size.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <ftxui/dom/elements.hpp> // for operator|, text, Element, hcenter, Fit, hbox, size, window, Elements, bold, dim, EQUAL, WIDTH
5#include <ftxui/screen/screen.hpp> // for Screen
6#include <memory> // for allocator, shared_ptr
7#include <string> // for string, to_string
8#include <utility> // for move
9
10#include "ftxui/dom/node.hpp" // for Render
11#include "ftxui/screen/color.hpp" // for ftxui
12
13 int main() {
14 using namespace ftxui;
15 auto make_box = [](const std::string& title) {
16 return window(text(title) | hcenter | bold,
17 text("content") | hcenter | dim);
18 };
19
20 Elements content;
21 for (int x = 3; x < 30; ++x) {
22 content.push_back(make_box(std::to_string(x)) | size(WIDTH, EQUAL, x));
23 }
24
25 auto document = hbox(std::move(content));
26 auto screen = Screen::Create(Dimension::Fit(document));
27 Render(screen, document);
28 screen.Print();
29
30 return 0;
31}
color.hpp
elements.hpp
make_box
Element make_box(int x, int y)
Definition examples/component/focus.cpp:17
main
int main()
Definition examples/dom/size.cpp:13
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::Elements
std::vector< Element > Elements
Definition elements.hpp:23
node.hpp
screen.hpp