FTXUI
4.1.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
loop.cpp
Go to the documentation of this file.
1
#include "
ftxui/component/loop.hpp
"
2
3
#include <utility>
// for move
4
5
#include "
ftxui/component/screen_interactive.hpp
"
// for ScreenInteractive, Component
6
7
namespace
ftxui
{
8
9
// NOLINTNEXTLINE
10
Loop::Loop
(
ScreenInteractive
* screen,
Component
component)
11
: screen_(screen), component_(std::move(component)) {
12
screen_->PreMain();
13
}
14
15
Loop::~Loop
() {
16
screen_->PostMain();
17
}
18
19
bool
Loop::HasQuitted
() {
20
return
screen_->HasQuitted();
21
}
22
23
/// @brief Execute the loop. Make the `component` to process every pending
24
/// tasks/events. A new frame might be drawn if the previous was invalidated.
25
/// Return true until the loop hasn't completed.
26
void
Loop::RunOnce
() {
27
screen_->RunOnce(component_);
28
}
29
30
/// @brief Wait for at least one event to be handled and execute
31
/// `Loop::RunOnce()`.
32
void
Loop::RunOnceBlocking
() {
33
screen_->RunOnceBlocking(component_);
34
}
35
36
/// Execute the loop, blocking the current thread, up until the loop has
37
/// quitted.
38
void
Loop::Run
() {
39
while
(!
HasQuitted
()) {
40
RunOnceBlocking
();
41
}
42
}
43
44
}
// namespace ftxui
45
46
// Copyright 2022 Arthur Sonzogni. All rights reserved.
47
// Use of this source code is governed by the MIT license that can be found in
48
// the LICENSE file.
ftxui::Loop::HasQuitted
bool HasQuitted()
Definition
loop.cpp:19
ftxui::Loop::~Loop
~Loop()
Definition
loop.cpp:15
ftxui::Loop::Run
void Run()
Definition
loop.cpp:38
ftxui::Loop::Loop
Loop(ScreenInteractive *screen, Component component)
Definition
loop.cpp:10
ftxui::Loop::RunOnce
void RunOnce()
Execute the loop. Make the component to process every pending tasks/events. A new frame might be draw...
Definition
loop.cpp:26
ftxui::Loop::RunOnceBlocking
void RunOnceBlocking()
Wait for at least one event to be handled and execute Loop::RunOnce().
Definition
loop.cpp:32
ftxui::ScreenInteractive
Definition
screen_interactive.hpp:26
loop.hpp
ftxui
Definition
animation.hpp:9
ftxui::Component
std::shared_ptr< ComponentBase > Component
Definition
component_base.hpp:21
screen_interactive.hpp