FTXUI
6.1.9
C++ functional terminal UI.
Toggle main menu visibility
Loading...
Searching...
No Matches
examples/component/nested_screen.cpp
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <memory>
// for allocator, shared_ptr, __shared_ptr_access
#include <string>
// for operator+, string, char_traits, basic_string
#include "
ftxui/component/captured_mouse.hpp
"
// for ftxui
#include "
ftxui/component/component.hpp
"
// for Button, Vertical, Renderer
#include "
ftxui/component/component_base.hpp
"
// for ComponentBase
#include "
ftxui/component/screen_interactive.hpp
"
// for ScreenInteractive
#include "
ftxui/dom/elements.hpp
"
// for separator, text, Element, operator|, vbox, border
using namespace
ftxui
;
void
Nested(std::string path) {
auto
screen =
ScreenInteractive::FitComponent
();
auto
back_button =
Button
(
"Back"
, screen.ExitLoopClosure());
auto
goto_1 =
Button
(
"Goto /1"
, [path] { Nested(path +
"/1"
); });
auto
goto_2 =
Button
(
"Goto /2"
, [path] { Nested(path +
"/2"
); });
auto
goto_3 =
Button
(
"Goto /3"
, [path] { Nested(path +
"/3"
); });
auto
layout =
Container::Vertical
({
back_button,
goto_1,
goto_2,
goto_3,
});
auto
renderer =
Renderer
(layout, [&] {
return
vbox
({
text
(
"path: "
+ path),
separator
(),
back_button->Render(),
goto_1->Render(),
goto_2->Render(),
goto_3->Render(),
}) |
border
;
});
screen.Loop(renderer);
}
int
main() {
auto
screen =
ScreenInteractive::FitComponent
();
auto
button_quit =
Button
(
"Quit"
, screen.ExitLoopClosure());
auto
button_nested =
Button
(
"Nested"
, [] { Nested(
""
); });
screen.Loop(
Container::Vertical
({
button_quit,
button_nested,
}));
return
0;
}
captured_mouse.hpp
ftxui::ScreenInteractive::FitComponent
static ScreenInteractive FitComponent()
Definition
screen_interactive.cpp:416
component.hpp
component_base.hpp
elements.hpp
ftxui::Container::Vertical
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Definition
container.cpp:317
ftxui
Definition
animation.hpp:10
ftxui::Button
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
Definition
button.cpp:176
ftxui::Renderer
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition
renderer.cpp:61
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition
text.cpp:160
ftxui::separator
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Definition
separator.cpp:134
ftxui::border
Element border(Element)
Draw a border around the element.
Definition
border.cpp:227
ftxui::vbox
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition
vbox.cpp:96
screen_interactive.hpp