FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
loop.hpp
Go to the documentation of this file.
1// Copyright 2022 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#ifndef FTXUI_COMPONENT_LOOP_HPP
5#define FTXUI_COMPONENT_LOOP_HPP
6
7#include <memory> // for shared_ptr
8
9#include "ftxui/component/component_base.hpp" // for ComponentBase
10#include "ftxui/util/export.hpp" // for FTXUI_EXPORT
11
12namespace ftxui {
13class ComponentBase;
14
15using Component = std::shared_ptr<ComponentBase>;
16class App;
17
18/// @brief Loopは、コンポーネントのイベントループを管理するクラスです。
19///
20/// コンポーネントの実行、イベントの処理、画面の更新を担当します。
21///
22/// Loopクラスは、ターミナル画面を表すAppオブジェクトと
23/// 一緒に使用するように設計されています。
24///
25/// **例**
26/// ```cpp
27/// #include <ftxui/component/component.hpp>
28/// #include <ftxui/component/app.hpp>
29/// #include <ftxui/component/loop.hpp>
30///
31/// int main() {
32/// auto screen = ftxui::App::TerminalOutput();
33/// auto component = ftxui::Button("Click me", [] { ... });
34///
35/// ftxui::Loop loop(screen.get(), component);
36///
37/// // または
38/// loop.Run(); // コンポーネントが終了するまでブロックします。
39///
40/// // または
41/// loop.RunOnce(); // ノンブロッキングで、即座に戻ります。
42///
43/// // または
44/// loop.RunOnceBlocking(); // 1つのイベントを処理するまでブロックします。
45///
46/// // またはループ内で:
47/// while (!loop.HasQuitted()) {
48/// loop.RunOnce();
49///
50/// // 別のライブラリのループ関数を実行するなど、他の処理を行います。
51/// }
52/// }
53/// ```
54///
55/// @ingroup component
56class FTXUI_EXPORT(COMPONENT) Loop {
57 public:
58 Loop(App* screen, Component component);
59 ~Loop();
60
61 bool HasQuitted();
62 void RunOnce();
63 void RunOnceBlocking();
64 void Run();
65
66 // このクラスはコピー/ムーブ不可です。
67 Loop& operator=(Loop&&) = delete;
68 Loop& operator=(const Loop&) = delete;
69 Loop(Loop&&) = delete;
70 Loop(const Loop&) = delete;
71
72 private:
73 App* screen_;
74 Component component_;
75};
76
77} // namespace ftxui
78
79#endif // FTXUI_COMPONENT_LOOP_HPP
FTXUI ftxui::名前空間
Definition animation.hpp:11
std::shared_ptr< ComponentBase > Component
Definition app.hpp:23