FTXUI
6.1.9
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.
4
#include "
ftxui/component/loop.hpp
"
5
6
#include <utility>
// for move
7
8
#include "
ftxui/component/screen_interactive.hpp
"
// for ScreenInteractive, Component
9
10
namespace
ftxui
{
11
12
/// @brief 迴圈是 Component 和 ScreenInteractive 的包裝器。
13
/// 它用於在終端機中執行元件。
14
/// @see Component, ScreenInteractive.
15
/// @see ScreenInteractive::Loop().
16
/// @see ScreenInteractive::ExitLoop().
17
/// @param[in] screen 要使用的螢幕。
18
/// @param[in] component 要執行的元件。
19
// NOLINTNEXTLINE
20
Loop::Loop
(
ScreenInteractive
* screen,
Component
component
)
21
: screen_(screen), component_(std::move(
component
)) {
22
screen_->PreMain();
23
}
24
25
Loop::~Loop
() {
26
screen_->PostMain();
27
}
28
29
/// @brief 迴圈是否已退出。
30
bool
Loop::HasQuitted
() {
31
return
screen_->HasQuitted();
32
}
33
34
/// @brief 執行迴圈。讓 `component` 處理所有待處理的任務/事件。
35
/// 如果前一個影格失效,可能會繪製一個新影格。
36
/// 在迴圈完成之前返回 true。
37
void
Loop::RunOnce
() {
38
screen_->RunOnce(component_);
39
}
40
41
/// @brief 等待至少一個事件被處理並執行
42
/// `Loop::RunOnce()`。
43
void
Loop::RunOnceBlocking
() {
44
screen_->RunOnceBlocking(component_);
45
}
46
47
/// 執行迴圈,阻塞當前執行緒,直到迴圈退出。
48
void
Loop::Run
() {
49
while
(!
HasQuitted
()) {
50
RunOnceBlocking
();
51
}
52
}
53
54
}
// namespace ftxui
ftxui::Loop::HasQuitted
bool HasQuitted()
迴圈是否已退出。
Definition
loop.cpp:30
ftxui::Loop::~Loop
~Loop()
Definition
loop.cpp:25
ftxui::Loop::Run
void Run()
執行迴圈,阻塞當前執行緒,直到迴圈退出。
Definition
loop.cpp:48
ftxui::Loop::Loop
Loop(ScreenInteractive *screen, Component component)
迴圈是 Component 和 ScreenInteractive 的包裝器。 它用於在終端機中執行元件。
Definition
loop.cpp:20
ftxui::Loop::RunOnce
void RunOnce()
執行迴圈。讓 component 處理所有待處理的任務/事件。 如果前一個影格失效,可能會繪製一個新影格。 在迴圈完成之前返回 true。
Definition
loop.cpp:37
ftxui::Loop::RunOnceBlocking
void RunOnceBlocking()
等待至少一個事件被處理並執行 Loop::RunOnce()。
Definition
loop.cpp:43
component
auto component
Definition
gallery.cpp:127
ftxui::ScreenInteractive
ScreenInteractive 是一個可以處理事件、執行主迴圈並管理組件的 Screen。
Definition
screen_interactive.hpp:33
loop.hpp
ftxui
FTXUI 的 ftxui:: 命名空間
Definition
animation.hpp:10
ftxui::Component
std::shared_ptr< ComponentBase > Component
Definition
component_base.hpp:23
screen_interactive.hpp