FTXUI 6.1.9
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// このソースコードの使用は、LICENSE ファイルにある MIT ライセンスによって管理されます。
3#ifndef FTXUI_COMPONENT_LOOP_HPP
4#define FTXUI_COMPONENT_LOOP_HPP
5
6#include <memory> // for shared_ptr
7
8#include "ftxui/component/component_base.hpp" // for ComponentBase
9
10namespace ftxui {
11class ComponentBase;
12
13using Component = std::shared_ptr<ComponentBase>;
14class ScreenInteractive;
15
16/// @brief Loopは、コンポーネントのイベントループを管理するクラスです。
17///
18/// コンポーネントの実行、イベントの処理、および画面の更新を担当します。
19///
20/// Loopクラスは、ターミナル画面を表すScreenInteractiveオブジェクトと共に使用するように設計されています。
21///
22/// **例**
23/// ```cpp
24/// #include <ftxui/component/component.hpp>
25/// #include <ftxui/component/screen_interactive.hpp>
26/// #include <ftxui/component/loop.hpp>
27///
28/// int main() {
29/// auto screen = ftxui::ScreenInteractive::TerminalOutput();
30/// auto component = ftxui::Button("Click me", [] { ... });
31///
32/// ftxui::Loop loop(screen.get(), component);
33///
34/// // いずれか
35/// loop.Run(); // コンポーネントが終了するまでブロックします。
36///
37/// // または
38/// loop.RunOnce(); // 非ブロッキングで、すぐに戻ります。
39///
40/// // または
41/// loop.RunOnceBlocking(); // 1つのイベントを処理するまでブロックします。
42///
43/// // またはループで:
44/// while (!loop.HasQuitted()) {
45/// loop.RunOnce();
46///
47/// // 別のライブラリのループ関数を実行するなど、他のことを行います。
48/// }
49/// }
50/// ```
51///
52/// @ingroup component
53class Loop {
54 public:
55 Loop(ScreenInteractive* screen, Component component);
56 ~Loop();
57
58 bool HasQuitted();
59 void RunOnce();
60 void RunOnceBlocking();
61 void Run();
62
63 // このクラスはコピー/移動できません。
64 Loop(const Loop&) = default;
65 Loop(Loop&&) = delete;
66 Loop& operator=(Loop&&) = delete;
67 Loop(const ScreenInteractive&) = delete;
68 Loop& operator=(const Loop&) = delete;
69
70 private:
71 ScreenInteractive* screen_;
72 Component component_;
73};
74
75} // namespace ftxui
76
77#endif // FTXUI_COMPONENT_LOOP_HPP
bool HasQuitted()
ループが終了したかどうか。
Definition loop.cpp:29
Loop(const ScreenInteractive &)=delete
void Run()
ループが終了するまで、現在のスレッドをブロックしてループを実行します。
Definition loop.cpp:46
Loop(ScreenInteractive *screen, Component component)
LoopはComponentとScreenInteractiveのラッパーです。 これはターミナルでコンポーネントを実行するために使用されます。
Definition loop.cpp:19
Loop & operator=(const Loop &)=delete
void RunOnce()
ループを実行します。componentに保留中のすべてのタスク/イベントを処理させます。 前のフレームが無効になった場合、新しいフレームが描画される可能性があります。 ループが完了するまでtrueを返し...
Definition loop.cpp:36
Loop(const Loop &)=default
Loop & operator=(Loop &&)=delete
Loop(Loop &&)=delete
void RunOnceBlocking()
少なくとも1つのイベントが処理されるのを待ち、Loop::RunOnce()を実行します。
Definition loop.cpp:41
Loopは、コンポーネントのイベントループを管理するクラスです。
Definition loop.hpp:53
ScreenInteractive はイベントを処理し、メインループを実行し、コンポーネントを管理できる Screen です。
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
std::shared_ptr< ComponentBase > Component