mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-23 13:28:08 +08:00
Update examples to use std::string. (#182)
In examples and tests, use std::string. In addtion: 1. Address follow-up from: https://github.com/ArthurSonzogni/FTXUI/pull/179 2. Fix a bug when Input is used with std::string.
This commit is contained in:
@@ -4,8 +4,7 @@
|
||||
#include "ftxui/component/component.hpp" // for Renderer, Button, Vertical
|
||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||
#include "ftxui/dom/deprecated.hpp" // for text
|
||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, bold, border, center, color
|
||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, text, bold, border, center, color
|
||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
@@ -18,18 +17,18 @@ int main(int argc, const char* argv[]) {
|
||||
// 1. Example of focusable renderer:
|
||||
auto renderer_focusable = Renderer([](bool focused) {
|
||||
if (focused)
|
||||
return text(L"FOCUSABLE RENDERER()") | center | bold | border;
|
||||
return text("FOCUSABLE RENDERER()") | center | bold | border;
|
||||
else
|
||||
return text(L" Focusable renderer() ") | center | border;
|
||||
return text(" Focusable renderer() ") | center | border;
|
||||
});
|
||||
|
||||
// 2. Examples of a 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.
|
||||
auto button = Button(L"Wrapped quit button", screen.ExitLoopClosure());
|
||||
auto button = Button("Wrapped quit button", screen.ExitLoopClosure());
|
||||
auto renderer_wrap = Renderer(button, [&] {
|
||||
if (button->Focused())
|
||||
return button->Render() | bold | color(Color::Red);
|
||||
|
Reference in New Issue
Block a user