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 Un Loop es un envoltorio alrededor de un Component y una App.
13/// Se usa para ejecutar un Component en un terminal.
14/// @see Component, App.
15/// @see App::Loop().
16/// @see App::Exit().
17/// @param[in] screen La pantalla a usar.
18/// @param[in] component El componente a ejecutar.
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 Si el bucle ha terminado.
30bool Loop::HasQuitted() {
31 return screen_->HasQuitted();
32}
33
34/// @brief Ejecuta el bucle una vez. Hace que el `component` procese todas las tareas/eventos
35/// pendientes. Un nuevo fotograma podrĂ­a dibujarse si el anterior fue invalidado.
36/// Devuelve true hasta que el bucle no haya terminado.
37void Loop::RunOnce() {
38 screen_->RunOnce(component_);
39}
40
41/// @brief Espera a que se maneje al menos un evento y ejecuta
42/// `Loop::RunOnce()`.
43void Loop::RunOnceBlocking() {
44 screen_->RunOnceBlocking(component_);
45}
46
47/// Ejecuta el bucle, bloqueando el hilo actual, hasta que el bucle haya
48/// terminado.
49void Loop::Run() {
50 while (!HasQuitted()) {
51 RunOnceBlocking();
52 }
53}
54
55} // namespace ftxui
El espacio de nombres ftxui:: de FTXUI.
Definition animation.hpp:11
std::shared_ptr< ComponentBase > Component
Definition app.hpp:23