FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
loop.cpp
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.
5
6#include <utility> // for move
7
8#include "ftxui/component/app.hpp" // for App, Component
9
10namespace ftxui {
11
12/// @brief LoopはComponentとAppを包むラッパーです。
13/// 端末でComponentを実行するために使用されます。
14/// @see Component, App.
15/// @see App::Loop().
16/// @see App::Exit().
17/// @param[in] screen 使用するスクリーン。
18/// @param[in] component 実行するコンポーネント。
19// NOLINTNEXTLINE
20Loop::Loop(App* screen, Component component)
21 : screen_(screen), component_(std::move(component)) {
22 screen_->PreMain();
23}
24
25Loop::~Loop() {
26 screen_->PostMain();
27}
28
29/// @brief ループが終了したかどうか。
30bool Loop::HasQuitted() {
31 return screen_->HasQuitted();
32}
33
34/// @brief ループを実行します。`component`に保留中のすべてのタスク/イベントを処理させます。
35/// 前のフレームが無効になった場合、新しいフレームが描画される可能性があります。
36/// ループが完了するまでtrueを返します。
37void Loop::RunOnce() {
38 screen_->RunOnce(component_);
39}
40
41/// @brief 少なくとも1つのイベントが処理されるのを待ち、`Loop::RunOnce()`を実行します。
42void Loop::RunOnceBlocking() {
43 screen_->RunOnceBlocking(component_);
44}
45
46/// ループを実行し、ループが終了するまで現在のスレッドを
47/// ブロックします。
48void Loop::Run() {
49 while (!HasQuitted()) {
50 RunOnceBlocking();
51 }
52}
53
54} // namespace ftxui
FTXUI ftxui::名前空間
Definition animation.hpp:11
std::shared_ptr< ComponentBase > Component
Definition app.hpp:23