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. 無断転載を禁じます。
2// このソースコードの使用は、LICENSEファイルにあるMITライセンスによって管理されています。
3#include <chrono> // for operator""s, chrono_literals
4#include <ftxui/dom/elements.hpp> // for text, gauge, operator|, flex, hbox, Element
5#include <ftxui/screen/screen.hpp> // for Screen
6#include <iostream> // for cout, endl, ostream
7#include <string> // for allocator, char_traits, operator+, operator<<, string, to_string, basic_string
8#include <thread> // for sleep_for
9
10#include "ftxui/dom/node.hpp" // for Render
11#include "ftxui/screen/color.hpp" // for ftxui
12
13int main() {
14 using namespace ftxui;
15 using namespace std::chrono_literals;
16
17 std::string reset_position;
18 for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
19 std::string data_downloaded =
20 std::to_string(int(percentage * 5000)) + "/5000";
21 auto document = hbox({
22 text("downloading:"),
23 gauge(percentage) | flex,
24 text(" " + data_downloaded),
25 });
26 auto screen = Screen(100, 1);
27 Render(screen, document);
28 std::cout << reset_position;
29 screen.Print();
30 reset_position = screen.ResetPosition();
31
32 std::this_thread::sleep_for(0.01s);
33 }
34 std::cout << std::endl;
35}
ピクセルの長方形グリッド。
Definition screen.hpp:25
FTXUI ftxui:: 名前空間
Definition animation.hpp:9