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