FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/dom/spinner.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 <chrono> // for operator""s, chrono_literals
5#include <ftxui/dom/elements.hpp> // for Element, operator|, separator, filler, hbox, size, spinner, text, vbox, bold, border, Fit, EQUAL, WIDTH
6#include <ftxui/screen/screen.hpp> // for Full, Screen
7#include <iostream> // for cout, endl, ostream
8#include <string> // for to_string, operator<<, string
9#include <thread> // for sleep_for
10#include <utility> // for move
11#include <vector> // for vector
12
13#include "ftxui/dom/node.hpp" // for Render
14#include "ftxui/screen/color.hpp" // for ftxui
15
16int main() {
17 using namespace ftxui;
18 using namespace std::chrono_literals;
19
20 std::string reset_position;
21 for (int index = 0; index < 200; ++index) {
22 std::vector<Element> entries;
23 for (int i = 0; i < 23; ++i) {
24 if (i != 0) {
25 entries.push_back(separator());
26 }
27 entries.push_back( //
28 hbox({
29 text(std::to_string(i)) | size(WIDTH, EQUAL, 2),
30 separator(),
31 spinner(i, index) | bold,
32 }));
33 }
34 auto document = hbox({
35 vbox(std::move(entries)) | border,
36 filler(),
37 });
38 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
39 Render(screen, document);
40 std::cout << reset_position;
41 screen.Print();
42 reset_position = screen.ResetPosition();
43
44 std::this_thread::sleep_for(0.1s);
45 }
46 std::cout << std::endl;
47}
The FTXUI ftxui:: namespace.
Definition animation.hpp:10