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:
Arthur Sonzogni
2021-08-09 00:27:37 +02:00
committed by GitHub
parent 3b4ab618a3
commit 9a54528bca
60 changed files with 817 additions and 836 deletions

View File

@@ -1,6 +1,6 @@
#include <functional> // for function
#include <memory> // for allocator, __shared_ptr_access
#include <string> // for wstring, basic_string, operator+, to_string
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
@@ -8,21 +8,17 @@
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/deprecated.hpp" // for text
#include "ftxui/dom/elements.hpp" // for separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border
#include "ftxui/screen/string.hpp" // for to_wstring
#include "ftxui/dom/elements.hpp" // for text, separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border
int main(int argc, const char* argv[]) {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
std::vector<std::wstring> left_menu_entries = {
L"0%", L"10%", L"20%", L"30%", L"40%",
L"50%", L"60%", L"70%", L"80%", L"90%",
std::vector<std::string> left_menu_entries = {
"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%",
};
std::vector<std::wstring> right_menu_entries = {
L"0%", L"1%", L"2%", L"3%", L"4%", L"5%",
L"6%", L"7%", L"8%", L"9%", L"10%",
std::vector<std::string> right_menu_entries = {
"0%", "1%", "2%", "3%", "4%", "5%", "6%", "7%", "8%", "9%", "10%",
};
auto menu_option = MenuOption();
@@ -47,14 +43,14 @@ int main(int argc, const char* argv[]) {
hbox({
// -------- Left Menu --------------
vbox({
hcenter(bold(text(L"Percentage by 10%"))),
hcenter(bold(text("Percentage by 10%"))),
separator(),
left_menu_->Render(),
}),
separator(),
// -------- Right Menu --------------
vbox({
hcenter(bold(text(L"Percentage by 1%"))),
hcenter(bold(text("Percentage by 1%"))),
separator(),
right_menu_->Render(),
}),
@@ -64,12 +60,12 @@ int main(int argc, const char* argv[]) {
// -------- Bottom panel --------------
vbox({
hbox({
text(L" gauge : "),
text(" gauge : "),
gauge(sum / 100.0),
}),
hbox({
text(L" text : "),
text(to_wstring(std::to_string(sum) + " %")),
text(" text : "),
text(std::to_string(sum) + " %"),
}),
}),
}) |