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// このソースコードの使用は、LICENSEファイルにあるMITライセンスに準拠しています。
3#include <memory> // for allocator, shared_ptr, __shared_ptr_access
4#include <string> // for operator+, string, char_traits, basic_string
5
6#include "ftxui/component/captured_mouse.hpp" // for ftxui
7#include "ftxui/component/component.hpp" // for Button, Vertical, Renderer
8#include "ftxui/component/component_base.hpp" // for ComponentBase
9#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
10#include "ftxui/dom/elements.hpp" // for separator, text, Element, operator|, vbox, border
11
12using namespace ftxui;
13
14void Nested(std::string path) {
15 auto screen = ScreenInteractive::FitComponent();
16 auto back_button = Button("Back", screen.ExitLoopClosure());
17 auto goto_1 = Button("Goto /1", [path] { Nested(path + "/1"); });
18 auto goto_2 = Button("Goto /2", [path] { Nested(path + "/2"); });
19 auto goto_3 = Button("Goto /3", [path] { Nested(path + "/3"); });
20 auto layout = Container::Vertical({
21 back_button,
22 goto_1,
23 goto_2,
24 goto_3,
25 });
26 auto renderer = Renderer(layout, [&] {
27 return vbox({
28 text("path: " + path),
29 separator(),
30 back_button->Render(),
31 goto_1->Render(),
32 goto_2->Render(),
33 goto_3->Render(),
34 }) |
35 border;
36 });
37 screen.Loop(renderer);
38}
39
40int main() {
41 auto screen = ScreenInteractive::FitComponent();
42 auto button_quit = Button("Quit", screen.ExitLoopClosure());
43 auto button_nested = Button("Nested", [] { Nested(""); });
44 screen.Loop(Container::Vertical({
45 button_quit,
46 button_nested,
47 }));
48 return 0;
49}
static ScreenInteractive FitComponent()
描画されるコンポーネントの幅と高さに一致するScreenInteractiveを作成します。
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked. (ja: ボタンを描画します。クリックされたときに機能を実行します。)
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
virtual void Render(Screen &screen)
要素をftxui::Screenに表示します。
Definition node.cpp:59
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
Element vbox(Elements)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:94
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Element separator()
void Nested(std::string path)
int main()