mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-20 18:48:08 +08:00
Update examples to use std::string. (#182)
In examples and tests, use std::string. In addtion: 1. Address follow-up from: https://github.com/ArthurSonzogni/FTXUI/pull/179 2. Fix a bug when Input is used with std::string.
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
#include <chrono> // for operator""s, chrono_literals
|
||||
#include <ftxui/dom/elements.hpp> // for gauge, operator|, flex, hbox, Element
|
||||
#include <chrono> // for operator""s, chrono_literals
|
||||
#include <ftxui/dom/elements.hpp> // for text, gauge, operator|, flex, hbox, Element
|
||||
#include <ftxui/screen/screen.hpp> // for Screen
|
||||
#include <iostream> // for cout, endl, ostream
|
||||
#include <string> // for allocator, operator+, char_traits, operator<<, to_wstring, basic_string, string, wstring
|
||||
#include <string> // for allocator, operator+, char_traits, operator<<, string, to_string, basic_string
|
||||
#include <thread> // for sleep_for
|
||||
|
||||
#include "ftxui/dom/deprecated.hpp" // for text
|
||||
#include "ftxui/dom/node.hpp" // for Render
|
||||
#include "ftxui/screen/box.hpp" // for ftxui
|
||||
#include "ftxui/dom/node.hpp" // for Render
|
||||
#include "ftxui/screen/box.hpp" // for ftxui
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
using namespace ftxui;
|
||||
@@ -15,12 +14,12 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
std::string reset_position;
|
||||
for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
|
||||
std::wstring data_downloaded =
|
||||
std::to_wstring(int(percentage * 5000)) + L"/5000";
|
||||
std::string data_downloaded =
|
||||
std::to_string(int(percentage * 5000)) + "/5000";
|
||||
auto document = hbox({
|
||||
text(L"downloading:"),
|
||||
text("downloading:"),
|
||||
gauge(percentage) | flex,
|
||||
text(L" " + data_downloaded),
|
||||
text(" " + data_downloaded),
|
||||
});
|
||||
auto screen = Screen(100, 1);
|
||||
Render(screen, document);
|
||||
|
Reference in New Issue
Block a user