FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
nested_screen.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <memory> // for allocator, shared_ptr, __shared_ptr_access
5#include <string> // for operator+, string, char_traits, basic_string
6
7#include "ftxui/component/captured_mouse.hpp" // for ftxui
8#include "ftxui/component/component.hpp" // for Button, Vertical, Renderer
9#include "ftxui/component/component_base.hpp" // for ComponentBase
10#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
11#include "ftxui/dom/elements.hpp" // for separator, text, Element, operator|, vbox, border
12
13 using namespace ftxui;
14
15 void Nested(std::string path) {
16 auto screen = ScreenInteractive::FitComponent();
17 auto back_button = Button("Back", screen.ExitLoopClosure());
18 auto goto_1 = Button("Goto /1", [path] { Nested(path + "/1"); });
19 auto goto_2 = Button("Goto /2", [path] { Nested(path + "/2"); });
20 auto goto_3 = Button("Goto /3", [path] { Nested(path + "/3"); });
21 auto layout = Container::Vertical({
22 back_button,
23 goto_1,
24 goto_2,
25 goto_3,
26 });
27 auto renderer = Renderer(layout, [&] {
28 return vbox({
29 text("path: " + path),
30 separator(),
31 back_button->Render(),
32 goto_1->Render(),
33 goto_2->Render(),
34 goto_3->Render(),
35 }) |
36 border;
37 });
38 screen.Loop(renderer);
39}
40
41 int main() {
42 auto screen = ScreenInteractive::FitComponent();
43 auto button_quit = Button("Quit", screen.ExitLoopClosure());
44 auto button_nested = Button("Nested", [] { Nested(""); });
45 screen.Loop(Container::Vertical({
46 button_quit,
47 button_nested,
48 }));
49 return 0;
50}
captured_mouse.hpp
component.hpp
component_base.hpp
elements.hpp
ftxui::ScreenInteractive::FitComponent
static ScreenInteractive FitComponent()
Definition screen_interactive.cpp:423
ftxui::Button
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
Definition src/ftxui/component/button.cpp:175
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 src/ftxui/component/renderer.cpp:61
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::Node::Render
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Definition node.cpp:59
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 src/ftxui/dom/separator.cpp:134
ftxui::vbox
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition vbox.cpp:96
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
Nested
void Nested(std::string path)
Definition nested_screen.cpp:15
main
int main()
Definition nested_screen.cpp:41
screen_interactive.hpp