mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +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:
parent
3b4ab618a3
commit
9a54528bca
@ -6,7 +6,6 @@
|
|||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/component_options.hpp" // for ButtonOption
|
#include "ftxui/component/component_options.hpp" // for ButtonOption
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, gauge, Element, operator|, vbox, border
|
#include "ftxui/dom/elements.hpp" // for separator, gauge, Element, operator|, vbox, border
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
@ -27,7 +26,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
// Modify the way to render them on screen:
|
// Modify the way to render them on screen:
|
||||||
auto component = Renderer(buttons, [&] {
|
auto component = Renderer(buttons, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"value = " + std::to_wstring(value)),
|
text("value = " + std::to_string(value)),
|
||||||
separator(),
|
separator(),
|
||||||
gauge(value * 0.01f),
|
gauge(value * 0.01f),
|
||||||
separator(),
|
separator(),
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
#include <memory> // for __shared_ptr_access, allocator_traits<>::value_type, shared_ptr
|
#include <memory> // for shared_ptr, __shared_ptr_access, allocator_traits<>::value_type
|
||||||
#include <string> // for operator+
|
#include <string> // for operator+, to_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Vertical
|
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Vertical
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/elements.hpp" // for Element, operator|, size, border, frame, HEIGHT, LESS_THAN
|
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, HEIGHT, LESS_THAN
|
||||||
#include "ftxui/screen/string.hpp" // for to_wstring
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
@ -21,7 +20,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto container = Container::Vertical({});
|
auto container = Container::Vertical({});
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
states[i].checked = false;
|
states[i].checked = false;
|
||||||
container->Add(Checkbox(L"Checkbox" + to_wstring(i), &states[i].checked));
|
container->Add(
|
||||||
|
Checkbox("Checkbox" + std::to_string(i), &states[i].checked));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto component = Renderer(container, [&] {
|
auto component = Renderer(container, [&] {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for operator+, to_wstring
|
#include <string> // for operator+, to_string
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
|
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/component_options.hpp" // for ButtonOption
|
#include "ftxui/component/component_options.hpp" // for ButtonOption
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, separator, Element, operator|, vbox, border
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, Element, operator|, vbox, border
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
@ -38,9 +37,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
// children reacts to events is maintained.
|
// children reacts to events is maintained.
|
||||||
auto leftpane = Renderer(left_buttons, [&] {
|
auto leftpane = Renderer(left_buttons, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"This is the left control"),
|
text("This is the left control"),
|
||||||
separator(),
|
separator(),
|
||||||
text(L"Left button count: " + std::to_wstring(left_count)),
|
text("Left button count: " + std::to_string(left_count)),
|
||||||
left_buttons->Render(),
|
left_buttons->Render(),
|
||||||
}) |
|
}) |
|
||||||
border;
|
border;
|
||||||
@ -48,9 +47,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
auto rightpane = Renderer(right_buttons, [&] {
|
auto rightpane = Renderer(right_buttons, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"This is the right control"),
|
text("This is the right control"),
|
||||||
separator(),
|
separator(),
|
||||||
text(L"Right button count: " + std::to_wstring(right_count)),
|
text("Right button count: " + std::to_string(right_count)),
|
||||||
right_buttons->Render(),
|
right_buttons->Render(),
|
||||||
}) |
|
}) |
|
||||||
border;
|
border;
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Slider, Checkbox, Vertical, Renderer, Button, Menu, Radiobox, Toggle
|
#include "ftxui/component/component.hpp" // for Slider, Checkbox, Vertical, Renderer, Button, Input, Menu, Radiobox, Toggle
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/deprecated.hpp" // for Input
|
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for separator, operator|, Element, size, xflex, text, WIDTH, hbox, vbox, EQUAL, border, GREATER_THAN
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, operator|, Element, size, xflex, WIDTH, hbox, vbox, EQUAL, border, GREATER_THAN
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
// Display a component nicely with a title on the left.
|
// Display a component nicely with a title on the left.
|
||||||
Component Wrap(std::wstring name, Component component) {
|
Component Wrap(std::string name, Component component) {
|
||||||
return Renderer(component, [name, component] {
|
return Renderer(component, [name, component] {
|
||||||
return hbox({
|
return hbox({
|
||||||
text(name) | size(WIDTH, EQUAL, 8),
|
text(name) | size(WIDTH, EQUAL, 8),
|
||||||
@ -30,24 +28,24 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
// -- Menu
|
// -- Menu
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
const std::vector<std::wstring> menu_entries = {
|
const std::vector<std::string> menu_entries = {
|
||||||
L"Menu 1",
|
"Menu 1",
|
||||||
L"Menu 2",
|
"Menu 2",
|
||||||
L"Menu 3",
|
"Menu 3",
|
||||||
L"Menu 4",
|
"Menu 4",
|
||||||
};
|
};
|
||||||
int menu_selected = 0;
|
int menu_selected = 0;
|
||||||
auto menu = Menu(&menu_entries, &menu_selected);
|
auto menu = Menu(&menu_entries, &menu_selected);
|
||||||
menu = Wrap(L"Menu", menu);
|
menu = Wrap("Menu", menu);
|
||||||
|
|
||||||
// -- Toggle------------------------------------------------------------------
|
// -- Toggle------------------------------------------------------------------
|
||||||
int toggle_selected = 0;
|
int toggle_selected = 0;
|
||||||
std::vector<std::wstring> toggle_entries = {
|
std::vector<std::string> toggle_entries = {
|
||||||
L"Toggle_1",
|
"Toggle_1",
|
||||||
L"Toggle_2",
|
"Toggle_2",
|
||||||
};
|
};
|
||||||
auto toggle = Toggle(&toggle_entries, &toggle_selected);
|
auto toggle = Toggle(&toggle_entries, &toggle_selected);
|
||||||
toggle = Wrap(L"Toggle", toggle);
|
toggle = Wrap("Toggle", toggle);
|
||||||
|
|
||||||
// -- Checkbox ---------------------------------------------------------------
|
// -- Checkbox ---------------------------------------------------------------
|
||||||
bool checkbox_1_selected = false;
|
bool checkbox_1_selected = false;
|
||||||
@ -57,40 +55,40 @@ int main(int argc, const char* argv[]) {
|
|||||||
Checkbox("checkbox1", &checkbox_1_selected),
|
Checkbox("checkbox1", &checkbox_1_selected),
|
||||||
Checkbox("checkbox2", &checkbox_2_selected),
|
Checkbox("checkbox2", &checkbox_2_selected),
|
||||||
});
|
});
|
||||||
checkboxes = Wrap(L"Checkbox", checkboxes);
|
checkboxes = Wrap("Checkbox", checkboxes);
|
||||||
|
|
||||||
// -- Radiobox ---------------------------------------------------------------
|
// -- Radiobox ---------------------------------------------------------------
|
||||||
int radiobox_selected = 0;
|
int radiobox_selected = 0;
|
||||||
std::vector<std::wstring> radiobox_entries = {
|
std::vector<std::string> radiobox_entries = {
|
||||||
L"Radiobox 1",
|
"Radiobox 1",
|
||||||
L"Radiobox 2",
|
"Radiobox 2",
|
||||||
L"Radiobox 3",
|
"Radiobox 3",
|
||||||
L"Radiobox 4",
|
"Radiobox 4",
|
||||||
};
|
};
|
||||||
auto radiobox = Radiobox(&radiobox_entries, &radiobox_selected);
|
auto radiobox = Radiobox(&radiobox_entries, &radiobox_selected);
|
||||||
radiobox = Wrap(L"Radiobox", radiobox);
|
radiobox = Wrap("Radiobox", radiobox);
|
||||||
|
|
||||||
// -- Input ------------------------------------------------------------------
|
// -- Input ------------------------------------------------------------------
|
||||||
std::wstring input_label;
|
std::string input_label;
|
||||||
auto input = Input(&input_label, L"placeholder");
|
auto input = Input(&input_label, "placeholder");
|
||||||
input = Wrap(L"Input", input);
|
input = Wrap("Input", input);
|
||||||
|
|
||||||
// -- Button -----------------------------------------------------------------
|
// -- Button -----------------------------------------------------------------
|
||||||
std::wstring button_label = L"Quit";
|
std::string button_label = "Quit";
|
||||||
std::function<void()> on_button_clicked_;
|
std::function<void()> on_button_clicked_;
|
||||||
auto button = Button(&button_label, screen.ExitLoopClosure());
|
auto button = Button(&button_label, screen.ExitLoopClosure());
|
||||||
button = Wrap(L"Button", button);
|
button = Wrap("Button", button);
|
||||||
|
|
||||||
// -- Slider -----------------------------------------------------------------
|
// -- Slider -----------------------------------------------------------------
|
||||||
int slider_value_1 = 12;
|
int slider_value_1 = 12;
|
||||||
int slider_value_2 = 56;
|
int slider_value_2 = 56;
|
||||||
int slider_value_3 = 128;
|
int slider_value_3 = 128;
|
||||||
auto sliders = Container::Vertical({
|
auto sliders = Container::Vertical({
|
||||||
Slider(L"R:", &slider_value_1, 0, 256, 1),
|
Slider("R:", &slider_value_1, 0, 256, 1),
|
||||||
Slider(L"G:", &slider_value_2, 0, 256, 1),
|
Slider("G:", &slider_value_2, 0, 256, 1),
|
||||||
Slider(L"B:", &slider_value_3, 0, 256, 1),
|
Slider("B:", &slider_value_3, 0, 256, 1),
|
||||||
});
|
});
|
||||||
sliders = Wrap(L"Slider", sliders);
|
sliders = Wrap("Slider", sliders);
|
||||||
|
|
||||||
// -- Layout -----------------------------------------------------------------
|
// -- Layout -----------------------------------------------------------------
|
||||||
auto layout = Container::Vertical({
|
auto layout = Container::Vertical({
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <cmath> // for sin
|
#include <cmath> // for sin
|
||||||
#include <functional> // for ref, reference_wrapper, function
|
#include <functional> // for ref, reference_wrapper, function
|
||||||
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for wstring, basic_string, operator+, char_traits, to_wstring
|
#include <string> // for string, basic_string, operator+, char_traits, to_string
|
||||||
#include <thread> // for sleep_for, thread
|
#include <thread> // for sleep_for, thread
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -12,10 +12,8 @@
|
|||||||
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Horizontal, Vertical, Menu, Radiobox, Tab, Toggle
|
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Horizontal, Vertical, Menu, Radiobox, Tab, Toggle
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/component_options.hpp" // for InputOption
|
#include "ftxui/component/component_options.hpp" // for InputOption
|
||||||
#include "ftxui/component/deprecated.hpp" // for Input
|
|
||||||
#include "ftxui/component/event.hpp" // for Event, Event::Custom
|
#include "ftxui/component/event.hpp" // for Event, Event::Custom
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, color, bgcolor, filler, Element, size, vbox, flex, hbox, graph, separator, EQUAL, WIDTH, hcenter, bold, border, window, HEIGHT, Elements, hflow, flex_grow, frame, gauge, LESS_THAN, spinner, dim, GREATER_THAN
|
#include "ftxui/dom/elements.hpp" // for operator|, color, bgcolor, filler, Element, size, vbox, flex, hbox, graph, separator, EQUAL, WIDTH, hcenter, bold, border, window, HEIGHT, Elements, hflow, flex_grow, frame, gauge, LESS_THAN, spinner, dim, GREATER_THAN
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::BlueLight, Color::RedLight, Color::Black, Color::Blue, Color::Cyan, Color::CyanLight, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::White, Color::Yellow, Color::YellowLight, Color::Default
|
#include "ftxui/screen/color.hpp" // for Color, Color::BlueLight, Color::RedLight, Color::Black, Color::Blue, Color::Cyan, Color::CyanLight, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::White, Color::Yellow, Color::YellowLight, Color::Default
|
||||||
|
|
||||||
@ -41,42 +39,42 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
auto htop = Renderer([&] {
|
auto htop = Renderer([&] {
|
||||||
auto frequency = vbox({
|
auto frequency = vbox({
|
||||||
text(L"Frequency [Mhz]") | hcenter,
|
text("Frequency [Mhz]") | hcenter,
|
||||||
hbox({
|
hbox({
|
||||||
vbox({
|
vbox({
|
||||||
text(L"2400 "),
|
text("2400 "),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"1200 "),
|
text("1200 "),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"0 "),
|
text("0 "),
|
||||||
}),
|
}),
|
||||||
graph(std::ref(my_graph)) | flex,
|
graph(std::ref(my_graph)) | flex,
|
||||||
}) | flex,
|
}) | flex,
|
||||||
});
|
});
|
||||||
|
|
||||||
auto utilization = vbox({
|
auto utilization = vbox({
|
||||||
text(L"Utilization [%]") | hcenter,
|
text("Utilization [%]") | hcenter,
|
||||||
hbox({
|
hbox({
|
||||||
vbox({
|
vbox({
|
||||||
text(L"100 "),
|
text("100 "),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"50 "),
|
text("50 "),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"0 "),
|
text("0 "),
|
||||||
}),
|
}),
|
||||||
graph(std::ref(my_graph)) | color(Color::RedLight),
|
graph(std::ref(my_graph)) | color(Color::RedLight),
|
||||||
}) | flex,
|
}) | flex,
|
||||||
});
|
});
|
||||||
|
|
||||||
auto ram = vbox({
|
auto ram = vbox({
|
||||||
text(L"Ram [Mo]") | hcenter,
|
text("Ram [Mo]") | hcenter,
|
||||||
hbox({
|
hbox({
|
||||||
vbox({
|
vbox({
|
||||||
text(L"8192"),
|
text("8192"),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"4096 "),
|
text("4096 "),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"0 "),
|
text("0 "),
|
||||||
}),
|
}),
|
||||||
graph(std::ref(my_graph)) | color(Color::BlueLight),
|
graph(std::ref(my_graph)) | color(Color::BlueLight),
|
||||||
}) | flex,
|
}) | flex,
|
||||||
@ -94,56 +92,56 @@ int main(int argc, const char* argv[]) {
|
|||||||
flex | border;
|
flex | border;
|
||||||
});
|
});
|
||||||
|
|
||||||
const std::vector<std::wstring> compiler_entries = {
|
const std::vector<std::string> compiler_entries = {
|
||||||
L"gcc",
|
"gcc",
|
||||||
L"clang",
|
"clang",
|
||||||
L"emcc",
|
"emcc",
|
||||||
L"game_maker",
|
"game_maker",
|
||||||
L"Ada compilers",
|
"Ada compilers",
|
||||||
L"ALGOL 60 compilers",
|
"ALGOL 60 compilers",
|
||||||
L"ALGOL 68 compilers",
|
"ALGOL 68 compilers",
|
||||||
L"Assemblers (Intel *86)",
|
"Assemblers (Intel *86)",
|
||||||
L"Assemblers (Motorola 68*)",
|
"Assemblers (Motorola 68*)",
|
||||||
L"Assemblers (Zilog Z80)",
|
"Assemblers (Zilog Z80)",
|
||||||
L"Assemblers (other)",
|
"Assemblers (other)",
|
||||||
L"BASIC Compilers",
|
"BASIC Compilers",
|
||||||
L"BASIC interpreters",
|
"BASIC interpreters",
|
||||||
L"Batch compilers",
|
"Batch compilers",
|
||||||
L"C compilers",
|
"C compilers",
|
||||||
L"Source-to-source compilers",
|
"Source-to-source compilers",
|
||||||
L"C++ compilers",
|
"C++ compilers",
|
||||||
L"C# compilers",
|
"C# compilers",
|
||||||
L"COBOL compilers",
|
"COBOL compilers",
|
||||||
L"Common Lisp compilers",
|
"Common Lisp compilers",
|
||||||
L"D compilers",
|
"D compilers",
|
||||||
L"DIBOL/DBL compilers",
|
"DIBOL/DBL compilers",
|
||||||
L"ECMAScript interpreters",
|
"ECMAScript interpreters",
|
||||||
L"Eiffel compilers",
|
"Eiffel compilers",
|
||||||
L"Fortran compilers",
|
"Fortran compilers",
|
||||||
L"Go compilers",
|
"Go compilers",
|
||||||
L"Haskell compilers",
|
"Haskell compilers",
|
||||||
L"Java compilers",
|
"Java compilers",
|
||||||
L"Pascal compilers",
|
"Pascal compilers",
|
||||||
L"Perl Interpreters",
|
"Perl Interpreters",
|
||||||
L"PHP compilers",
|
"PHP compilers",
|
||||||
L"PL/I compilers",
|
"PL/I compilers",
|
||||||
L"Python compilers",
|
"Python compilers",
|
||||||
L"Scheme compilers and interpreters",
|
"Scheme compilers and interpreters",
|
||||||
L"Smalltalk compilers",
|
"Smalltalk compilers",
|
||||||
L"Tcl Interpreters",
|
"Tcl Interpreters",
|
||||||
L"VMS Interpreters",
|
"VMS Interpreters",
|
||||||
L"Rexx Interpreters",
|
"Rexx Interpreters",
|
||||||
L"CLI compilers",
|
"CLI compilers",
|
||||||
};
|
};
|
||||||
|
|
||||||
int compiler_selected = 0;
|
int compiler_selected = 0;
|
||||||
Component compiler = Radiobox(&compiler_entries, &compiler_selected);
|
Component compiler = Radiobox(&compiler_entries, &compiler_selected);
|
||||||
|
|
||||||
std::array<std::wstring, 4> options_label = {
|
std::array<std::string, 4> options_label = {
|
||||||
L"-Wall",
|
"-Wall",
|
||||||
L"-Werror",
|
"-Werror",
|
||||||
L"-lpthread",
|
"-lpthread",
|
||||||
L"-O3",
|
"-O3",
|
||||||
};
|
};
|
||||||
std::array<bool, 4> options_state = {
|
std::array<bool, 4> options_state = {
|
||||||
false,
|
false,
|
||||||
@ -152,19 +150,19 @@ int main(int argc, const char* argv[]) {
|
|||||||
false,
|
false,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::wstring> input_entries;
|
std::vector<std::string> input_entries;
|
||||||
int input_selected = 0;
|
int input_selected = 0;
|
||||||
Component input = Menu(&input_entries, &input_selected);
|
Component input = Menu(&input_entries, &input_selected);
|
||||||
|
|
||||||
auto input_option = InputOption();
|
auto input_option = InputOption();
|
||||||
std::wstring input_add_content;
|
std::string input_add_content;
|
||||||
input_option.on_enter = [&] {
|
input_option.on_enter = [&] {
|
||||||
input_entries.push_back(input_add_content);
|
input_entries.push_back(input_add_content);
|
||||||
input_add_content = L"";
|
input_add_content = "";
|
||||||
};
|
};
|
||||||
Component input_add = Input(&input_add_content, "input files", input_option);
|
Component input_add = Input(&input_add_content, "input files", input_option);
|
||||||
|
|
||||||
std::wstring executable_content_ = L"";
|
std::string executable_content_ = "";
|
||||||
Component executable_ = Input(&executable_content_, "executable");
|
Component executable_ = Input(&executable_content_, "executable");
|
||||||
|
|
||||||
Component flags = Container::Vertical({
|
Component flags = Container::Vertical({
|
||||||
@ -193,33 +191,33 @@ int main(int argc, const char* argv[]) {
|
|||||||
// flags
|
// flags
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
if (options_state[i]) {
|
if (options_state[i]) {
|
||||||
line.push_back(text(L" "));
|
line.push_back(text(" "));
|
||||||
line.push_back(text(options_label[i]) | dim);
|
line.push_back(text(options_label[i]) | dim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Executable
|
// Executable
|
||||||
if (!executable_content_.empty()) {
|
if (!executable_content_.empty()) {
|
||||||
line.push_back(text(L" -o ") | bold);
|
line.push_back(text(" -o ") | bold);
|
||||||
line.push_back(text(executable_content_) | color(Color::BlueLight) |
|
line.push_back(text(executable_content_) | color(Color::BlueLight) |
|
||||||
bold);
|
bold);
|
||||||
}
|
}
|
||||||
// Input
|
// Input
|
||||||
for (auto& it : input_entries) {
|
for (auto& it : input_entries) {
|
||||||
line.push_back(text(L" " + it) | color(Color::RedLight));
|
line.push_back(text(" " + it) | color(Color::RedLight));
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto compiler_renderer = Renderer(compiler_component, [&] {
|
auto compiler_renderer = Renderer(compiler_component, [&] {
|
||||||
auto compiler_win = window(text(L"Compiler"), compiler->Render() | frame);
|
auto compiler_win = window(text("Compiler"), compiler->Render() | frame);
|
||||||
auto flags_win = window(text(L"Flags"), flags->Render());
|
auto flags_win = window(text("Flags"), flags->Render());
|
||||||
auto executable_win = window(text(L"Executable:"), executable_->Render());
|
auto executable_win = window(text("Executable:"), executable_->Render());
|
||||||
auto input_win =
|
auto input_win =
|
||||||
window(text(L"Input"),
|
window(text("Input"),
|
||||||
hbox({
|
hbox({
|
||||||
vbox({
|
vbox({
|
||||||
hbox({
|
hbox({
|
||||||
text(L"Add: "),
|
text("Add: "),
|
||||||
input_add->Render(),
|
input_add->Render(),
|
||||||
}) | size(WIDTH, EQUAL, 20) |
|
}) | size(WIDTH, EQUAL, 20) |
|
||||||
size(HEIGHT, EQUAL, 1),
|
size(HEIGHT, EQUAL, 1),
|
||||||
@ -255,42 +253,42 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto color_tab_renderer = Renderer([] {
|
auto color_tab_renderer = Renderer([] {
|
||||||
return hbox({
|
return hbox({
|
||||||
vbox({
|
vbox({
|
||||||
color(Color::Default, text(L"Default")),
|
color(Color::Default, text("Default")),
|
||||||
color(Color::Black, text(L"Black")),
|
color(Color::Black, text("Black")),
|
||||||
color(Color::GrayDark, text(L"GrayDark")),
|
color(Color::GrayDark, text("GrayDark")),
|
||||||
color(Color::GrayLight, text(L"GrayLight")),
|
color(Color::GrayLight, text("GrayLight")),
|
||||||
color(Color::White, text(L"White")),
|
color(Color::White, text("White")),
|
||||||
color(Color::Blue, text(L"Blue")),
|
color(Color::Blue, text("Blue")),
|
||||||
color(Color::BlueLight, text(L"BlueLight")),
|
color(Color::BlueLight, text("BlueLight")),
|
||||||
color(Color::Cyan, text(L"Cyan")),
|
color(Color::Cyan, text("Cyan")),
|
||||||
color(Color::CyanLight, text(L"CyanLight")),
|
color(Color::CyanLight, text("CyanLight")),
|
||||||
color(Color::Green, text(L"Green")),
|
color(Color::Green, text("Green")),
|
||||||
color(Color::GreenLight, text(L"GreenLight")),
|
color(Color::GreenLight, text("GreenLight")),
|
||||||
color(Color::Magenta, text(L"Magenta")),
|
color(Color::Magenta, text("Magenta")),
|
||||||
color(Color::MagentaLight, text(L"MagentaLight")),
|
color(Color::MagentaLight, text("MagentaLight")),
|
||||||
color(Color::Red, text(L"Red")),
|
color(Color::Red, text("Red")),
|
||||||
color(Color::RedLight, text(L"RedLight")),
|
color(Color::RedLight, text("RedLight")),
|
||||||
color(Color::Yellow, text(L"Yellow")),
|
color(Color::Yellow, text("Yellow")),
|
||||||
color(Color::YellowLight, text(L"YellowLight")),
|
color(Color::YellowLight, text("YellowLight")),
|
||||||
}),
|
}),
|
||||||
vbox({
|
vbox({
|
||||||
bgcolor(Color::Default, text(L"Default")),
|
bgcolor(Color::Default, text("Default")),
|
||||||
bgcolor(Color::Black, text(L"Black")),
|
bgcolor(Color::Black, text("Black")),
|
||||||
bgcolor(Color::GrayDark, text(L"GrayDark")),
|
bgcolor(Color::GrayDark, text("GrayDark")),
|
||||||
bgcolor(Color::GrayLight, text(L"GrayLight")),
|
bgcolor(Color::GrayLight, text("GrayLight")),
|
||||||
bgcolor(Color::White, text(L"White")),
|
bgcolor(Color::White, text("White")),
|
||||||
bgcolor(Color::Blue, text(L"Blue")),
|
bgcolor(Color::Blue, text("Blue")),
|
||||||
bgcolor(Color::BlueLight, text(L"BlueLight")),
|
bgcolor(Color::BlueLight, text("BlueLight")),
|
||||||
bgcolor(Color::Cyan, text(L"Cyan")),
|
bgcolor(Color::Cyan, text("Cyan")),
|
||||||
bgcolor(Color::CyanLight, text(L"CyanLight")),
|
bgcolor(Color::CyanLight, text("CyanLight")),
|
||||||
bgcolor(Color::Green, text(L"Green")),
|
bgcolor(Color::Green, text("Green")),
|
||||||
bgcolor(Color::GreenLight, text(L"GreenLight")),
|
bgcolor(Color::GreenLight, text("GreenLight")),
|
||||||
bgcolor(Color::Magenta, text(L"Magenta")),
|
bgcolor(Color::Magenta, text("Magenta")),
|
||||||
bgcolor(Color::MagentaLight, text(L"MagentaLight")),
|
bgcolor(Color::MagentaLight, text("MagentaLight")),
|
||||||
bgcolor(Color::Red, text(L"Red")),
|
bgcolor(Color::Red, text("Red")),
|
||||||
bgcolor(Color::RedLight, text(L"RedLight")),
|
bgcolor(Color::RedLight, text("RedLight")),
|
||||||
bgcolor(Color::Yellow, text(L"Yellow")),
|
bgcolor(Color::Yellow, text("Yellow")),
|
||||||
bgcolor(Color::YellowLight, text(L"YellowLight")),
|
bgcolor(Color::YellowLight, text("YellowLight")),
|
||||||
}),
|
}),
|
||||||
}) |
|
}) |
|
||||||
hcenter | border;
|
hcenter | border;
|
||||||
@ -299,7 +297,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto render_gauge = [&shift](int delta) {
|
auto render_gauge = [&shift](int delta) {
|
||||||
float progress = (shift + delta) % 1000 / 1000.f;
|
float progress = (shift + delta) % 1000 / 1000.f;
|
||||||
return hbox({
|
return hbox({
|
||||||
text(std::to_wstring(int(progress * 100)) + L"% ") |
|
text(std::to_string(int(progress * 100)) + "% ") |
|
||||||
size(WIDTH, EQUAL, 5),
|
size(WIDTH, EQUAL, 5),
|
||||||
gauge(progress),
|
gauge(progress),
|
||||||
});
|
});
|
||||||
@ -329,8 +327,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
int tab_index = 0;
|
int tab_index = 0;
|
||||||
std::vector<std::wstring> tab_entries = {
|
std::vector<std::string> tab_entries = {
|
||||||
L"htop", L"color", L"spinner", L"gauge", L"compiler",
|
"htop", "color", "spinner", "gauge", "compiler",
|
||||||
};
|
};
|
||||||
auto tab_selection = Toggle(&tab_entries, &tab_index);
|
auto tab_selection = Toggle(&tab_entries, &tab_index);
|
||||||
auto tab_content = Container::Tab(
|
auto tab_content = Container::Tab(
|
||||||
@ -350,7 +348,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
auto main_renderer = Renderer(main_container, [&] {
|
auto main_renderer = Renderer(main_container, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"FTXUI Demo") | bold | hcenter,
|
text("FTXUI Demo") | bold | hcenter,
|
||||||
tab_selection->Render() | hcenter,
|
tab_selection->Render() | hcenter,
|
||||||
tab_content->Render() | flex,
|
tab_content->Render() | flex,
|
||||||
});
|
});
|
||||||
|
@ -5,17 +5,15 @@
|
|||||||
#include "ftxui/component/component.hpp" // for Renderer, Vertical
|
#include "ftxui/component/component.hpp" // for Renderer, Vertical
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/component_options.hpp" // for InputOption
|
#include "ftxui/component/component_options.hpp" // for InputOption
|
||||||
#include "ftxui/component/deprecated.hpp" // for Input
|
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/elements.hpp" // for hbox, separator, Element, operator|, vbox, border
|
#include "ftxui/dom/elements.hpp" // for hbox, separator, Element, operator|, vbox, border
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
std::wstring first_name;
|
std::string first_name;
|
||||||
std::wstring last_name;
|
std::string last_name;
|
||||||
std::wstring password;
|
std::string password;
|
||||||
|
|
||||||
Component input_first_name = Input(&first_name, "first name");
|
Component input_first_name = Input(&first_name, "first name");
|
||||||
Component input_last_name = Input(&last_name, "last name");
|
Component input_last_name = Input(&last_name, "last name");
|
||||||
@ -32,11 +30,11 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
auto renderer = Renderer(component, [&] {
|
auto renderer = Renderer(component, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"Hello " + first_name + L" " + last_name),
|
text("Hello " + first_name + " " + last_name),
|
||||||
separator(),
|
separator(),
|
||||||
hbox(text(L" First name : "), input_first_name->Render()),
|
hbox(text(" First name : "), input_first_name->Render()),
|
||||||
hbox(text(L" Last name : "), input_last_name->Render()),
|
hbox(text(" Last name : "), input_last_name->Render()),
|
||||||
hbox(text(L" Password : "), input_password->Render()),
|
hbox(text(" Password : "), input_password->Render()),
|
||||||
}) |
|
}) |
|
||||||
border;
|
border;
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
||||||
#include <string> // for wstring, basic_string, allocator
|
#include <string> // for string, basic_string, allocator
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -12,10 +12,10 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
std::vector<std::wstring> entries = {
|
std::vector<std::string> entries = {
|
||||||
L"entry 1",
|
"entry 1",
|
||||||
L"entry 2",
|
"entry 2",
|
||||||
L"entry 3",
|
"entry 3",
|
||||||
};
|
};
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <memory> // for allocator, __shared_ptr_access
|
#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 <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -8,21 +8,17 @@
|
|||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/component_options.hpp" // for MenuOption
|
#include "ftxui/component/component_options.hpp" // for MenuOption
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border
|
|
||||||
#include "ftxui/screen/string.hpp" // for to_wstring
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
std::vector<std::wstring> left_menu_entries = {
|
std::vector<std::string> left_menu_entries = {
|
||||||
L"0%", L"10%", L"20%", L"30%", L"40%",
|
"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%",
|
||||||
L"50%", L"60%", L"70%", L"80%", L"90%",
|
|
||||||
};
|
};
|
||||||
std::vector<std::wstring> right_menu_entries = {
|
std::vector<std::string> right_menu_entries = {
|
||||||
L"0%", L"1%", L"2%", L"3%", L"4%", L"5%",
|
"0%", "1%", "2%", "3%", "4%", "5%", "6%", "7%", "8%", "9%", "10%",
|
||||||
L"6%", L"7%", L"8%", L"9%", L"10%",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto menu_option = MenuOption();
|
auto menu_option = MenuOption();
|
||||||
@ -47,14 +43,14 @@ int main(int argc, const char* argv[]) {
|
|||||||
hbox({
|
hbox({
|
||||||
// -------- Left Menu --------------
|
// -------- Left Menu --------------
|
||||||
vbox({
|
vbox({
|
||||||
hcenter(bold(text(L"Percentage by 10%"))),
|
hcenter(bold(text("Percentage by 10%"))),
|
||||||
separator(),
|
separator(),
|
||||||
left_menu_->Render(),
|
left_menu_->Render(),
|
||||||
}),
|
}),
|
||||||
separator(),
|
separator(),
|
||||||
// -------- Right Menu --------------
|
// -------- Right Menu --------------
|
||||||
vbox({
|
vbox({
|
||||||
hcenter(bold(text(L"Percentage by 1%"))),
|
hcenter(bold(text("Percentage by 1%"))),
|
||||||
separator(),
|
separator(),
|
||||||
right_menu_->Render(),
|
right_menu_->Render(),
|
||||||
}),
|
}),
|
||||||
@ -64,12 +60,12 @@ int main(int argc, const char* argv[]) {
|
|||||||
// -------- Bottom panel --------------
|
// -------- Bottom panel --------------
|
||||||
vbox({
|
vbox({
|
||||||
hbox({
|
hbox({
|
||||||
text(L" gauge : "),
|
text(" gauge : "),
|
||||||
gauge(sum / 100.0),
|
gauge(sum / 100.0),
|
||||||
}),
|
}),
|
||||||
hbox({
|
hbox({
|
||||||
text(L" text : "),
|
text(" text : "),
|
||||||
text(to_wstring(std::to_string(sum) + " %")),
|
text(std::to_string(sum) + " %"),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
}) |
|
}) |
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
#include <stdlib.h> // for EXIT_SUCCESS
|
#include <stdlib.h> // for EXIT_SUCCESS
|
||||||
#include <memory> // for allocator, __shared_ptr_access
|
#include <memory> // for allocator, __shared_ptr_access
|
||||||
#include <string> // for wstring, operator+, basic_string, char_traits
|
#include <string> // for string, operator+, basic_string, to_string, char_traits
|
||||||
#include <vector> // for vector, __alloc_traits<>::value_type
|
#include <vector> // for vector, __alloc_traits<>::value_type
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Menu, Renderer, Horizontal, Vertical
|
#include "ftxui/component/component.hpp" // for Menu, Renderer, Horizontal, Vertical
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, Element, operator|, window, flex, vbox
|
||||||
#include "ftxui/dom/elements.hpp" // for Element, operator|, window, flex, vbox
|
|
||||||
#include "ftxui/screen/string.hpp" // for to_wstring
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
Component Window(std::wstring title, Component component) {
|
Component Window(std::string title, Component component) {
|
||||||
return Renderer(component, [component, title] { //
|
return Renderer(component, [component, title] { //
|
||||||
return window(text(title), component->Render()) | flex;
|
return window(text(title), component->Render()) | flex;
|
||||||
});
|
});
|
||||||
@ -21,46 +19,46 @@ Component Window(std::wstring title, Component component) {
|
|||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
int menu_selected[] = {0, 0, 0};
|
int menu_selected[] = {0, 0, 0};
|
||||||
std::vector<std::vector<std::wstring>> menu_entries = {
|
std::vector<std::vector<std::string>> menu_entries = {
|
||||||
{
|
{
|
||||||
L"Ananas",
|
"Ananas",
|
||||||
L"Raspberry",
|
"Raspberry",
|
||||||
L"Citrus",
|
"Citrus",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
L"Potatoes",
|
"Potatoes",
|
||||||
L"Weat",
|
"Weat",
|
||||||
L"Rise",
|
"Rise",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
L"Carrot",
|
"Carrot",
|
||||||
L"Lettuce",
|
"Lettuce",
|
||||||
L"Tomato",
|
"Tomato",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
int menu_selected_global = 0;
|
int menu_selected_global = 0;
|
||||||
auto menu_global = Container::Vertical(
|
auto menu_global = Container::Vertical(
|
||||||
{
|
{
|
||||||
Window(L"Menu 1", Menu(&menu_entries[0], &menu_selected[0])),
|
Window("Menu 1", Menu(&menu_entries[0], &menu_selected[0])),
|
||||||
Window(L"Menu 2", Menu(&menu_entries[1], &menu_selected[1])),
|
Window("Menu 2", Menu(&menu_entries[1], &menu_selected[1])),
|
||||||
Window(L"Menu 3", Menu(&menu_entries[2], &menu_selected[2])),
|
Window("Menu 3", Menu(&menu_entries[2], &menu_selected[2])),
|
||||||
},
|
},
|
||||||
&menu_selected_global);
|
&menu_selected_global);
|
||||||
|
|
||||||
auto info = Renderer([&] {
|
auto info = Renderer([&] {
|
||||||
int g = menu_selected_global;
|
int g = menu_selected_global;
|
||||||
std::wstring value = menu_entries[g][menu_selected[g]];
|
std::string value = menu_entries[g][menu_selected[g]];
|
||||||
return window(text(L"Content"), //
|
return window(text("Content"), //
|
||||||
vbox({
|
vbox({
|
||||||
text(L"menu_selected_global = " + to_wstring(g)),
|
text("menu_selected_global = " + std::to_string(g)),
|
||||||
text(L"menu_selected[0] = " +
|
text("menu_selected[0] = " +
|
||||||
to_wstring(menu_selected[0])),
|
std::to_string(menu_selected[0])),
|
||||||
text(L"menu_selected[1] = " +
|
text("menu_selected[1] = " +
|
||||||
to_wstring(menu_selected[1])),
|
std::to_string(menu_selected[1])),
|
||||||
text(L"menu_selected[2] = " +
|
text("menu_selected[2] = " +
|
||||||
to_wstring(menu_selected[2])),
|
std::to_string(menu_selected[2])),
|
||||||
text(L"Value = " + value),
|
text("Value = " + value),
|
||||||
})) |
|
})) |
|
||||||
flex;
|
flex;
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
|
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -15,8 +15,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
std::vector<std::wstring> entries = {
|
std::vector<std::string> entries = {
|
||||||
L"Monkey", L"Dog", L"Cat", L"Bird", L"Elephant",
|
"Monkey", "Dog", "Cat", "Bird", "Elephant",
|
||||||
};
|
};
|
||||||
int menu_1_selected_ = 0;
|
int menu_1_selected_ = 0;
|
||||||
int menu_2_selected_ = 0;
|
int menu_2_selected_ = 0;
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for wstring, basic_string, char_traits, operator+
|
#include <string> // for string, basic_string, char_traits, operator+
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Button, Renderer, Horizontal, Tab
|
#include "ftxui/component/component.hpp" // for Button, Renderer, Horizontal, Tab
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for operator|, Element, filler, text, hbox, separator, center, vbox, bold, border, clear_under, dbox, size, GREATER_THAN, HEIGHT
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, filler, hbox, separator, center, vbox, bold, border, clear_under, dbox, size, GREATER_THAN, HEIGHT
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
@ -17,7 +16,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
// The current rating of FTXUI.
|
// The current rating of FTXUI.
|
||||||
std::wstring rating = L"3/5 stars";
|
std::string rating = "3/5 stars";
|
||||||
|
|
||||||
// At depth=0, two buttons. One for rating FTXUI and one for quitting.
|
// At depth=0, two buttons. One for rating FTXUI and one for quitting.
|
||||||
auto button_rate_ftxui = Button("Rate FTXUI", [&] { depth = 1; });
|
auto button_rate_ftxui = Button("Rate FTXUI", [&] { depth = 1; });
|
||||||
@ -29,9 +28,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
});
|
});
|
||||||
auto depth_0_renderer = Renderer(depth_0_container, [&] {
|
auto depth_0_renderer = Renderer(depth_0_container, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"Modal dialog example"),
|
text("Modal dialog example"),
|
||||||
separator(),
|
separator(),
|
||||||
text(L"☆☆☆ FTXUI:" + rating + L" ☆☆☆") | bold,
|
text("☆☆☆ FTXUI:" + rating + " ☆☆☆") | bold,
|
||||||
filler(),
|
filler(),
|
||||||
hbox({
|
hbox({
|
||||||
button_rate_ftxui->Render(),
|
button_rate_ftxui->Render(),
|
||||||
@ -43,10 +42,10 @@ int main(int argc, const char* argv[]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// At depth=1, The "modal" window.
|
// At depth=1, The "modal" window.
|
||||||
std::vector<std::wstring> rating_labels = {
|
std::vector<std::string> rating_labels = {
|
||||||
L"1/5 stars", L"2/5 stars", L"3/5 stars", L"4/5 stars", L"5/5 stars",
|
"1/5 stars", "2/5 stars", "3/5 stars", "4/5 stars", "5/5 stars",
|
||||||
};
|
};
|
||||||
auto on_rating = [&](std::wstring new_rating) {
|
auto on_rating = [&](std::string new_rating) {
|
||||||
rating = new_rating;
|
rating = new_rating;
|
||||||
depth = 0;
|
depth = 0;
|
||||||
};
|
};
|
||||||
@ -60,7 +59,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
auto depth_1_renderer = Renderer(depth_1_container, [&] {
|
auto depth_1_renderer = Renderer(depth_1_container, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"Do you like FTXUI?"),
|
text("Do you like FTXUI?"),
|
||||||
separator(),
|
separator(),
|
||||||
hbox(depth_1_container->Render()),
|
hbox(depth_1_container->Render()),
|
||||||
}) |
|
}) |
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <string> // for wstring, allocator, basic_string
|
#include <string> // for string, allocator, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -8,11 +8,11 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
std::vector<std::wstring> radiobox_list = {
|
std::vector<std::string> radiobox_list = {
|
||||||
L"Use gcc",
|
"Use gcc",
|
||||||
L"Use clang",
|
"Use clang",
|
||||||
L"Use emscripten",
|
"Use emscripten",
|
||||||
L"Use tcc",
|
"Use tcc",
|
||||||
};
|
};
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
#include <memory> // for __shared_ptr_access, shared_ptr
|
#include <memory> // for shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for wstring, operator+
|
#include <string> // for string, basic_string, operator+, to_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Radiobox, Renderer
|
#include "ftxui/component/component.hpp" // for Radiobox, Renderer
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/elements.hpp" // for Element, operator|, size, border, frame, HEIGHT, LESS_THAN
|
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, HEIGHT, LESS_THAN
|
||||||
#include "ftxui/screen/string.hpp" // for to_wstring
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
std::vector<std::wstring> entries;
|
std::vector<std::string> entries;
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 30; ++i)
|
for (int i = 0; i < 30; ++i)
|
||||||
entries.push_back(L"RadioBox " + to_wstring(i));
|
entries.push_back("RadioBox " + std::to_string(i));
|
||||||
auto radiobox = Radiobox(&entries, &selected);
|
auto radiobox = Radiobox(&entries, &selected);
|
||||||
auto renderer = Renderer(radiobox, [&] {
|
auto renderer = Renderer(radiobox, [&] {
|
||||||
return radiobox->Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
return radiobox->Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include "ftxui/component/component.hpp" // for Renderer, Button, Vertical
|
#include "ftxui/component/component.hpp" // for Renderer, Button, Vertical
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for operator|, Element, text, bold, border, center, color
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, bold, border, center, color
|
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
@ -18,18 +17,18 @@ int main(int argc, const char* argv[]) {
|
|||||||
// 1. Example of focusable renderer:
|
// 1. Example of focusable renderer:
|
||||||
auto renderer_focusable = Renderer([](bool focused) {
|
auto renderer_focusable = Renderer([](bool focused) {
|
||||||
if (focused)
|
if (focused)
|
||||||
return text(L"FOCUSABLE RENDERER()") | center | bold | border;
|
return text("FOCUSABLE RENDERER()") | center | bold | border;
|
||||||
else
|
else
|
||||||
return text(L" Focusable renderer() ") | center | border;
|
return text(" Focusable renderer() ") | center | border;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. Examples of a non focusable renderer.
|
// 2. Examples of a non focusable renderer.
|
||||||
auto renderer_non_focusable = Renderer([&] {
|
auto renderer_non_focusable = Renderer([&] {
|
||||||
return text(L"~~~~~ Non Focusable renderer() ~~~~~"); //
|
return text("~~~~~ Non Focusable renderer() ~~~~~"); //
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3. Renderer can wrap other components to redefine their Render() function.
|
// 3. Renderer can wrap other components to redefine their Render() function.
|
||||||
auto button = Button(L"Wrapped quit button", screen.ExitLoopClosure());
|
auto button = Button("Wrapped quit button", screen.ExitLoopClosure());
|
||||||
auto renderer_wrap = Renderer(button, [&] {
|
auto renderer_wrap = Renderer(button, [&] {
|
||||||
if (button->Focused())
|
if (button->Focused())
|
||||||
return button->Render() | bold | color(Color::Red);
|
return button->Render() | bold | color(Color::Red);
|
||||||
|
@ -4,19 +4,18 @@
|
|||||||
#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
|
#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
|
||||||
#include "ftxui/dom/elements.hpp" // for Element, operator|, center, border
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
auto screen = ScreenInteractive::Fullscreen();
|
||||||
|
|
||||||
auto middle = Renderer([] { return text(L"middle") | center; });
|
auto middle = Renderer([] { return text("middle") | center; });
|
||||||
auto left = Renderer([] { return text(L"Left") | center; });
|
auto left = Renderer([] { return text("Left") | center; });
|
||||||
auto right = Renderer([] { return text(L"right") | center; });
|
auto right = Renderer([] { return text("right") | center; });
|
||||||
auto top = Renderer([] { return text(L"top") | center; });
|
auto top = Renderer([] { return text("top") | center; });
|
||||||
auto bottom = Renderer([] { return text(L"bottom") | center; });
|
auto bottom = Renderer([] { return text("bottom") | center; });
|
||||||
|
|
||||||
int left_size = 20;
|
int left_size = 20;
|
||||||
int right_size = 20;
|
int right_size = 20;
|
||||||
|
@ -7,7 +7,7 @@ using namespace ftxui;
|
|||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
int value = 50;
|
int value = 50;
|
||||||
auto slider = Slider(L"Value:", &value, 0, 100, 1);
|
auto slider = Slider("Value:", &value, 0, 100, 1);
|
||||||
screen.Loop(slider);
|
screen.Loop(slider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for char_traits, operator+, to_wstring
|
#include <string> // for char_traits, operator+, to_string
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Slider, Renderer, Vertical
|
#include "ftxui/component/component.hpp" // for Slider, Renderer, Vertical
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for separator, operator|, Element, size, text, vbox, xflex, bgcolor, hbox, GREATER_THAN, WIDTH, border, HEIGHT, LESS_THAN
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, operator|, Element, size, vbox, xflex, bgcolor, hbox, GREATER_THAN, WIDTH, border, HEIGHT, LESS_THAN
|
|
||||||
#include "ftxui/screen/color.hpp" // for Color
|
#include "ftxui/screen/color.hpp" // for Color
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
Element ColorTile(int red, int green, int blue) {
|
Element ColorTile(int red, int green, int blue) {
|
||||||
return text(L"") | size(WIDTH, GREATER_THAN, 14) |
|
return text("") | size(WIDTH, GREATER_THAN, 14) |
|
||||||
size(HEIGHT, GREATER_THAN, 7) | bgcolor(Color::RGB(red, green, blue));
|
size(HEIGHT, GREATER_THAN, 7) | bgcolor(Color::RGB(red, green, blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
Element ColorString(int red, int green, int blue) {
|
Element ColorString(int red, int green, int blue) {
|
||||||
return text(L"RGB = (" + //
|
return text("RGB = (" + //
|
||||||
std::to_wstring(red) + L"," + //
|
std::to_string(red) + "," + //
|
||||||
std::to_wstring(green) + L"," + //
|
std::to_string(green) + "," + //
|
||||||
std::to_wstring(blue) + L")" //
|
std::to_string(blue) + ")" //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,9 +27,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
int red = 128;
|
int red = 128;
|
||||||
int green = 25;
|
int green = 25;
|
||||||
int blue = 100;
|
int blue = 100;
|
||||||
auto slider_red = Slider(L"Red :", &red, 0, 255, 1);
|
auto slider_red = Slider("Red :", &red, 0, 255, 1);
|
||||||
auto slider_green = Slider(L"Green:", &green, 0, 255, 1);
|
auto slider_green = Slider("Green:", &green, 0, 255, 1);
|
||||||
auto slider_blue = Slider(L"Blue :", &blue, 0, 255, 1);
|
auto slider_blue = Slider("Blue :", &blue, 0, 255, 1);
|
||||||
|
|
||||||
auto container = Container::Vertical({
|
auto container = Container::Vertical({
|
||||||
slider_red,
|
slider_red,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <memory> // for allocator, __shared_ptr_access, shared_ptr
|
#include <memory> // for allocator, __shared_ptr_access, shared_ptr
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -11,33 +11,33 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
std::vector<std::wstring> tab_values{
|
std::vector<std::string> tab_values{
|
||||||
L"tab_1",
|
"tab_1",
|
||||||
L"tab_2",
|
"tab_2",
|
||||||
L"tab_3",
|
"tab_3",
|
||||||
};
|
};
|
||||||
int tab_selected = 0;
|
int tab_selected = 0;
|
||||||
auto tab_toggle = Toggle(&tab_values, &tab_selected);
|
auto tab_toggle = Toggle(&tab_values, &tab_selected);
|
||||||
|
|
||||||
std::vector<std::wstring> tab_1_entries{
|
std::vector<std::string> tab_1_entries{
|
||||||
L"Forest",
|
"Forest",
|
||||||
L"Water",
|
"Water",
|
||||||
L"I don't know",
|
"I don't know",
|
||||||
};
|
};
|
||||||
int tab_1_selected = 0;
|
int tab_1_selected = 0;
|
||||||
|
|
||||||
std::vector<std::wstring> tab_2_entries{
|
std::vector<std::string> tab_2_entries{
|
||||||
L"Hello",
|
"Hello",
|
||||||
L"Hi",
|
"Hi",
|
||||||
L"Hay",
|
"Hay",
|
||||||
};
|
};
|
||||||
int tab_2_selected = 0;
|
int tab_2_selected = 0;
|
||||||
|
|
||||||
std::vector<std::wstring> tab_3_entries{
|
std::vector<std::string> tab_3_entries{
|
||||||
L"Table",
|
"Table",
|
||||||
L"Nothing",
|
"Nothing",
|
||||||
L"Is",
|
"Is",
|
||||||
L"Empty",
|
"Empty",
|
||||||
};
|
};
|
||||||
int tab_3_selected = 0;
|
int tab_3_selected = 0;
|
||||||
auto tab_container = Container::Tab(
|
auto tab_container = Container::Tab(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <memory> // for allocator, __shared_ptr_access, shared_ptr
|
#include <memory> // for allocator, __shared_ptr_access, shared_ptr
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -11,33 +11,33 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
std::vector<std::wstring> tab_values{
|
std::vector<std::string> tab_values{
|
||||||
L"tab_1",
|
"tab_1",
|
||||||
L"tab_2",
|
"tab_2",
|
||||||
L"tab_3",
|
"tab_3",
|
||||||
};
|
};
|
||||||
int tab_selected = 0;
|
int tab_selected = 0;
|
||||||
auto tab_menu = Menu(&tab_values, &tab_selected);
|
auto tab_menu = Menu(&tab_values, &tab_selected);
|
||||||
|
|
||||||
std::vector<std::wstring> tab_1_entries{
|
std::vector<std::string> tab_1_entries{
|
||||||
L"Forest",
|
"Forest",
|
||||||
L"Water",
|
"Water",
|
||||||
L"I don't know",
|
"I don't know",
|
||||||
};
|
};
|
||||||
int tab_1_selected = 0;
|
int tab_1_selected = 0;
|
||||||
|
|
||||||
std::vector<std::wstring> tab_2_entries{
|
std::vector<std::string> tab_2_entries{
|
||||||
L"Hello",
|
"Hello",
|
||||||
L"Hi",
|
"Hi",
|
||||||
L"Hay",
|
"Hay",
|
||||||
};
|
};
|
||||||
int tab_2_selected = 0;
|
int tab_2_selected = 0;
|
||||||
|
|
||||||
std::vector<std::wstring> tab_3_entries{
|
std::vector<std::string> tab_3_entries{
|
||||||
L"Table",
|
"Table",
|
||||||
L"Nothing",
|
"Nothing",
|
||||||
L"Is",
|
"Is",
|
||||||
L"Empty",
|
"Empty",
|
||||||
};
|
};
|
||||||
int tab_3_selected = 0;
|
int tab_3_selected = 0;
|
||||||
auto tab_container = Container::Tab(
|
auto tab_container = Container::Tab(
|
||||||
|
@ -1,33 +1,32 @@
|
|||||||
#include <memory> // for allocator, __shared_ptr_access
|
#include <memory> // for allocator, __shared_ptr_access
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Toggle, Renderer, Vertical
|
#include "ftxui/component/component.hpp" // for Toggle, Renderer, Vertical
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, hbox, vbox, Element
|
||||||
#include "ftxui/dom/elements.hpp" // for hbox, vbox, Element
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
std::vector<std::wstring> toggle_1_entries = {
|
std::vector<std::string> toggle_1_entries = {
|
||||||
L"On",
|
"On",
|
||||||
L"Off",
|
"Off",
|
||||||
};
|
};
|
||||||
std::vector<std::wstring> toggle_2_entries = {
|
std::vector<std::string> toggle_2_entries = {
|
||||||
L"Enabled",
|
"Enabled",
|
||||||
L"Disabled",
|
"Disabled",
|
||||||
};
|
};
|
||||||
std::vector<std::wstring> toggle_3_entries = {
|
std::vector<std::string> toggle_3_entries = {
|
||||||
L"10€",
|
"10€",
|
||||||
L"0€",
|
"0€",
|
||||||
};
|
};
|
||||||
std::vector<std::wstring> toggle_4_entries = {
|
std::vector<std::string> toggle_4_entries = {
|
||||||
L"Nothing",
|
"Nothing",
|
||||||
L"One element",
|
"One element",
|
||||||
L"Several elements",
|
"Several elements",
|
||||||
};
|
};
|
||||||
|
|
||||||
int toggle_1_selected = 0;
|
int toggle_1_selected = 0;
|
||||||
@ -48,12 +47,12 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
auto renderer = Renderer(container, [&] {
|
auto renderer = Renderer(container, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text(L"Choose your options:"),
|
text("Choose your options:"),
|
||||||
text(L""),
|
text(""),
|
||||||
hbox(text(L" * Poweroff on startup : "), toggle_1->Render()),
|
hbox(text(" * Poweroff on startup : "), toggle_1->Render()),
|
||||||
hbox(text(L" * Out of process : "), toggle_2->Render()),
|
hbox(text(" * Out of process : "), toggle_2->Render()),
|
||||||
hbox(text(L" * Price of the information : "), toggle_3->Render()),
|
hbox(text(" * Price of the information : "), toggle_3->Render()),
|
||||||
hbox(text(L" * Number of elements : "), toggle_4->Render()),
|
hbox(text(" * Number of elements : "), toggle_4->Render()),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, vbox, border, Element, hbox
|
#include <ftxui/dom/elements.hpp> // for text, operator|, vbox, border, Element, Fit, hbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -11,21 +10,21 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto document = //
|
auto document = //
|
||||||
hbox({
|
hbox({
|
||||||
vbox({
|
vbox({
|
||||||
text(L"Line 1"),
|
text("Line 1"),
|
||||||
text(L"Line 2"),
|
text("Line 2"),
|
||||||
text(L"Line 3"),
|
text("Line 3"),
|
||||||
}) | border,
|
}) | border,
|
||||||
|
|
||||||
vbox({
|
vbox({
|
||||||
text(L"Line 4"),
|
text("Line 4"),
|
||||||
text(L"Line 5"),
|
text("Line 5"),
|
||||||
text(L"Line 6"),
|
text("Line 6"),
|
||||||
}) | border,
|
}) | border,
|
||||||
|
|
||||||
vbox({
|
vbox({
|
||||||
text(L"Line 7"),
|
text("Line 7"),
|
||||||
text(L"Line 8"),
|
text("Line 8"),
|
||||||
text(L"Line 9"),
|
text("Line 9"),
|
||||||
}) | border,
|
}) | border,
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <ftxui/screen/terminal.hpp> // for Terminal, Terminal::Color, Terminal::Palette16, Terminal::Palette256, Terminal::TrueColor
|
#include <ftxui/screen/terminal.hpp> // for ColorSupport, Color, Palette16, Palette256, TrueColor
|
||||||
#include <memory> // for allocator, shared_ptr
|
#include <memory> // for allocator, shared_ptr
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
|
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, bgcolor, color, vbox, hbox, separator, operator|, Elements, Element, Fit, border
|
||||||
#include "ftxui/dom/elements.hpp" // for bgcolor, color, vbox, hbox, separator, operator|, Elements, Element, border
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Black, Color::Blue, Color::BlueLight, Color::Cyan, Color::CyanLight, Color::Default, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::RedLight, Color::White, Color::Yellow, Color::YellowLight, Color::Palette256, ftxui
|
#include "ftxui/screen/color.hpp" // for Color, Color::Black, Color::Blue, Color::BlueLight, Color::Cyan, Color::CyanLight, Color::Default, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::RedLight, Color::White, Color::Yellow, Color::YellowLight, Color::Palette256, ftxui
|
||||||
|
|
||||||
@ -16,52 +15,52 @@ int main(int argc, const char* argv[]) {
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
auto basic_color_display =
|
auto basic_color_display =
|
||||||
vbox(
|
vbox(
|
||||||
text(L"16 color palette:"),
|
text("16 color palette:"),
|
||||||
separator(),
|
separator(),
|
||||||
hbox(
|
hbox(
|
||||||
vbox(
|
vbox(
|
||||||
color(Color::Default, text(L"Default")),
|
color(Color::Default, text("Default")),
|
||||||
color(Color::Black, text(L"Black")),
|
color(Color::Black, text("Black")),
|
||||||
color(Color::GrayDark, text(L"GrayDark")),
|
color(Color::GrayDark, text("GrayDark")),
|
||||||
color(Color::GrayLight, text(L"GrayLight")),
|
color(Color::GrayLight, text("GrayLight")),
|
||||||
color(Color::White, text(L"White")),
|
color(Color::White, text("White")),
|
||||||
color(Color::Blue, text(L"Blue")),
|
color(Color::Blue, text("Blue")),
|
||||||
color(Color::BlueLight, text(L"BlueLight")),
|
color(Color::BlueLight, text("BlueLight")),
|
||||||
color(Color::Cyan, text(L"Cyan")),
|
color(Color::Cyan, text("Cyan")),
|
||||||
color(Color::CyanLight, text(L"CyanLight")),
|
color(Color::CyanLight, text("CyanLight")),
|
||||||
color(Color::Green, text(L"Green")),
|
color(Color::Green, text("Green")),
|
||||||
color(Color::GreenLight, text(L"GreenLight")),
|
color(Color::GreenLight, text("GreenLight")),
|
||||||
color(Color::Magenta, text(L"Magenta")),
|
color(Color::Magenta, text("Magenta")),
|
||||||
color(Color::MagentaLight, text(L"MagentaLight")),
|
color(Color::MagentaLight, text("MagentaLight")),
|
||||||
color(Color::Red, text(L"Red")),
|
color(Color::Red, text("Red")),
|
||||||
color(Color::RedLight, text(L"RedLight")),
|
color(Color::RedLight, text("RedLight")),
|
||||||
color(Color::Yellow, text(L"Yellow")),
|
color(Color::Yellow, text("Yellow")),
|
||||||
color(Color::YellowLight, text(L"YellowLight"))
|
color(Color::YellowLight, text("YellowLight"))
|
||||||
),
|
),
|
||||||
vbox(
|
vbox(
|
||||||
bgcolor(Color::Default, text(L"Default")),
|
bgcolor(Color::Default, text("Default")),
|
||||||
bgcolor(Color::Black, text(L"Black")),
|
bgcolor(Color::Black, text("Black")),
|
||||||
bgcolor(Color::GrayDark, text(L"GrayDark")),
|
bgcolor(Color::GrayDark, text("GrayDark")),
|
||||||
bgcolor(Color::GrayLight, text(L"GrayLight")),
|
bgcolor(Color::GrayLight, text("GrayLight")),
|
||||||
bgcolor(Color::White, text(L"White")),
|
bgcolor(Color::White, text("White")),
|
||||||
bgcolor(Color::Blue, text(L"Blue")),
|
bgcolor(Color::Blue, text("Blue")),
|
||||||
bgcolor(Color::BlueLight, text(L"BlueLight")),
|
bgcolor(Color::BlueLight, text("BlueLight")),
|
||||||
bgcolor(Color::Cyan, text(L"Cyan")),
|
bgcolor(Color::Cyan, text("Cyan")),
|
||||||
bgcolor(Color::CyanLight, text(L"CyanLight")),
|
bgcolor(Color::CyanLight, text("CyanLight")),
|
||||||
bgcolor(Color::Green, text(L"Green")),
|
bgcolor(Color::Green, text("Green")),
|
||||||
bgcolor(Color::GreenLight, text(L"GreenLight")),
|
bgcolor(Color::GreenLight, text("GreenLight")),
|
||||||
bgcolor(Color::Magenta, text(L"Magenta")),
|
bgcolor(Color::Magenta, text("Magenta")),
|
||||||
bgcolor(Color::MagentaLight, text(L"MagentaLight")),
|
bgcolor(Color::MagentaLight, text("MagentaLight")),
|
||||||
bgcolor(Color::Red, text(L"Red")),
|
bgcolor(Color::Red, text("Red")),
|
||||||
bgcolor(Color::RedLight, text(L"RedLight")),
|
bgcolor(Color::RedLight, text("RedLight")),
|
||||||
bgcolor(Color::Yellow, text(L"Yellow")),
|
bgcolor(Color::Yellow, text("Yellow")),
|
||||||
bgcolor(Color::YellowLight, text(L"YellowLight"))
|
bgcolor(Color::YellowLight, text("YellowLight"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
auto palette_256_color_display = text(L"256 colors palette:");
|
auto palette_256_color_display = text("256 colors palette:");
|
||||||
{
|
{
|
||||||
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
|
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
|
||||||
Elements columns;
|
Elements columns;
|
||||||
@ -69,7 +68,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
Elements column_elements;
|
Elements column_elements;
|
||||||
for (auto& it : column) {
|
for (auto& it : column) {
|
||||||
column_elements.push_back(
|
column_elements.push_back(
|
||||||
text(L" ") | bgcolor(Color(Color::Palette256(it.index_256))));
|
text(" ") | bgcolor(Color(Color::Palette256(it.index_256))));
|
||||||
}
|
}
|
||||||
columns.push_back(hbox(std::move(column_elements)));
|
columns.push_back(hbox(std::move(column_elements)));
|
||||||
}
|
}
|
||||||
@ -81,14 +80,14 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True color display.
|
// True color display.
|
||||||
auto true_color_display = text(L"TrueColors: 24bits:");
|
auto true_color_display = text("TrueColors: 24bits:");
|
||||||
{
|
{
|
||||||
int saturation = 255;
|
int saturation = 255;
|
||||||
Elements array;
|
Elements array;
|
||||||
for (int value = 0; value < 255; value += 16) {
|
for (int value = 0; value < 255; value += 16) {
|
||||||
Elements line;
|
Elements line;
|
||||||
for (int hue = 0; hue < 255; hue += 6) {
|
for (int hue = 0; hue < 255; hue += 6) {
|
||||||
line.push_back(text(L"▀") //
|
line.push_back(text("▀") //
|
||||||
| color(Color::HSV(hue, saturation, value)) //
|
| color(Color::HSV(hue, saturation, value)) //
|
||||||
| bgcolor(Color::HSV(hue, saturation, value + 8)));
|
| bgcolor(Color::HSV(hue, saturation, value + 8)));
|
||||||
}
|
}
|
||||||
@ -104,22 +103,22 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto terminal_info =
|
auto terminal_info =
|
||||||
vbox({
|
vbox({
|
||||||
Terminal::ColorSupport() >= Terminal::Color::Palette16
|
Terminal::ColorSupport() >= Terminal::Color::Palette16
|
||||||
? text(L" 16 color palette support : Yes")
|
? text(" 16 color palette support : Yes")
|
||||||
: text(L" 16 color palette support : No"),
|
: text(" 16 color palette support : No"),
|
||||||
Terminal::ColorSupport() >= Terminal::Color::Palette256
|
Terminal::ColorSupport() >= Terminal::Color::Palette256
|
||||||
? text(L"256 color palette support : Yes")
|
? text("256 color palette support : Yes")
|
||||||
: text(L"256 color palette support : No"),
|
: text("256 color palette support : No"),
|
||||||
Terminal::ColorSupport() >= Terminal::Color::TrueColor
|
Terminal::ColorSupport() >= Terminal::Color::TrueColor
|
||||||
? text(L" True color support : Yes")
|
? text(" True color support : Yes")
|
||||||
: text(L" True color support : No"),
|
: text(" True color support : No"),
|
||||||
}) |
|
}) |
|
||||||
border;
|
border;
|
||||||
|
|
||||||
auto document = vbox({hbox({
|
auto document = vbox({hbox({
|
||||||
basic_color_display,
|
basic_color_display,
|
||||||
text(L" "),
|
text(" "),
|
||||||
palette_256_color_display,
|
palette_256_color_display,
|
||||||
text(L" "),
|
text(" "),
|
||||||
true_color_display,
|
true_color_display,
|
||||||
}),
|
}),
|
||||||
terminal_info});
|
terminal_info});
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for bgcolor, hbox, operator|, Elements, vbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, bgcolor, hbox, operator|, Elements, Fit, vbox, Element
|
||||||
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <string> // for allocator, string
|
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector, allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Palette256
|
#include "ftxui/screen/color.hpp" // for Color, Color::Palette256
|
||||||
#include "ftxui/screen/string.hpp" // for to_wstring
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
|
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
|
||||||
@ -23,8 +20,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
Elements column_elements;
|
Elements column_elements;
|
||||||
for (auto& it : column) {
|
for (auto& it : column) {
|
||||||
column_elements.push_back(hbox({
|
column_elements.push_back(hbox({
|
||||||
text(L" ") | bgcolor(Color(Color::Palette256(it.index_256))),
|
text(" ") | bgcolor(Color(Color::Palette256(it.index_256))),
|
||||||
text(to_wstring(std::string(it.name))),
|
text(it.name),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
columns_elements.push_back(vbox(std::move(column_elements)));
|
columns_elements.push_back(vbox(std::move(column_elements)));
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, Elements, bgcolor, color, hbox, vbox, Element
|
#include <ftxui/dom/elements.hpp> // for operator|, Elements, Fit, bgcolor, color, hbox, text, vbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color
|
#include "ftxui/screen/color.hpp" // for Color
|
||||||
@ -16,7 +15,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
for (int value = 0; value < 255; value += 20) {
|
for (int value = 0; value < 255; value += 20) {
|
||||||
Elements line;
|
Elements line;
|
||||||
for (int hue = 0; hue < 255; hue += 2) {
|
for (int hue = 0; hue < 255; hue += 2) {
|
||||||
line.push_back(text(L"▀") //
|
line.push_back(text("▀") //
|
||||||
| color(Color::HSV(hue, saturation, value)) //
|
| color(Color::HSV(hue, saturation, value)) //
|
||||||
| bgcolor(Color::HSV(hue, saturation, value + 10)));
|
| bgcolor(Color::HSV(hue, saturation, value + 10)));
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for hbox, bgcolor, operator|, vbox, Elements, window, Element
|
#include <ftxui/dom/elements.hpp> // for hbox, text, bgcolor, operator|, vbox, Elements, window, Element, Fit
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color
|
#include "ftxui/screen/color.hpp" // for Color
|
||||||
@ -21,26 +20,26 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
for (int value = 0; value < 255; value += 3) {
|
for (int value = 0; value < 255; value += 3) {
|
||||||
int v = value * value / 255;
|
int v = value * value / 255;
|
||||||
red_line.push_back(text(L" ") | bgcolor(Color::RGB(v, 0, 0)));
|
red_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, 0)));
|
||||||
green_line.push_back(text(L" ") | bgcolor(Color::RGB(0, v, 0)));
|
green_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, 0)));
|
||||||
blue_line.push_back(text(L" ") | bgcolor(Color::RGB(0, 0, v)));
|
blue_line.push_back(text(" ") | bgcolor(Color::RGB(0, 0, v)));
|
||||||
cyan_line.push_back(text(L" ") | bgcolor(Color::RGB(0, v, v)));
|
cyan_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, v)));
|
||||||
magenta_line.push_back(text(L" ") | bgcolor(Color::RGB(v, 0, v)));
|
magenta_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, v)));
|
||||||
yellow_line.push_back(text(L" ") | bgcolor(Color::RGB(v, v, 0)));
|
yellow_line.push_back(text(" ") | bgcolor(Color::RGB(v, v, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto document = vbox({
|
auto document = vbox({
|
||||||
window(text(L"Primary colors"),
|
window(text("Primary colors"),
|
||||||
vbox({
|
vbox({
|
||||||
hbox({text(L"Red line :"), hbox(std::move(red_line))}),
|
hbox({text("Red line :"), hbox(std::move(red_line))}),
|
||||||
hbox({text(L"Green line :"), hbox(std::move(green_line))}),
|
hbox({text("Green line :"), hbox(std::move(green_line))}),
|
||||||
hbox({text(L"Blue line :"), hbox(std::move(blue_line))}),
|
hbox({text("Blue line :"), hbox(std::move(blue_line))}),
|
||||||
})),
|
})),
|
||||||
window(text(L"Secondary colors"),
|
window(text("Secondary colors"),
|
||||||
vbox({
|
vbox({
|
||||||
hbox({text(L"cyan line :"), hbox(std::move(cyan_line))}),
|
hbox({text("cyan line :"), hbox(std::move(cyan_line))}),
|
||||||
hbox({text(L"magenta line:"), hbox(std::move(magenta_line))}),
|
hbox({text("magenta line:"), hbox(std::move(magenta_line))}),
|
||||||
hbox({text(L"Yellow line :"), hbox(std::move(yellow_line))}),
|
hbox({text("Yellow line :"), hbox(std::move(yellow_line))}),
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, border, Element, vbox, center, dbox
|
#include <ftxui/dom/elements.hpp> // for text, operator|, border, Element, vbox, center, Fit, dbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -10,13 +9,13 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = dbox({
|
auto document = dbox({
|
||||||
vbox({
|
vbox({
|
||||||
text(L"line_1"),
|
text("line_1"),
|
||||||
text(L"line_2"),
|
text("line_2"),
|
||||||
text(L"line_3"),
|
text("line_3"),
|
||||||
text(L"line_4"),
|
text("line_4"),
|
||||||
text(L"line_5"),
|
text("line_5"),
|
||||||
}) | border,
|
}) | border,
|
||||||
text(L"overlay") | border | center,
|
text("overlay") | border | center,
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#include <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/dom/elements.hpp> // for gauge, operator|, flex, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, gauge, operator|, flex, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
#include <iostream> // for cout, endl, ostream
|
#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 <thread> // for sleep_for
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -15,12 +14,12 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
std::string reset_position;
|
std::string reset_position;
|
||||||
for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
|
for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
|
||||||
std::wstring data_downloaded =
|
std::string data_downloaded =
|
||||||
std::to_wstring(int(percentage * 5000)) + L"/5000";
|
std::to_string(int(percentage * 5000)) + "/5000";
|
||||||
auto document = hbox({
|
auto document = hbox({
|
||||||
text(L"downloading:"),
|
text("downloading:"),
|
||||||
gauge(percentage) | flex,
|
gauge(percentage) | flex,
|
||||||
text(L" " + data_downloaded),
|
text(" " + data_downloaded),
|
||||||
});
|
});
|
||||||
auto screen = Screen(100, 1);
|
auto screen = Screen(100, 1);
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
#include <stddef.h> // for size_t
|
#include <stddef.h> // for size_t
|
||||||
#include <ftxui/dom/elements.hpp> // for operator|, size, Element, hcenter, Decorator, WIDTH, hflow, window, EQUAL, GREATER_THAN, HEIGHT, bold, border, dim, LESS_THAN
|
#include <ftxui/dom/elements.hpp> // for operator|, size, Element, text, hcenter, Decorator, Fit, WIDTH, hflow, window, EQUAL, GREATER_THAN, HEIGHT, bold, border, dim, LESS_THAN
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <ftxui/screen/string.hpp> // for to_wstring
|
|
||||||
#include <memory> // for allocator, shared_ptr
|
#include <memory> // for allocator, shared_ptr
|
||||||
#include <string> // for operator+, char_traits, wstring
|
#include <string> // for operator+, to_string, char_traits, string
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto make_box = [](size_t dimx, size_t dimy) {
|
auto make_box = [](size_t dimx, size_t dimy) {
|
||||||
std::wstring title = to_wstring(dimx) + L"x" + to_wstring(dimy);
|
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
|
||||||
return window(text(title) | hcenter | bold,
|
return window(text(title) | hcenter | bold,
|
||||||
text(L"content") | hcenter | dim) |
|
text("content") | hcenter | dim) |
|
||||||
size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
|
size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#include <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen, Dimension
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <iostream> // for cout, ostream
|
#include <iostream> // for cout, ostream
|
||||||
#include <memory> // for allocator, shared_ptr
|
#include <memory> // for allocator, shared_ptr
|
||||||
#include <string> // for operator<<, string
|
#include <string> // for operator<<, string
|
||||||
#include <thread> // for sleep_for
|
#include <thread> // for sleep_for
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for paragraph, text
|
#include "ftxui/dom/elements.hpp" // for paragraph, text, operator|, Element, border, color, hflow, spinner, vbox, bold, dim, underlined
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, border, color, hflow, spinner, vbox, bold, dim, underlined
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
||||||
@ -15,34 +14,34 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
auto img1 = []() { return text(L"img") | border; };
|
auto img1 = []() { return text("img") | border; };
|
||||||
auto img2 = []() { return vbox({text(L"big"), text(L"image")}) | border; };
|
auto img2 = []() { return vbox({text("big"), text("image")}) | border; };
|
||||||
|
|
||||||
std::string reset_position;
|
std::string reset_position;
|
||||||
for (int i = 0;; ++i) {
|
for (int i = 0;; ++i) {
|
||||||
auto document = //
|
auto document = //
|
||||||
hflow(
|
hflow(
|
||||||
paragraph(L"Hello world! Here is an image:"), img1(),
|
paragraph("Hello world! Here is an image:"), img1(),
|
||||||
paragraph(L" Here is a text "), text(L"underlined ") | underlined,
|
paragraph(" Here is a text "), text("underlined ") | underlined,
|
||||||
paragraph(L" Here is a text "), text(L"bold ") | bold,
|
paragraph(" Here is a text "), text("bold ") | bold,
|
||||||
paragraph(L"Hello world! Here is an image:"), img2(),
|
paragraph("Hello world! Here is an image:"), img2(),
|
||||||
paragraph(
|
paragraph(
|
||||||
L"Le Lorem Ipsum est simplement du faux texte employé dans la "
|
"Le Lorem Ipsum est simplement du faux texte employé dans la "
|
||||||
L"composition et la mise en page avant impression. Le Lorem "
|
"composition et la mise en page avant impression. Le Lorem "
|
||||||
L"Ipsum est le faux texte standard de l'imprimerie depuis les "
|
"Ipsum est le faux texte standard de l'imprimerie depuis les "
|
||||||
L"années 1500, quand un imprimeur anonyme assembla ensemble "
|
"années 1500, quand un imprimeur anonyme assembla ensemble "
|
||||||
L"des morceaux de texte pour réaliser un livre spécimen de "
|
"des morceaux de texte pour réaliser un livre spécimen de "
|
||||||
L"polices de texte. Il n'a pas fait que survivre cinq siècles, "
|
"polices de texte. Il n'a pas fait que survivre cinq siècles, "
|
||||||
L"mais s'est aussi adapté à la bureautique informatique, sans "
|
"mais s'est aussi adapté à la bureautique informatique, sans "
|
||||||
L"que son contenu n'en soit modifié. Il a été popularisé dans "
|
"que son contenu n'en soit modifié. Il a été popularisé dans "
|
||||||
L"les années 1960 grâce à la vente de feuilles Letraset "
|
"les années 1960 grâce à la vente de feuilles Letraset "
|
||||||
L"contenant des passages du Lorem Ipsum, et, plus récemment, "
|
"contenant des passages du Lorem Ipsum, et, plus récemment, "
|
||||||
L"par son inclusion dans des applications de mise en page de "
|
"par son inclusion dans des applications de mise en page de "
|
||||||
L"texte, comme Aldus PageMaker."),
|
"texte, comme Aldus PageMaker."),
|
||||||
paragraph(L" Here is a text "), text(L"dim ") | dim,
|
paragraph(" Here is a text "), text("dim ") | dim,
|
||||||
paragraph(L"Hello world! Here is an image:"), img1(),
|
paragraph("Hello world! Here is an image:"), img1(),
|
||||||
paragraph(L" Here is a text "), text(L"red ") | color(Color::Red),
|
paragraph(" Here is a text "), text("red ") | color(Color::Red),
|
||||||
paragraph(L" A spinner "), spinner(6, i / 10)) |
|
paragraph(" A spinner "), spinner(6, i / 10)) |
|
||||||
border;
|
border;
|
||||||
|
|
||||||
auto screen = Screen::Create(Dimension::Full());
|
auto screen = Screen::Create(Dimension::Full());
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#include <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/dom/elements.hpp> // for operator|, Element, hbox, bold, color, filler, separator, vbox, window, gauge, size, dim, EQUAL, WIDTH
|
#include <ftxui/dom/elements.hpp> // for operator|, text, Element, hbox, bold, color, filler, separator, vbox, window, gauge, Fit, size, dim, EQUAL, WIDTH
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen, Dimension
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <ftxui/screen/string.hpp> // for to_wstring
|
|
||||||
#include <iostream> // for cout, endl, ostream
|
#include <iostream> // for cout, endl, ostream
|
||||||
#include <list> // for list, operator!=, _List_iterator, _List_iterator<>::_Self
|
#include <list> // for list, operator!=, _List_iterator, _List_iterator<>::_Self
|
||||||
#include <memory> // for allocator, shared_ptr, allocator_traits<>::value_type
|
#include <memory> // for allocator, shared_ptr, allocator_traits<>::value_type
|
||||||
#include <string> // for wstring, operator<<, string
|
#include <string> // for string, operator<<, to_string
|
||||||
#include <thread> // for sleep_for
|
#include <thread> // for sleep_for
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Green, Color::Red, Color::RedLight
|
#include "ftxui/screen/color.hpp" // for Color, Color::Green, Color::Red, Color::RedLight
|
||||||
@ -19,25 +17,25 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
std::wstring name;
|
std::string name;
|
||||||
int number_of_threads;
|
int number_of_threads;
|
||||||
int downloaded;
|
int downloaded;
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::list<Task> remaining_tasks = {
|
std::list<Task> remaining_tasks = {
|
||||||
{L"contact server ", 10, 0, 6 * 25},
|
{"contact server ", 10, 0, 6 * 25},
|
||||||
{L"download index.html ", 10, 0, 9 * 25},
|
{"download index.html ", 10, 0, 9 * 25},
|
||||||
{L"download script.js ", 1, 0, 3 * 25},
|
{"download script.js ", 1, 0, 3 * 25},
|
||||||
{L"download style.js ", 1, 0, 4 * 25},
|
{"download style.js ", 1, 0, 4 * 25},
|
||||||
{L"download image.png ", 1, 0, 5 * 25},
|
{"download image.png ", 1, 0, 5 * 25},
|
||||||
{L"download big_1.png ", 1, 0, 30 * 25},
|
{"download big_1.png ", 1, 0, 30 * 25},
|
||||||
{L"download icon_1.png ", 1, 0, 7 * 25},
|
{"download icon_1.png ", 1, 0, 7 * 25},
|
||||||
{L"download icon_2.png ", 1, 0, 8 * 25},
|
{"download icon_2.png ", 1, 0, 8 * 25},
|
||||||
{L"download big_2.png ", 1, 0, 30 * 25},
|
{"download big_2.png ", 1, 0, 30 * 25},
|
||||||
{L"download small_1.png ", 1, 0, 10 * 25},
|
{"download small_1.png ", 1, 0, 10 * 25},
|
||||||
{L"download small_2.png ", 1, 0, 11 * 25},
|
{"download small_2.png ", 1, 0, 11 * 25},
|
||||||
{L"download small_3.png ", 1, 0, 12 * 25},
|
{"download small_3.png ", 1, 0, 12 * 25},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::list<Task> displayed_task;
|
std::list<Task> displayed_task;
|
||||||
@ -49,7 +47,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
int nb_done = 0;
|
int nb_done = 0;
|
||||||
|
|
||||||
auto to_text = [](int number) {
|
auto to_text = [](int number) {
|
||||||
return text(to_wstring(number)) | size(WIDTH, EQUAL, 3);
|
return text(std::to_string(number)) | size(WIDTH, EQUAL, 3);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto renderTask = [&](const Task& task) {
|
auto renderTask = [&](const Task& task) {
|
||||||
@ -58,7 +56,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
text(task.name) | style,
|
text(task.name) | style,
|
||||||
separator(),
|
separator(),
|
||||||
to_text(task.downloaded),
|
to_text(task.downloaded),
|
||||||
text(L"/"),
|
text("/"),
|
||||||
to_text(task.size),
|
to_text(task.size),
|
||||||
separator(),
|
separator(),
|
||||||
gauge(task.downloaded / float(task.size)),
|
gauge(task.downloaded / float(task.size)),
|
||||||
@ -68,20 +66,20 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto renderSummary = [&]() {
|
auto renderSummary = [&]() {
|
||||||
auto summary = vbox({
|
auto summary = vbox({
|
||||||
hbox({
|
hbox({
|
||||||
text(L"- done: "),
|
text("- done: "),
|
||||||
to_text(nb_done) | bold,
|
to_text(nb_done) | bold,
|
||||||
}) | color(Color::Green),
|
}) | color(Color::Green),
|
||||||
hbox({
|
hbox({
|
||||||
text(L"- active: "),
|
text("- active: "),
|
||||||
to_text(nb_active) | bold,
|
to_text(nb_active) | bold,
|
||||||
}) | color(Color::RedLight),
|
}) | color(Color::RedLight),
|
||||||
hbox({
|
hbox({
|
||||||
text(L"- queue: "),
|
text("- queue: "),
|
||||||
to_text(nb_queued) | bold,
|
to_text(nb_queued) | bold,
|
||||||
}) | color(Color::Red),
|
}) | color(Color::Red),
|
||||||
});
|
});
|
||||||
|
|
||||||
return window(text(L" Summary "), summary);
|
return window(text(" Summary "), summary);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto render = [&]() {
|
auto render = [&]() {
|
||||||
@ -91,7 +89,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return vbox({
|
return vbox({
|
||||||
// List of tasks.
|
// List of tasks.
|
||||||
window(text(L" Task "), vbox(std::move(entries))),
|
window(text(" Task "), vbox(std::move(entries))),
|
||||||
|
|
||||||
// Summary.
|
// Summary.
|
||||||
hbox({
|
hbox({
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
#include <stdio.h> // for getchar
|
#include <stdio.h> // for getchar
|
||||||
#include <ftxui/dom/elements.hpp> // for operator|, hflow, border, Element, hbox, flex, vbox
|
#include <ftxui/dom/elements.hpp> // for operator|, hflow, paragraph, border, Element, hbox, flex, vbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <string> // for allocator, wstring
|
#include <string> // for allocator, string
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for paragraph
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
std::wstring p =
|
std::string p =
|
||||||
LR"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
|
R"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
|
||||||
|
|
||||||
auto document = vbox({
|
auto document = vbox({
|
||||||
hbox({
|
hbox({
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for center, separator, operator|, flex, Element, vbox, hbox, border
|
#include <ftxui/dom/elements.hpp> // for text, center, separator, operator|, flex, Element, vbox, Fit, hbox, border
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = hbox({
|
auto document = hbox({
|
||||||
text(L"left-column"),
|
text("left-column"),
|
||||||
separator(),
|
separator(),
|
||||||
vbox({
|
vbox({
|
||||||
center(text(L"right-top")) | flex,
|
center(text("right-top")) | flex,
|
||||||
separator(),
|
separator(),
|
||||||
center(text(L"bottom-bottom")),
|
center(text("bottom-bottom")),
|
||||||
}) | flex,
|
}) | flex,
|
||||||
separator(),
|
separator(),
|
||||||
text(L"right-column"),
|
text("right-column"),
|
||||||
}) |
|
}) |
|
||||||
border;
|
border;
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, Element, hcenter, hbox, size, window, Elements, bold, dim, EQUAL, WIDTH
|
#include <ftxui/dom/elements.hpp> // for operator|, text, Element, hcenter, Fit, hbox, size, window, Elements, bold, dim, EQUAL, WIDTH
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen, Dimension
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
#include <ftxui/screen/string.hpp> // for to_wstring
|
|
||||||
#include <memory> // for allocator, shared_ptr
|
#include <memory> // for allocator, shared_ptr
|
||||||
#include <string> // for wstring
|
#include <string> // for string, to_string
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto make_box = [](const std::wstring title) {
|
auto make_box = [](const std::string& title) {
|
||||||
return window(text(title) | hcenter | bold,
|
return window(text(title) | hcenter | bold,
|
||||||
text(L"content") | hcenter | dim);
|
text("content") | hcenter | dim);
|
||||||
};
|
};
|
||||||
|
|
||||||
Elements content;
|
Elements content;
|
||||||
for (int x = 3; x < 30; ++x) {
|
for (int x = 3; x < 30; ++x) {
|
||||||
content.push_back(make_box(to_wstring(x)) | size(WIDTH, EQUAL, x));
|
content.push_back(make_box(std::to_string(x)) | size(WIDTH, EQUAL, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto document = hbox(std::move(content));
|
auto document = hbox(std::move(content));
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#include <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/dom/elements.hpp> // for Element, operator|, separator, filler, hbox, size, spinner, vbox, bold, border, EQUAL, WIDTH
|
#include <ftxui/dom/elements.hpp> // for Element, operator|, separator, filler, hbox, size, spinner, text, vbox, bold, border, Fit, EQUAL, WIDTH
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen, Dimension
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <ftxui/screen/string.hpp> // for to_wstring
|
|
||||||
#include <iostream> // for cout, endl, ostream
|
#include <iostream> // for cout, endl, ostream
|
||||||
#include <string> // for operator<<, string
|
#include <string> // for to_string, operator<<, string
|
||||||
#include <thread> // for sleep_for
|
#include <thread> // for sleep_for
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -24,7 +22,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
entries.push_back(separator());
|
entries.push_back(separator());
|
||||||
entries.push_back( //
|
entries.push_back( //
|
||||||
hbox({
|
hbox({
|
||||||
text(to_wstring(i)) | size(WIDTH, EQUAL, 2),
|
text(std::to_string(i)) | size(WIDTH, EQUAL, 2),
|
||||||
separator(),
|
separator(),
|
||||||
spinner(i, index) | bold,
|
spinner(i, index) | bold,
|
||||||
}));
|
}));
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, blink, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, operator|, blink, Fit, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -10,9 +9,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = //
|
auto document = //
|
||||||
hbox({
|
hbox({
|
||||||
text(L"This text is "),
|
text("This text is "),
|
||||||
text(L"blink") | blink,
|
text("blink") | blink,
|
||||||
text(L". Do you like it?"),
|
text(". Do you like it?"),
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, bold, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, operator|, bold, Fit, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -10,9 +9,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = //
|
auto document = //
|
||||||
hbox({
|
hbox({
|
||||||
text(L"This text is "),
|
text("This text is "),
|
||||||
text(L"bold") | bold,
|
text("bold") | bold,
|
||||||
text(L". Do you like it?"),
|
text(". Do you like it?"),
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, bgcolor, color, vbox, Fit, filler, hbox
|
||||||
#include "ftxui/dom/elements.hpp" // for bgcolor, color, vbox, filler, hbox
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Black, Color::Blue, Color::BlueLight, Color::Cyan, Color::CyanLight, Color::Default, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::RedLight, Color::White, Color::Yellow, Color::YellowLight
|
#include "ftxui/screen/color.hpp" // for Color, Color::Black, Color::Blue, Color::BlueLight, Color::Cyan, Color::CyanLight, Color::Default, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::RedLight, Color::White, Color::Yellow, Color::YellowLight
|
||||||
@ -13,42 +12,42 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto document =
|
auto document =
|
||||||
hbox(
|
hbox(
|
||||||
vbox(
|
vbox(
|
||||||
color(Color::Default, text(L"Default")),
|
color(Color::Default, text("Default")),
|
||||||
color(Color::Black, text(L"Black")),
|
color(Color::Black, text("Black")),
|
||||||
color(Color::GrayDark, text(L"GrayDark")),
|
color(Color::GrayDark, text("GrayDark")),
|
||||||
color(Color::GrayLight, text(L"GrayLight")),
|
color(Color::GrayLight, text("GrayLight")),
|
||||||
color(Color::White, text(L"White")),
|
color(Color::White, text("White")),
|
||||||
color(Color::Blue, text(L"Blue")),
|
color(Color::Blue, text("Blue")),
|
||||||
color(Color::BlueLight, text(L"BlueLight")),
|
color(Color::BlueLight, text("BlueLight")),
|
||||||
color(Color::Cyan, text(L"Cyan")),
|
color(Color::Cyan, text("Cyan")),
|
||||||
color(Color::CyanLight, text(L"CyanLight")),
|
color(Color::CyanLight, text("CyanLight")),
|
||||||
color(Color::Green, text(L"Green")),
|
color(Color::Green, text("Green")),
|
||||||
color(Color::GreenLight, text(L"GreenLight")),
|
color(Color::GreenLight, text("GreenLight")),
|
||||||
color(Color::Magenta, text(L"Magenta")),
|
color(Color::Magenta, text("Magenta")),
|
||||||
color(Color::MagentaLight, text(L"MagentaLight")),
|
color(Color::MagentaLight, text("MagentaLight")),
|
||||||
color(Color::Red, text(L"Red")),
|
color(Color::Red, text("Red")),
|
||||||
color(Color::RedLight, text(L"RedLight")),
|
color(Color::RedLight, text("RedLight")),
|
||||||
color(Color::Yellow, text(L"Yellow")),
|
color(Color::Yellow, text("Yellow")),
|
||||||
color(Color::YellowLight, text(L"YellowLight"))
|
color(Color::YellowLight, text("YellowLight"))
|
||||||
),
|
),
|
||||||
vbox(
|
vbox(
|
||||||
bgcolor(Color::Default, text(L"Default")),
|
bgcolor(Color::Default, text("Default")),
|
||||||
bgcolor(Color::Black, text(L"Black")),
|
bgcolor(Color::Black, text("Black")),
|
||||||
bgcolor(Color::GrayDark, text(L"GrayDark")),
|
bgcolor(Color::GrayDark, text("GrayDark")),
|
||||||
bgcolor(Color::GrayLight, text(L"GrayLight")),
|
bgcolor(Color::GrayLight, text("GrayLight")),
|
||||||
bgcolor(Color::White, text(L"White")),
|
bgcolor(Color::White, text("White")),
|
||||||
bgcolor(Color::Blue, text(L"Blue")),
|
bgcolor(Color::Blue, text("Blue")),
|
||||||
bgcolor(Color::BlueLight, text(L"BlueLight")),
|
bgcolor(Color::BlueLight, text("BlueLight")),
|
||||||
bgcolor(Color::Cyan, text(L"Cyan")),
|
bgcolor(Color::Cyan, text("Cyan")),
|
||||||
bgcolor(Color::CyanLight, text(L"CyanLight")),
|
bgcolor(Color::CyanLight, text("CyanLight")),
|
||||||
bgcolor(Color::Green, text(L"Green")),
|
bgcolor(Color::Green, text("Green")),
|
||||||
bgcolor(Color::GreenLight, text(L"GreenLight")),
|
bgcolor(Color::GreenLight, text("GreenLight")),
|
||||||
bgcolor(Color::Magenta, text(L"Magenta")),
|
bgcolor(Color::Magenta, text("Magenta")),
|
||||||
bgcolor(Color::MagentaLight, text(L"MagentaLight")),
|
bgcolor(Color::MagentaLight, text("MagentaLight")),
|
||||||
bgcolor(Color::Red, text(L"Red")),
|
bgcolor(Color::Red, text("Red")),
|
||||||
bgcolor(Color::RedLight, text(L"RedLight")),
|
bgcolor(Color::RedLight, text("RedLight")),
|
||||||
bgcolor(Color::Yellow, text(L"Yellow")),
|
bgcolor(Color::Yellow, text("Yellow")),
|
||||||
bgcolor(Color::YellowLight, text(L"YellowLight"))
|
bgcolor(Color::YellowLight, text("YellowLight"))
|
||||||
),
|
),
|
||||||
filler()
|
filler()
|
||||||
);
|
);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, dim, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, operator|, dim, Fit, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -10,9 +9,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = //
|
auto document = //
|
||||||
hbox({
|
hbox({
|
||||||
text(L"This text is "),
|
text("This text is "),
|
||||||
text(L"dim") | dim,
|
text("dim") | dim,
|
||||||
text(L". Do you like it?"),
|
text(". Do you like it?"),
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, Element, bgcolor, color, blink, bold, dim, inverted, underlined, hbox
|
#include <ftxui/dom/elements.hpp> // for text, operator|, Element, bgcolor, color, blink, bold, dim, inverted, underlined, Fit, hbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Blue
|
#include "ftxui/screen/color.hpp" // for Color, Color::Blue
|
||||||
@ -12,14 +11,14 @@ int main(int argc, const char* argv[]) {
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
auto document =
|
auto document =
|
||||||
hbox({
|
hbox({
|
||||||
text(L"normal") , text(L" ") ,
|
text("normal") , text(" ") ,
|
||||||
text(L"bold") | bold , text(L" ") ,
|
text("bold") | bold , text(" ") ,
|
||||||
text(L"dim") | dim , text(L" ") ,
|
text("dim") | dim , text(" ") ,
|
||||||
text(L"inverted") | inverted , text(L" ") ,
|
text("inverted") | inverted , text(" ") ,
|
||||||
text(L"underlined")| underlined , text(L" ") ,
|
text("underlined")| underlined , text(" ") ,
|
||||||
text(L"blink") | blink , text(L" ") ,
|
text("blink") | blink , text(" ") ,
|
||||||
text(L"color") | color(Color::Blue) , text(L" ") ,
|
text("color") | color(Color::Blue) , text(" ") ,
|
||||||
text(L"bgcolor") | bgcolor(Color::Blue),
|
text("bgcolor") | bgcolor(Color::Blue),
|
||||||
});
|
});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, inverted, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, operator|, inverted, Fit, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = hbox({
|
auto document = hbox({
|
||||||
text(L"This text is "),
|
text("This text is "),
|
||||||
text(L"inverted") | inverted,
|
text("inverted") | inverted,
|
||||||
text(L". Do you like it?"),
|
text(". Do you like it?"),
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <ftxui/dom/elements.hpp> // for operator|, underlined, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, operator|, underlined, Fit, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Dimension, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -10,9 +9,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = //
|
auto document = //
|
||||||
hbox({
|
hbox({
|
||||||
text(L"This text is "),
|
text("This text is "),
|
||||||
text(L"underlined") | underlined,
|
text("underlined") | underlined,
|
||||||
text(L". Do you like it?"),
|
text(". Do you like it?"),
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#include <stdio.h> // for getchar
|
#include <stdio.h> // for getchar
|
||||||
#include <ftxui/dom/elements.hpp> // for filler, hbox, vbox
|
#include <ftxui/dom/elements.hpp> // for filler, text, hbox, vbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen, Dimension
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
@ -12,21 +11,21 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto document = //
|
auto document = //
|
||||||
vbox({
|
vbox({
|
||||||
hbox({
|
hbox({
|
||||||
text(L"north-west"),
|
text("north-west"),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"north-east"),
|
text("north-east"),
|
||||||
}),
|
}),
|
||||||
filler(),
|
filler(),
|
||||||
hbox({
|
hbox({
|
||||||
filler(),
|
filler(),
|
||||||
text(L"center"),
|
text("center"),
|
||||||
filler(),
|
filler(),
|
||||||
}),
|
}),
|
||||||
filler(),
|
filler(),
|
||||||
hbox({
|
hbox({
|
||||||
text(L"south-west"),
|
text("south-west"),
|
||||||
filler(),
|
filler(),
|
||||||
text(L"south-east"),
|
text("south-east"),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
auto screen = Screen::Create(Dimension::Full());
|
auto screen = Screen::Create(Dimension::Full());
|
||||||
|
@ -33,33 +33,33 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document =
|
auto document =
|
||||||
hbox(
|
hbox(
|
||||||
window(text(L" main frame ") | hcenter,
|
window(text(" main frame ") | hcenter,
|
||||||
vbox(
|
vbox(
|
||||||
text(L"Line 1"),
|
text("Line 1"),
|
||||||
text(L"Line 2"),
|
text("Line 2"),
|
||||||
text(L"Line 3"),
|
text("Line 3"),
|
||||||
vbox(
|
vbox(
|
||||||
text(L"Line 4"),
|
text("Line 4"),
|
||||||
text(L"Line 5"),
|
text("Line 5"),
|
||||||
text(L"Line 6")
|
text("Line 6")
|
||||||
) | border,
|
) | border,
|
||||||
hbox(
|
hbox(
|
||||||
window(text(L"frame 2"),
|
window(text("frame 2"),
|
||||||
vbox(
|
vbox(
|
||||||
text(L"Line 4"),
|
text("Line 4"),
|
||||||
gauge(0.5) | border,
|
gauge(0.5) | border,
|
||||||
text(L"Line 6")
|
text("Line 6")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
window(text(L"frame 3"),
|
window(text("frame 3"),
|
||||||
vbox(
|
vbox(
|
||||||
text(L"Line 7"),
|
text("Line 7"),
|
||||||
text(L"Line 8"),
|
text("Line 8"),
|
||||||
text(L"Line 9")
|
text("Line 9")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
text(L"footer footer footer footer footer")
|
text("footer footer footer footer footer")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
filler()
|
filler()
|
||||||
|
@ -20,7 +20,7 @@ using GraphFunction = std::function<std::vector<int>(int, int)>;
|
|||||||
// Pipe elements into decorator togethers.
|
// Pipe elements into decorator togethers.
|
||||||
// For instance the next lines are equivalents:
|
// For instance the next lines are equivalents:
|
||||||
// -> text("ftxui") | bold | underlined
|
// -> text("ftxui") | bold | underlined
|
||||||
// -> underlined(bold(text(L"FTXUI")))
|
// -> underlined(bold(text("FTXUI")))
|
||||||
Element operator|(Element, Decorator);
|
Element operator|(Element, Decorator);
|
||||||
Elements operator|(Elements, Decorator);
|
Elements operator|(Elements, Decorator);
|
||||||
Decorator operator|(Decorator, Decorator);
|
Decorator operator|(Decorator, Decorator);
|
||||||
|
15
include/ftxui/screen/deprecated.hpp
Normal file
15
include/ftxui/screen/deprecated.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef FTXUI_SCREEN_DEPRECATED_HPP
|
||||||
|
#define FTXUI_SCREEN_DEPRECATED_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace ftxui {
|
||||||
|
int wchar_width(wchar_t);
|
||||||
|
int wstring_width(const std::wstring&);
|
||||||
|
} // namespace ftxui
|
||||||
|
|
||||||
|
#endif /* end of include guard: FTXUI_SCREEN_DEPRECATED_HPP */
|
||||||
|
|
||||||
|
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
||||||
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
|
// the LICENSE file.
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef FTXUI_SCREEN_STRING_HPP
|
#ifndef FTXUI_SCREEN_STRING_HPP
|
||||||
#define FTXUI_SCREEN_STRING_HPP
|
#define FTXUI_SCREEN_STRING_HPP
|
||||||
|
|
||||||
#include <string>
|
#include <string> // for string, wstring, to_string
|
||||||
#include <vector>
|
#include <vector> // for vector
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
std::string to_string(const std::wstring& s);
|
std::string to_string(const std::wstring& s);
|
||||||
@ -13,13 +13,13 @@ std::wstring to_wstring(T s) {
|
|||||||
return to_wstring(std::to_string(s));
|
return to_wstring(std::to_string(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
int wchar_width(wchar_t);
|
|
||||||
int wstring_width(const std::wstring&);
|
|
||||||
int string_width(const std::string&);
|
int string_width(const std::string&);
|
||||||
std::vector<std::string> Utf8ToGlyphs(const std::string& input);
|
std::vector<std::string> Utf8ToGlyphs(const std::string& input);
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
|
||||||
|
#include "ftxui/screen/deprecated.hpp"
|
||||||
|
|
||||||
#endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
|
#endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
|
||||||
|
|
||||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <iostream>
|
||||||
//#include "ftxui/component/event.hpp"
|
//#include "ftxui/component/event.hpp"
|
||||||
//#include "ftxui/component/receiver.hpp"
|
//#include "ftxui/component/receiver.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -17,15 +18,21 @@ bool GeneratorBool(const char*& data, size_t& size) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring GeneratorString(const char*& data, size_t& size) {
|
std::string GeneratorString(const char*& data, size_t& size) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < size && data[index])
|
while (index < size && data[index])
|
||||||
++index;
|
++index;
|
||||||
|
|
||||||
auto out = std::wstring(data, data + index);
|
try {
|
||||||
|
auto out = std::string(data, data + index);
|
||||||
|
auto w_out = to_wstring(out);
|
||||||
data += index;
|
data += index;
|
||||||
size -= index;
|
size -= index;
|
||||||
return std::move(out);
|
return std::move(out);
|
||||||
|
} catch (...) {
|
||||||
|
// The input component do not support invalid UTF8 yet.
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GeneratorInt(const char* data, size_t size) {
|
int GeneratorInt(const char* data, size_t size) {
|
||||||
@ -39,7 +46,7 @@ int GeneratorInt(const char* data, size_t size) {
|
|||||||
|
|
||||||
bool g_bool;
|
bool g_bool;
|
||||||
int g_int;
|
int g_int;
|
||||||
std::vector<std::wstring> g_list;
|
std::vector<std::string> g_list;
|
||||||
|
|
||||||
Components GeneratorComponents(const char*& data, size_t& size, int depth);
|
Components GeneratorComponents(const char*& data, size_t& size, int depth);
|
||||||
|
|
||||||
@ -114,7 +121,7 @@ extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) {
|
|||||||
g_bool = GeneratorBool(data, size);
|
g_bool = GeneratorBool(data, size);
|
||||||
g_int = GeneratorInt(data, size);
|
g_int = GeneratorInt(data, size);
|
||||||
g_list = {
|
g_list = {
|
||||||
L"test_1", L"test_2", L"test_3", L"test_4", L"test_5",
|
"test_1", "test_2", "test_3", "test_4", "test_5",
|
||||||
};
|
};
|
||||||
|
|
||||||
int depth = 10;
|
int depth = 10;
|
||||||
@ -123,6 +130,12 @@ extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) {
|
|||||||
int width = GeneratorInt(data, size);
|
int width = GeneratorInt(data, size);
|
||||||
int height = GeneratorInt(data, size);
|
int height = GeneratorInt(data, size);
|
||||||
|
|
||||||
|
width %= 500;
|
||||||
|
width += 500;
|
||||||
|
|
||||||
|
height %= 500;
|
||||||
|
height += 500;
|
||||||
|
|
||||||
auto screen =
|
auto screen =
|
||||||
Screen::Create(Dimension::Fixed(width), Dimension::Fixed(height));
|
Screen::Create(Dimension::Fixed(width), Dimension::Fixed(height));
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
Component Focusable() {
|
Component Focusable() {
|
||||||
return Button(L"", [] {});
|
return Button("", [] {});
|
||||||
}
|
}
|
||||||
Component NonFocusable() {
|
Component NonFocusable() {
|
||||||
return Container::Horizontal({});
|
return Container::Horizontal({});
|
||||||
|
@ -200,7 +200,7 @@ class InputBase : public ComponentBase {
|
|||||||
bool OnEvent(Event event) override {
|
bool OnEvent(Event event) override {
|
||||||
wrapped_content_ = to_wstring(*content_);
|
wrapped_content_ = to_wstring(*content_);
|
||||||
if (wrapped_input_.OnEvent(event)) {
|
if (wrapped_input_.OnEvent(event)) {
|
||||||
content_ = to_string(wrapped_content_);
|
*content_ = to_string(wrapped_content_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include <gtest/gtest-message.h> // for Message
|
#include <gtest/gtest-message.h> // for Message
|
||||||
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver, TestFactoryImpl
|
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver, TestFactoryImpl
|
||||||
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
||||||
#include <string> // for wstring
|
#include <string> // for string
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
|
#include "ftxui/component/component.hpp" // for Input
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase, Component
|
#include "ftxui/component/component_base.hpp" // for ComponentBase, Component
|
||||||
#include "ftxui/component/component_options.hpp" // for InputOption
|
#include "ftxui/component/component_options.hpp" // for InputOption
|
||||||
#include "ftxui/component/deprecated.hpp" // for Input
|
|
||||||
#include "ftxui/component/event.hpp" // for Event, Event::ArrowLeft, Event::ArrowRight, Event::Backspace, Event::Delete, Event::End, Event::Home
|
#include "ftxui/component/event.hpp" // for Event, Event::ArrowLeft, Event::ArrowRight, Event::Backspace, Event::Delete, Event::End, Event::Home
|
||||||
#include "ftxui/dom/elements.hpp" // for Fit
|
#include "ftxui/dom/elements.hpp" // for Fit
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
@ -17,8 +17,8 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
TEST(InputTest, Init) {
|
TEST(InputTest, Init) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
Component input = Input(&content, &placeholder, &option);
|
Component input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
@ -26,17 +26,17 @@ TEST(InputTest, Init) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, Type) {
|
TEST(InputTest, Type) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
Component input = Input(&content, &placeholder, &option);
|
Component input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('a'));
|
input->OnEvent(Event::Character("a"));
|
||||||
EXPECT_EQ(content, L"a");
|
EXPECT_EQ(content, "a");
|
||||||
EXPECT_EQ(option.cursor_position(), 1u);
|
EXPECT_EQ(option.cursor_position(), 1u);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('b'));
|
input->OnEvent(Event::Character('b'));
|
||||||
EXPECT_EQ(content, L"ab");
|
EXPECT_EQ(content, "ab");
|
||||||
EXPECT_EQ(option.cursor_position(), 2u);
|
EXPECT_EQ(option.cursor_position(), 2u);
|
||||||
|
|
||||||
auto document = input->Render();
|
auto document = input->Render();
|
||||||
@ -47,18 +47,18 @@ TEST(InputTest, Type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, TypePassword) {
|
TEST(InputTest, TypePassword) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
option.password = true;
|
option.password = true;
|
||||||
Component input = Input(&content, &placeholder, &option);
|
Component input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('a'));
|
input->OnEvent(Event::Character('a'));
|
||||||
EXPECT_EQ(content, L"a");
|
EXPECT_EQ(content, "a");
|
||||||
EXPECT_EQ(option.cursor_position(), 1u);
|
EXPECT_EQ(option.cursor_position(), 1u);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('b'));
|
input->OnEvent(Event::Character('b'));
|
||||||
EXPECT_EQ(content, L"ab");
|
EXPECT_EQ(content, "ab");
|
||||||
EXPECT_EQ(option.cursor_position(), 2u);
|
EXPECT_EQ(option.cursor_position(), 2u);
|
||||||
|
|
||||||
auto document = input->Render();
|
auto document = input->Render();
|
||||||
@ -69,8 +69,8 @@ TEST(InputTest, TypePassword) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, Arrow) {
|
TEST(InputTest, Arrow) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
auto input = Input(&content, &placeholder, &option);
|
auto input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
@ -106,53 +106,53 @@ TEST(InputTest, Arrow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, Insert) {
|
TEST(InputTest, Insert) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
Component input = Input(&content, &placeholder);
|
Component input = Input(&content, &placeholder);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('a'));
|
input->OnEvent(Event::Character('a'));
|
||||||
input->OnEvent(Event::Character('b'));
|
input->OnEvent(Event::Character('b'));
|
||||||
input->OnEvent(Event::Character('c'));
|
input->OnEvent(Event::Character('c'));
|
||||||
EXPECT_EQ(content, L"abc");
|
EXPECT_EQ(content, "abc");
|
||||||
|
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
input->OnEvent(Event::Character('-'));
|
input->OnEvent(Event::Character('-'));
|
||||||
EXPECT_EQ(content, L"a-bc");
|
EXPECT_EQ(content, "a-bc");
|
||||||
|
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
input->OnEvent(Event::Character('-'));
|
input->OnEvent(Event::Character('-'));
|
||||||
EXPECT_EQ(content, L"a--bc");
|
EXPECT_EQ(content, "a--bc");
|
||||||
|
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
input->OnEvent(Event::Character('-'));
|
input->OnEvent(Event::Character('-'));
|
||||||
EXPECT_EQ(content, L"-a--bc");
|
EXPECT_EQ(content, "-a--bc");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, Home) {
|
TEST(InputTest, Home) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
auto input = Input(&content, &placeholder, &option);
|
auto input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('a'));
|
input->OnEvent(Event::Character('a'));
|
||||||
input->OnEvent(Event::Character('b'));
|
input->OnEvent(Event::Character('b'));
|
||||||
input->OnEvent(Event::Character('c'));
|
input->OnEvent(Event::Character('c'));
|
||||||
EXPECT_EQ(content, L"abc");
|
EXPECT_EQ(content, "abc");
|
||||||
|
|
||||||
EXPECT_EQ(option.cursor_position(), 3u);
|
EXPECT_EQ(option.cursor_position(), 3u);
|
||||||
input->OnEvent(Event::Home);
|
input->OnEvent(Event::Home);
|
||||||
EXPECT_EQ(option.cursor_position(), 0u);
|
EXPECT_EQ(option.cursor_position(), 0u);
|
||||||
|
|
||||||
input->OnEvent(Event::Character('-'));
|
input->OnEvent(Event::Character('-'));
|
||||||
EXPECT_EQ(content, L"-abc");
|
EXPECT_EQ(content, "-abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, End) {
|
TEST(InputTest, End) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
auto input = Input(&content, &placeholder, &option);
|
auto input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
@ -169,8 +169,8 @@ TEST(InputTest, End) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, Delete) {
|
TEST(InputTest, Delete) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
auto input = Input(&content, &placeholder, &option);
|
auto input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
@ -179,21 +179,21 @@ TEST(InputTest, Delete) {
|
|||||||
input->OnEvent(Event::Character('c'));
|
input->OnEvent(Event::Character('c'));
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
|
|
||||||
EXPECT_EQ(content, L"abc");
|
EXPECT_EQ(content, "abc");
|
||||||
EXPECT_EQ(option.cursor_position(), 2u);
|
EXPECT_EQ(option.cursor_position(), 2u);
|
||||||
|
|
||||||
input->OnEvent(Event::Delete);
|
input->OnEvent(Event::Delete);
|
||||||
EXPECT_EQ(content, L"ab");
|
EXPECT_EQ(content, "ab");
|
||||||
EXPECT_EQ(option.cursor_position(), 2u);
|
EXPECT_EQ(option.cursor_position(), 2u);
|
||||||
|
|
||||||
input->OnEvent(Event::Delete);
|
input->OnEvent(Event::Delete);
|
||||||
EXPECT_EQ(content, L"ab");
|
EXPECT_EQ(content, "ab");
|
||||||
EXPECT_EQ(option.cursor_position(), 2u);
|
EXPECT_EQ(option.cursor_position(), 2u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputTest, Backspace) {
|
TEST(InputTest, Backspace) {
|
||||||
std::wstring content;
|
std::string content;
|
||||||
std::wstring placeholder;
|
std::string placeholder;
|
||||||
auto option = InputOption();
|
auto option = InputOption();
|
||||||
auto input = Input(&content, &placeholder, &option);
|
auto input = Input(&content, &placeholder, &option);
|
||||||
|
|
||||||
@ -202,19 +202,19 @@ TEST(InputTest, Backspace) {
|
|||||||
input->OnEvent(Event::Character('c'));
|
input->OnEvent(Event::Character('c'));
|
||||||
input->OnEvent(Event::ArrowLeft);
|
input->OnEvent(Event::ArrowLeft);
|
||||||
|
|
||||||
EXPECT_EQ(content, L"abc");
|
EXPECT_EQ(content, "abc");
|
||||||
EXPECT_EQ(option.cursor_position(), 2u);
|
EXPECT_EQ(option.cursor_position(), 2u);
|
||||||
|
|
||||||
input->OnEvent(Event::Backspace);
|
input->OnEvent(Event::Backspace);
|
||||||
EXPECT_EQ(content, L"ac");
|
EXPECT_EQ(content, "ac");
|
||||||
EXPECT_EQ(option.cursor_position(), 1u);
|
EXPECT_EQ(option.cursor_position(), 1u);
|
||||||
|
|
||||||
input->OnEvent(Event::Backspace);
|
input->OnEvent(Event::Backspace);
|
||||||
EXPECT_EQ(content, L"c");
|
EXPECT_EQ(content, "c");
|
||||||
EXPECT_EQ(option.cursor_position(), 0u);
|
EXPECT_EQ(option.cursor_position(), 0u);
|
||||||
|
|
||||||
input->OnEvent(Event::Backspace);
|
input->OnEvent(Event::Backspace);
|
||||||
EXPECT_EQ(content, L"c");
|
EXPECT_EQ(content, "c");
|
||||||
EXPECT_EQ(option.cursor_position(), 0u);
|
EXPECT_EQ(option.cursor_position(), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <gtest/gtest-message.h> // for Message
|
#include <gtest/gtest-message.h> // for Message
|
||||||
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver, TestFactoryImpl
|
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver, TestFactoryImpl
|
||||||
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -14,7 +14,7 @@ using namespace ftxui;
|
|||||||
|
|
||||||
TEST(RadioboxTest, Navigation) {
|
TEST(RadioboxTest, Navigation) {
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
std::vector<std::wstring> entries = {L"1", L"2", L"3"};
|
std::vector<std::string> entries = {"1", "2", "3"};
|
||||||
auto radiobox = Radiobox(&entries, &selected);
|
auto radiobox = Radiobox(&entries, &selected);
|
||||||
|
|
||||||
// With arrow key.
|
// With arrow key.
|
||||||
@ -60,7 +60,7 @@ TEST(RadioboxTest, Navigation) {
|
|||||||
EXPECT_EQ(selected, 0);
|
EXPECT_EQ(selected, 0);
|
||||||
|
|
||||||
// With more entries
|
// With more entries
|
||||||
entries = {L"1", L"2", L"3"};
|
entries = {"1", "2", "3"};
|
||||||
EXPECT_EQ(selected, 0);
|
EXPECT_EQ(selected, 0);
|
||||||
radiobox->OnEvent(Event::ArrowDown);
|
radiobox->OnEvent(Event::ArrowDown);
|
||||||
radiobox->OnEvent(Event::Return);
|
radiobox->OnEvent(Event::Return);
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include "ftxui/component/component.hpp" // for Renderer
|
#include "ftxui/component/component.hpp" // for Renderer
|
||||||
#include "ftxui/component/screen_interactive.hpp"
|
#include "ftxui/component/screen_interactive.hpp"
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, Element
|
||||||
#include "ftxui/dom/elements.hpp" // for Element
|
|
||||||
#include "gtest/gtest_pred_impl.h" // for Test, TEST, EXPECT_EQ
|
#include "gtest/gtest_pred_impl.h" // for Test, TEST, EXPECT_EQ
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
@ -18,7 +17,7 @@ bool TestSignal(int signal) {
|
|||||||
called++;
|
called++;
|
||||||
std::raise(signal);
|
std::raise(signal);
|
||||||
called++;
|
called++;
|
||||||
return text(L"");
|
return text("");
|
||||||
});
|
});
|
||||||
|
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver, TestFactoryImpl
|
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver, TestFactoryImpl
|
||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
||||||
#include <string> // for wstring, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -15,7 +15,7 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
TEST(ToggleTest, leftRightArrow) {
|
TEST(ToggleTest, leftRightArrow) {
|
||||||
std::vector<std::wstring> entries = {L"On", L"Off"};
|
std::vector<std::string> entries = {"On", "Off"};
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
auto toggle = Toggle(&entries, &selected);
|
auto toggle = Toggle(&entries, &selected);
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ TEST(ToggleTest, leftRightArrow) {
|
|||||||
EXPECT_EQ(selected, 0);
|
EXPECT_EQ(selected, 0);
|
||||||
|
|
||||||
// With more entries
|
// With more entries
|
||||||
entries = {L"1", L"2", L"3"};
|
entries = {"1", "2", "3"};
|
||||||
EXPECT_EQ(selected, 0);
|
EXPECT_EQ(selected, 0);
|
||||||
toggle->OnEvent(Event::ArrowRight);
|
toggle->OnEvent(Event::ArrowRight);
|
||||||
EXPECT_EQ(selected, 1);
|
EXPECT_EQ(selected, 1);
|
||||||
@ -59,7 +59,7 @@ TEST(ToggleTest, leftRightArrow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ToggleTest, Tab) {
|
TEST(ToggleTest, Tab) {
|
||||||
std::vector<std::wstring> entries = {L"1", L"2", L"3"};
|
std::vector<std::string> entries = {"1", "2", "3"};
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
auto toggle = Toggle(&entries, &selected);
|
auto toggle = Toggle(&entries, &selected);
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ TEST(ToggleTest, Tab) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ToggleTest, OnChange) {
|
TEST(ToggleTest, OnChange) {
|
||||||
std::vector<std::wstring> entries = {L"1", L"2", L"3"};
|
std::vector<std::string> entries = {"1", "2", "3"};
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
auto option = ToggleOption();
|
auto option = ToggleOption();
|
||||||
@ -115,7 +115,7 @@ TEST(ToggleTest, OnChange) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ToggleTest, OnEnter) {
|
TEST(ToggleTest, OnEnter) {
|
||||||
std::vector<std::wstring> entries = {L"1", L"2", L"3"};
|
std::vector<std::string> entries = {"1", "2", "3"};
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
|
@ -9,14 +9,17 @@
|
|||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
static std::string charset[] =
|
static std::string charset[] = {
|
||||||
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||||
// Microsoft's terminals often use fonts not handling the 8 unicode
|
// Microsoft's terminals often use fonts not handling the 8 unicode
|
||||||
// characters for representing the whole gauge. Fallback with less.
|
// characters for representing the whole gauge. Fallback with less.
|
||||||
{" ", " ", " ", " ", "▌", "▌", "▌", "█", "█", "█"};
|
" ", " ", " ", " ", "▌", "▌", "▌", "█", "█", "█",
|
||||||
#else
|
#else
|
||||||
{" ", " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"};
|
" ", " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█",
|
||||||
#endif
|
#endif
|
||||||
|
// An extra character in case when the fuzzer manage to have:
|
||||||
|
// int(9 * (limit - limit_int) = 9
|
||||||
|
"█"};
|
||||||
|
|
||||||
class Gauge : public Node {
|
class Gauge : public Node {
|
||||||
public:
|
public:
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include <string> // for allocator, basic_string, string
|
#include <string> // for allocator, basic_string, string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex_grow, flex_shrink, hbox
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, flex_grow, flex_shrink, hbox
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/screen.hpp" // for Screen
|
#include "ftxui/screen/screen.hpp" // for Screen
|
||||||
@ -15,9 +14,9 @@ using namespace ftxui;
|
|||||||
|
|
||||||
TEST(HBoxTest, NoFlex_NoFlex_NoFlex) {
|
TEST(HBoxTest, NoFlex_NoFlex_NoFlex) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012"),
|
text("012"),
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC"),
|
text("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -43,9 +42,9 @@ TEST(HBoxTest, NoFlex_NoFlex_NoFlex) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexGrow_NoFlex_NoFlex) {
|
TEST(HBoxTest, FlexGrow_NoFlex_NoFlex) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_grow,
|
text("012") | flex_grow,
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC"),
|
text("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -71,9 +70,9 @@ TEST(HBoxTest, FlexGrow_NoFlex_NoFlex) {
|
|||||||
|
|
||||||
TEST(HBoxTest, NoFlex_FlexGrow_NoFlex) {
|
TEST(HBoxTest, NoFlex_FlexGrow_NoFlex) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012"),
|
text("012"),
|
||||||
text(L"abc") | flex_grow,
|
text("abc") | flex_grow,
|
||||||
text(L"ABC"),
|
text("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -99,9 +98,9 @@ TEST(HBoxTest, NoFlex_FlexGrow_NoFlex) {
|
|||||||
|
|
||||||
TEST(HBoxTest, NoFlex_NoFlex_FlexGrow) {
|
TEST(HBoxTest, NoFlex_NoFlex_FlexGrow) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012"),
|
text("012"),
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC") | flex_grow,
|
text("ABC") | flex_grow,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -127,9 +126,9 @@ TEST(HBoxTest, NoFlex_NoFlex_FlexGrow) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexGrow_NoFlex_FlexGrow) {
|
TEST(HBoxTest, FlexGrow_NoFlex_FlexGrow) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_grow,
|
text("012") | flex_grow,
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC") | flex_grow,
|
text("ABC") | flex_grow,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -157,9 +156,9 @@ TEST(HBoxTest, FlexGrow_NoFlex_FlexGrow) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexGrow_FlexGrow_FlexGrow) {
|
TEST(HBoxTest, FlexGrow_FlexGrow_FlexGrow) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_grow,
|
text("012") | flex_grow,
|
||||||
text(L"abc") | flex_grow,
|
text("abc") | flex_grow,
|
||||||
text(L"ABC") | flex_grow,
|
text("ABC") | flex_grow,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -191,9 +190,9 @@ TEST(HBoxTest, FlexGrow_FlexGrow_FlexGrow) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexShrink_NoFlex_NoFlex) {
|
TEST(HBoxTest, FlexShrink_NoFlex_NoFlex) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_shrink,
|
text("012") | flex_shrink,
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC"),
|
text("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -219,9 +218,9 @@ TEST(HBoxTest, FlexShrink_NoFlex_NoFlex) {
|
|||||||
|
|
||||||
TEST(HBoxTest, NoFlex_FlexShrink_NoFlex) {
|
TEST(HBoxTest, NoFlex_FlexShrink_NoFlex) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012"),
|
text("012"),
|
||||||
text(L"abc") | flex_shrink,
|
text("abc") | flex_shrink,
|
||||||
text(L"ABC"),
|
text("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -247,9 +246,9 @@ TEST(HBoxTest, NoFlex_FlexShrink_NoFlex) {
|
|||||||
|
|
||||||
TEST(HBoxTest, NoFlex_NoFlex_FlexShrink) {
|
TEST(HBoxTest, NoFlex_NoFlex_FlexShrink) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012"),
|
text("012"),
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC") | flex_shrink,
|
text("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -275,9 +274,9 @@ TEST(HBoxTest, NoFlex_NoFlex_FlexShrink) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexShrink_NoFlex_FlexShrink) {
|
TEST(HBoxTest, FlexShrink_NoFlex_FlexShrink) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_shrink,
|
text("012") | flex_shrink,
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC") | flex_shrink,
|
text("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -302,9 +301,9 @@ TEST(HBoxTest, FlexShrink_NoFlex_FlexShrink) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexShrink_FlexShrink_FlexShrink) {
|
TEST(HBoxTest, FlexShrink_FlexShrink_FlexShrink) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_shrink,
|
text("012") | flex_shrink,
|
||||||
text(L"abc") | flex_shrink,
|
text("abc") | flex_shrink,
|
||||||
text(L"ABC") | flex_shrink,
|
text("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -331,9 +330,9 @@ TEST(HBoxTest, FlexShrink_FlexShrink_FlexShrink) {
|
|||||||
|
|
||||||
TEST(HBoxTest, FlexGrow_NoFlex_FlewShrink) {
|
TEST(HBoxTest, FlexGrow_NoFlex_FlewShrink) {
|
||||||
auto root = hbox({
|
auto root = hbox({
|
||||||
text(L"012") | flex_grow,
|
text("012") | flex_grow,
|
||||||
text(L"abc"),
|
text("abc"),
|
||||||
text(L"ABC") | flex_shrink,
|
text("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
|
@ -68,8 +68,8 @@ class HFlow : public Node {
|
|||||||
///
|
///
|
||||||
/// ```cpp
|
/// ```cpp
|
||||||
/// hbox({
|
/// hbox({
|
||||||
/// text(L"Left"),
|
/// text("Left"),
|
||||||
/// text(L"Right"),
|
/// text("Right"),
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
Element hflow(Elements children) {
|
Element hflow(Elements children) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
#include <algorithm> // for min
|
||||||
#include <memory> // for make_shared
|
#include <memory> // for make_shared
|
||||||
#include <string> // for string
|
#include <string> // for string, wstring
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text, vtext
|
#include "ftxui/dom/deprecated.hpp" // for text, vtext
|
||||||
@ -87,7 +88,7 @@ Element text(std::string text) {
|
|||||||
return std::make_shared<Text>(text);
|
return std::make_shared<Text>(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Display a piece of UTF16 encoded unicode text.
|
/// @brief Display a piece of unicode text.
|
||||||
/// @ingroup dom
|
/// @ingroup dom
|
||||||
/// @see ftxui::to_wstring
|
/// @see ftxui::to_wstring
|
||||||
///
|
///
|
||||||
@ -136,7 +137,7 @@ Element vtext(std::string text) {
|
|||||||
return std::make_shared<VText>(text);
|
return std::make_shared<VText>(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Display a piece of UTF16 encoded unicode text vertically.
|
/// @brief Display a piece unicode text vertically.
|
||||||
/// @ingroup dom
|
/// @ingroup dom
|
||||||
/// @see ftxui::to_wstring
|
/// @see ftxui::to_wstring
|
||||||
///
|
///
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
#include <gtest/gtest-message.h> // for Message
|
#include <gtest/gtest-message.h> // for Message
|
||||||
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl, TestPartResult
|
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl, TestPartResult
|
||||||
#include <string> // for allocator, wstring
|
#include <string> // for allocator, string
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for text
|
#include "ftxui/dom/elements.hpp" // for text, operator|, border, Element
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, border, Element
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/screen.hpp" // for Screen
|
#include "ftxui/screen/screen.hpp" // for Screen
|
||||||
#include "ftxui/screen/string.hpp" // for to_string
|
|
||||||
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TEST
|
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TEST
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
TEST(TextTest, ScreenHeightSmaller) {
|
TEST(TextTest, ScreenHeightSmaller) {
|
||||||
auto element = text(L"test");
|
auto element = text("test");
|
||||||
Screen screen(2, 0);
|
Screen screen(2, 0);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
|
|
||||||
@ -21,7 +19,7 @@ TEST(TextTest, ScreenHeightSmaller) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(TextTest, ScreenSmaller) {
|
TEST(TextTest, ScreenSmaller) {
|
||||||
auto element = text(L"test");
|
auto element = text("test");
|
||||||
Screen screen(2, 1);
|
Screen screen(2, 1);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
|
|
||||||
@ -29,7 +27,7 @@ TEST(TextTest, ScreenSmaller) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(TextTest, ScreenFit) {
|
TEST(TextTest, ScreenFit) {
|
||||||
auto element = text(L"test");
|
auto element = text("test");
|
||||||
Screen screen(4, 1);
|
Screen screen(4, 1);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
|
|
||||||
@ -37,7 +35,7 @@ TEST(TextTest, ScreenFit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(TextTest, ScreenBigger) {
|
TEST(TextTest, ScreenBigger) {
|
||||||
auto element = text(L"test");
|
auto element = text("test");
|
||||||
Screen screen(6, 1);
|
Screen screen(6, 1);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ TEST(TextTest, ScreenBigger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(TextTest, ScreenBigger2) {
|
TEST(TextTest, ScreenBigger2) {
|
||||||
auto element = text(L"test");
|
auto element = text("test");
|
||||||
Screen screen(6, 2);
|
Screen screen(6, 2);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
|
|
||||||
@ -54,7 +52,7 @@ TEST(TextTest, ScreenBigger2) {
|
|||||||
|
|
||||||
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
|
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
|
||||||
TEST(TextTest, CJK) {
|
TEST(TextTest, CJK) {
|
||||||
auto element = text(L"测试") | border;
|
auto element = text("测试") | border;
|
||||||
Screen screen(6, 3);
|
Screen screen(6, 3);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
@ -66,7 +64,7 @@ TEST(TextTest, CJK) {
|
|||||||
|
|
||||||
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
|
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
|
||||||
TEST(TextTest, CJK_2) {
|
TEST(TextTest, CJK_2) {
|
||||||
auto element = text(L"测试") | border;
|
auto element = text("测试") | border;
|
||||||
Screen screen(5, 3);
|
Screen screen(5, 3);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
@ -78,7 +76,7 @@ TEST(TextTest, CJK_2) {
|
|||||||
|
|
||||||
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
|
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
|
||||||
TEST(TextTest, CJK_3) {
|
TEST(TextTest, CJK_3) {
|
||||||
auto element = text(L"测试") | border;
|
auto element = text("测试") | border;
|
||||||
Screen screen(4, 3);
|
Screen screen(4, 3);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
@ -89,20 +87,20 @@ TEST(TextTest, CJK_3) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(TextTest, CombiningCharacters) {
|
TEST(TextTest, CombiningCharacters) {
|
||||||
const std::wstring t =
|
const std::string t =
|
||||||
// Combining above:
|
// Combining above:
|
||||||
L"ā à á â ã ā a̅ ă ȧ ä ả å a̋ ǎ a̍ a̎ ȁ a̐ ȃ a̒ a̔ a̕ a̚ a̛ a̽ a̾ a̿ à á a͂ a͆ a͊ a͋ a͌ a͐ "
|
"ā à á â ã ā a̅ ă ȧ ä ả å a̋ ǎ a̍ a̎ ȁ a̐ ȃ a̒ a̔ a̕ a̚ a̛ a̽ a̾ a̿ à á a͂ a͆ a͊ a͋ a͌ a͐ "
|
||||||
L"a͑ a͒ a͗ a͘ a͛ a͝ a͞ a͠ a͡ aͣ aͤ aͥ aͦ aͧ aͨ aͩ aͪ aͫ aͬ aͭ aͮ aͯ a᷀ a᷁ a᷃ a᷄ a᷅ a᷆ a᷇ a᷈ a᷉ a᷾ a⃐ a⃑ a⃔ "
|
"a͑ a͒ a͗ a͘ a͛ a͝ a͞ a͠ a͡ aͣ aͤ aͥ aͦ aͧ aͨ aͩ aͪ aͫ aͬ aͭ aͮ aͯ a᷀ a᷁ a᷃ a᷄ a᷅ a᷆ a᷇ a᷈ a᷉ a᷾ a⃐ a⃑ a⃔ "
|
||||||
L"a⃕ a⃖ a⃗ a⃛ a⃜ a⃡ a⃩ a⃰ a︠ a︡ a︢ a︣"
|
"a⃕ a⃖ a⃗ a⃛ a⃜ a⃡ a⃩ a⃰ a︠ a︡ a︢ a︣"
|
||||||
// Combining middle:
|
// Combining middle:
|
||||||
L"a̴ a̵ a̶ a̷ a̸ a⃒ a⃓ a⃘ a⃙ a⃚ a⃝ a⃞ a⃟ a⃥ a⃦"
|
"a̴ a̵ a̶ a̷ a̸ a⃒ a⃓ a⃘ a⃙ a⃚ a⃝ a⃞ a⃟ a⃥ a⃦"
|
||||||
// Combining below:
|
// Combining below:
|
||||||
L"a̗ a̘ a̙ a̜ a̝ a̞ a̟ a̠ a̡ a̢ ạ ḁ a̦ a̧ ą a̩ a̪ a̫ a̬ a̭ a̮ a̯ a̰ a̱ a̲ a̳ a̹ a̺ a̻ a̼ aͅ a͇ a͈ a͉ a͍ "
|
"a̗ a̘ a̙ a̜ a̝ a̞ a̟ a̠ a̡ a̢ ạ ḁ a̦ a̧ ą a̩ a̪ a̫ a̬ a̭ a̮ a̯ a̰ a̱ a̲ a̳ a̹ a̺ a̻ a̼ aͅ a͇ a͈ a͉ a͍ "
|
||||||
L"a͎ a͓ a͔ a͕ a͖ a͙ a͚ a͜ a͟ a͢ a᷂ a᷊ a᷿ a⃨";
|
"a͎ a͓ a͔ a͕ a͖ a͙ a͚ a͜ a͟ a͢ a᷂ a᷊ a᷿ a⃨";
|
||||||
auto element = text(t);
|
auto element = text(t);
|
||||||
Screen screen(290, 1);
|
Screen screen(290, 1);
|
||||||
Render(screen, element);
|
Render(screen, element);
|
||||||
EXPECT_EQ(to_string(t), screen.ToString());
|
EXPECT_EQ(t, screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <string> // for allocator, basic_string, string
|
#include <string> // for allocator, basic_string, string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/dom/deprecated.hpp" // for vtext
|
#include "ftxui/dom/elements.hpp" // for vtext, operator|, Element, flex_grow, flex_shrink, vbox
|
||||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, flex_grow, flex_shrink, vbox
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/screen.hpp" // for Screen
|
#include "ftxui/screen/screen.hpp" // for Screen
|
||||||
@ -22,9 +21,9 @@ std::string rotate(std::string str) {
|
|||||||
|
|
||||||
TEST(VBoxText, NoFlex_NoFlex_NoFlex) {
|
TEST(VBoxText, NoFlex_NoFlex_NoFlex) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012"),
|
vtext("012"),
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC"),
|
vtext("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -50,9 +49,9 @@ TEST(VBoxText, NoFlex_NoFlex_NoFlex) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexGrow_NoFlex_NoFlex) {
|
TEST(VBoxText, FlexGrow_NoFlex_NoFlex) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_grow,
|
vtext("012") | flex_grow,
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC"),
|
vtext("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -78,9 +77,9 @@ TEST(VBoxText, FlexGrow_NoFlex_NoFlex) {
|
|||||||
|
|
||||||
TEST(VBoxText, NoFlex_FlexGrow_NoFlex) {
|
TEST(VBoxText, NoFlex_FlexGrow_NoFlex) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012"),
|
vtext("012"),
|
||||||
vtext(L"abc") | flex_grow,
|
vtext("abc") | flex_grow,
|
||||||
vtext(L"ABC"),
|
vtext("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -106,9 +105,9 @@ TEST(VBoxText, NoFlex_FlexGrow_NoFlex) {
|
|||||||
|
|
||||||
TEST(VBoxText, NoFlex_NoFlex_FlexGrow) {
|
TEST(VBoxText, NoFlex_NoFlex_FlexGrow) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012"),
|
vtext("012"),
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC") | flex_grow,
|
vtext("ABC") | flex_grow,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -134,9 +133,9 @@ TEST(VBoxText, NoFlex_NoFlex_FlexGrow) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexGrow_NoFlex_FlexGrow) {
|
TEST(VBoxText, FlexGrow_NoFlex_FlexGrow) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_grow,
|
vtext("012") | flex_grow,
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC") | flex_grow,
|
vtext("ABC") | flex_grow,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -164,9 +163,9 @@ TEST(VBoxText, FlexGrow_NoFlex_FlexGrow) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexGrow_FlexGrow_FlexGrow) {
|
TEST(VBoxText, FlexGrow_FlexGrow_FlexGrow) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_grow,
|
vtext("012") | flex_grow,
|
||||||
vtext(L"abc") | flex_grow,
|
vtext("abc") | flex_grow,
|
||||||
vtext(L"ABC") | flex_grow,
|
vtext("ABC") | flex_grow,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -198,9 +197,9 @@ TEST(VBoxText, FlexGrow_FlexGrow_FlexGrow) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexShrink_NoFlex_NoFlex) {
|
TEST(VBoxText, FlexShrink_NoFlex_NoFlex) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_shrink,
|
vtext("012") | flex_shrink,
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC"),
|
vtext("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -226,9 +225,9 @@ TEST(VBoxText, FlexShrink_NoFlex_NoFlex) {
|
|||||||
|
|
||||||
TEST(VBoxText, NoFlex_FlexShrink_NoFlex) {
|
TEST(VBoxText, NoFlex_FlexShrink_NoFlex) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012"),
|
vtext("012"),
|
||||||
vtext(L"abc") | flex_shrink,
|
vtext("abc") | flex_shrink,
|
||||||
vtext(L"ABC"),
|
vtext("ABC"),
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -254,9 +253,9 @@ TEST(VBoxText, NoFlex_FlexShrink_NoFlex) {
|
|||||||
|
|
||||||
TEST(VBoxText, NoFlex_NoFlex_FlexShrink) {
|
TEST(VBoxText, NoFlex_NoFlex_FlexShrink) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012"),
|
vtext("012"),
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC") | flex_shrink,
|
vtext("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -282,9 +281,9 @@ TEST(VBoxText, NoFlex_NoFlex_FlexShrink) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexShrink_NoFlex_FlexShrink) {
|
TEST(VBoxText, FlexShrink_NoFlex_FlexShrink) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_shrink,
|
vtext("012") | flex_shrink,
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC") | flex_shrink,
|
vtext("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -309,9 +308,9 @@ TEST(VBoxText, FlexShrink_NoFlex_FlexShrink) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexShrink_FlexShrink_FlexShrink) {
|
TEST(VBoxText, FlexShrink_FlexShrink_FlexShrink) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_shrink,
|
vtext("012") | flex_shrink,
|
||||||
vtext(L"abc") | flex_shrink,
|
vtext("abc") | flex_shrink,
|
||||||
vtext(L"ABC") | flex_shrink,
|
vtext("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
@ -338,9 +337,9 @@ TEST(VBoxText, FlexShrink_FlexShrink_FlexShrink) {
|
|||||||
|
|
||||||
TEST(VBoxText, FlexGrow_NoFlex_FlewShrink) {
|
TEST(VBoxText, FlexGrow_NoFlex_FlewShrink) {
|
||||||
auto root = vbox({
|
auto root = vbox({
|
||||||
vtext(L"012") | flex_grow,
|
vtext("012") | flex_grow,
|
||||||
vtext(L"abc"),
|
vtext("abc"),
|
||||||
vtext(L"ABC") | flex_shrink,
|
vtext("ABC") | flex_shrink,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::string> expectations = {
|
std::vector<std::string> expectations = {
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <locale> // for wstring_convert
|
#include <locale> // for wstring_convert
|
||||||
#include <string> // for string, basic_string, wstring, allocator
|
#include <string> // for string, basic_string, wstring, allocator
|
||||||
|
|
||||||
|
#include "ftxui/screen/deprecated.hpp" // for wchar_width, wstring_width
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct Interval {
|
struct Interval {
|
||||||
|
Loading…
Reference in New Issue
Block a user