Skip to content

ftxui::Loop ​

cpp
#include <ftxui/component/loop.hpp>

Loop is a class that manages the event loop for a component.

It is responsible for running the component, handling events, and updating the screen.

The Loop class is designed to be used with an App object, which represents the terminal screen.

Example

cpp
#include <ftxui/component/component.hpp>
#include <ftxui/component/app.hpp>
#include <ftxui/component/loop.hpp>

int main() {
 auto screen = ftxui::App::TerminalOutput();
 auto component = ftxui::Button("Click me", [] { ... });

ftxui::Loop loop(screen.get(), component);

// Either
 loop.Run();  // Blocking until the component quits.

// Or
 loop.RunOnce();  // Non-blocking, returns immediately.

// Or
 loop.RunOnceBlocking();  // Blocking until handling one event.

// Or in a loop:
 while (!loop.HasQuitted()) {
   loop.RunOnce();

// Do something else like running a different library loop function.
 }
}

Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/dropdown, component/dropdown_custom (+41 more)

Summary ​

SymbolDescription
Loop
~Loop
HasQuitted
RunOnce
RunOnceBlocking
Run
operator=

Public Member Functions ​

Loop ​

cpp
Loop(App * screen, Component component);

Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/dropdown, component/dropdown_custom (+41 more)

~Loop ​

cpp
~Loop();

HasQuitted ​

cpp
bool HasQuitted();

RunOnce ​

cpp
void RunOnce();

RunOnceBlocking ​

cpp
void RunOnceBlocking();

Run ​

cpp
void Run();

operator= ​

cpp
Loop & operator=(Loop &&);

operator= ​

cpp
Loop & operator=(const Loop &);

Loop ​

cpp
Loop(Loop &&);

Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/dropdown, component/dropdown_custom (+41 more)

Loop ​

cpp
Loop(const Loop &);

Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/dropdown, component/dropdown_custom (+41 more)