FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/component/maybe.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// MITライセンスに従って、このソースコードを使用することができます。ライセンスは
3// LICENSEファイルに記載されています。
4#include <string> // for string, allocator, basic_string
5#include <vector> // for vector
6
7#include "ftxui/component/captured_mouse.hpp" // for ftxui
8#include "ftxui/component/component.hpp" // for operator|, Maybe, Checkbox, Radiobox, Renderer, Vertical
9#include "ftxui/component/component_base.hpp" // for Component
10#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
11#include "ftxui/dom/elements.hpp" // for Element, border, color, operator|, text
12#include "ftxui/screen/color.hpp" // for Color, Color::Red
13
14using namespace ftxui;
15
16int main() {
17 std::vector<std::string> entries = {
18 "entry 1",
19 "entry 2",
20 "entry 3",
21 };
22 int menu_1_selected = 0;
23 int menu_2_selected = 0;
24
25 bool menu_1_show = false;
26 bool menu_2_show = false;
27
28 auto layout = Container::Vertical({
29 Checkbox("Show menu_1", &menu_1_show),
30 Radiobox(&entries, &menu_1_selected) | border | Maybe(&menu_1_show),
31 Checkbox("Show menu_2", &menu_2_show),
32 Radiobox(&entries, &menu_2_selected) | border | Maybe(&menu_2_show),
33
34 Renderer([] {
35 return text("You found the secret combinaison!") | color(Color::Red);
36 }) | Maybe([&] { return menu_1_selected == 1 && menu_2_selected == 2; }),
37 });
38
40 screen.Loop(layout);
41}
static ScreenInteractive TerminalOutput()
ターミナル出力の幅に一致し、描画されるコンポーネントの高さに一致するScreenInteractiveを作成します。
Component Maybe(Component, const bool *show)
コンポーネント|child|を装飾します。|show|がtrueの場合にのみ表示されます。
Component Radiobox(RadioboxOption options)
1つだけ選択できる要素のリスト。
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
Component Checkbox(CheckboxOption options)
チェック可能な要素を描画します。
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
Decorator color(Color)
前景色を使用して装飾します。
FTXUI ftxui:: 名前空間
Definition animation.hpp:9