FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/component/selection.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. 無断転載を禁じます。
2// このソースコードの使用は、以下に記載されているMITライセンスに準拠します。
3// LICENSEファイル。
4#include <string> // for char_traits, operator+, string, basic_string
5
6#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical
7#include "ftxui/component/component_base.hpp" // for ComponentBase
8#include "ftxui/component/component_options.hpp" // for InputOption
9#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
10#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
11#include "ftxui/util/ref.hpp" // for Ref
12
13using namespace ftxui;
14
16 return vbox({
17 text("FTXUI: ユーザーインターフェースを構築するための強力なライブラリ。"),
18 text("豊富なコンポーネントセットと宣言的なスタイルをお楽しみください。"),
19 text("最小限の労力で美しく応答性の高いUIを作成します。"),
20 text("コミュニティに参加して、FTXUIの力を体験してください。"),
21 });
22}
23
24int main() {
26
27 auto quit =
28 Button("Quit", screen.ExitLoopClosure(), ButtonOption::Animated());
29
30 int selection_change_counter = 0;
31 std::string selection_content = "";
32 screen.SelectionChange([&] {
33 selection_change_counter++;
34 selection_content = screen.GetSelection();
35 });
36
37 // コンポーネント:
38 auto renderer = Renderer(quit, [&] {
39 return vbox({
40 text("選択変更: " + std::to_string(selection_change_counter) +
41 " times"),
42 text("現在選択中: "),
43 paragraph(selection_content) | vscroll_indicator | frame | border |
44 size(HEIGHT, EQUAL, 10),
45 window(text("水平分割"), hbox({
46 LoremIpsum(),
47 separator(),
48 LoremIpsum(),
49 separator(),
50 LoremIpsum(),
51 })),
52 window(text("垂直分割"), vbox({
53 LoremIpsum(),
54 separator(),
55 LoremIpsum(),
56 separator(),
57 LoremIpsum(),
58 })),
59 window(text("異なるスタイルのグリッド分割"),
60 vbox({
61 hbox({
62 LoremIpsum(),
63 separator(),
64 LoremIpsum() //
68 separator(),
70 }),
71 separator(),
72 hbox({
74 separator(),
75 LoremIpsum() | selectionStyle([](Pixel& pixel) {
76 pixel.underlined_double = true;
77 }),
78 separator(),
79 LoremIpsum(),
80 }),
81 })),
82 quit->Render(),
83 });
84 });
85
86 screen.Loop(renderer);
87}
Element LoremIpsum()
static ButtonOption Animated()
アニメーションカラーを使用するButtonOptionを作成します。
static ScreenInteractive TerminalOutput()
ターミナル出力の幅に一致し、描画されるコンポーネントの高さに一致する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
bool underlined_double
Definition pixel.hpp:33
Unicode文字とそれに関連付けられたスタイル。
Definition pixel.hpp:14
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
std::shared_ptr< Node > Element
Definition elements.hpp:21
Decorator selectionStyle(std::function< void(Pixel &)> style)
要素が選択されたときのスタイルを設定します。
Element hbox(Elements)
要素を水平方向に1つずつ表示するコンテナ。
Definition hbox.cpp:93
Decorator selectionBackgroundColor(Color foreground)
要素が選択されたときの背景色を設定します。 スタイルは既存のスタイルに重ねて適用されることに注意してください。
Element window(Element title, Element content, BorderStyle border=ROUNDED)
Decorator selectionColor(Color foreground)
要素が選択されたときの色を設定します。
Element selectionStyleReset(Element)
要素の選択スタイルをリセットします。
Element separator()
Elements paragraph(std::wstring text)
return size
Definition string.cpp:1516