FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
examples/dom/gauge.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 text, gauge, operator|, flex, hbox, Element
6#include <ftxui/screen/screen.hpp> // for Screen
7#include <iostream> // for cout, endl, ostream
8#include <string> // for allocator, char_traits, operator+, operator<<, string, to_string, basic_string
9#include <thread> // for sleep_for
10
11#include "ftxui/dom/node.hpp" // for Render
12#include "ftxui/screen/color.hpp" // for ftxui
13
14 int main() {
15 using namespace ftxui;
16 using namespace std::chrono_literals;
17
18 std::string reset_position;
19 for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
20 std::string data_downloaded =
21 std::to_string(int(percentage * 5000)) + "/5000";
22 auto document = hbox({
23 text("downloading:"),
24 gauge(percentage) | flex,
25 text(" " + data_downloaded),
26 });
27 auto screen = Screen(100, 1);
28 Render(screen, document);
29 std::cout << reset_position;
30 screen.Print();
31 reset_position = screen.ResetPosition();
32
33 std::this_thread::sleep_for(0.01s);
34 }
35 std::cout << std::endl;
36}
color.hpp
elements.hpp
main
int main()
Definition examples/dom/gauge.cpp:14
ftxui::Screen
A rectangular grid of Pixel.
Definition screen.hpp:27
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
node.hpp
screen.hpp