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 entries.push_back( //
27 hbox({
28 text(std::to_string(i)) | size(WIDTH, EQUAL, 2),
29 separator(),
30 spinner(i, index) | bold,
31 }));
32 }
33 auto document = hbox({
34 vbox(std::move(entries)) | border,
35 filler(),
36 });
37 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
38 Render(screen, document);
39 std::cout << reset_position;
40 screen.Print();
41 reset_position = screen.ResetPosition();
42
43 std::this_thread::sleep_for(0.1s);
44 }
45 std::cout << std::endl;
46}
int main()
The FTXUI ftxui:: namespace.
Definition animation.hpp:10