FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
Loop Class Reference

Loop 是一個用於管理元件事件循環的類別。 More...

#include <loop.hpp>

Public Member Functions

 Loop (ScreenInteractive *screen, Component component)
 迴圈是 Component 和 ScreenInteractive 的包裝器。 它用於在終端機中執行元件。
 
 ~Loop ()
 
bool HasQuitted ()
 迴圈是否已退出。
 
void RunOnce ()
 執行迴圈。讓 component 處理所有待處理的任務/事件。 如果前一個影格失效,可能會繪製一個新影格。 在迴圈完成之前返回 true。
 
void RunOnceBlocking ()
 等待至少一個事件被處理並執行 Loop::RunOnce()
 
void Run ()
 執行迴圈,阻塞當前執行緒,直到迴圈退出。
 
 Loop (const Loop &)=default
 
 Loop (Loop &&)=delete
 
Loopoperator= (Loop &&)=delete
 
 Loop (const ScreenInteractive &)=delete
 
Loopoperator= (const Loop &)=delete
 

Detailed Description

Loop 是一個用於管理元件事件循環的類別。

它負責執行元件、處理事件,並 更新畫面。

Loop 類別旨在與 ScreenInteractive 物件一起使用, 該物件代表終端機畫面。

範例

int main() {
auto component = ftxui::Button("Click me", [] { ... });
ftxui::Loop loop(screen.get(), component);
// 方法一
loop.Run(); // 阻塞直到元件退出。
// 方法二
loop.RunOnce(); // 非阻塞,立即返回。
// 方法三
loop.RunOnceBlocking(); // 阻塞直到處理一個事件。
// 方法四:在循環中:
while (!loop.HasQuitted()) {
loop.RunOnce();
// 執行其他操作,例如運行不同的函式庫循環函式。
}
}
Loop 是一個用於管理元件事件循環的類別。
Definition loop.hpp:56
auto component
Definition gallery.cpp:127
static ScreenInteractive TerminalOutput()
Component Button(ButtonOption options)
繪製一個按鈕。點擊時執行一個函數。
Examples
examples/component/custom_loop.cpp, and examples/component/homescreen.cpp.

Definition at line 56 of file loop.hpp.

Constructor & Destructor Documentation

◆ Loop() [1/4]

Loop ( ScreenInteractive * screen,
Component component )

迴圈是 Component 和 ScreenInteractive 的包裝器。 它用於在終端機中執行元件。

See also
Component, ScreenInteractive.
ScreenInteractive::Loop().
ScreenInteractive::ExitLoop().
Parameters
[in]screen要使用的螢幕。
[in]component要執行的元件。

Definition at line 20 of file loop.cpp.

◆ ~Loop()

~Loop ( )

Definition at line 25 of file loop.cpp.

◆ Loop() [2/4]

Loop ( const Loop & )
default

◆ Loop() [3/4]

Loop ( Loop && )
delete

◆ Loop() [4/4]

Loop ( const ScreenInteractive & )
delete

Member Function Documentation

◆ HasQuitted()

bool HasQuitted ( )

迴圈是否已退出。

Definition at line 30 of file loop.cpp.

◆ RunOnce()

void RunOnce ( )

執行迴圈。讓 component 處理所有待處理的任務/事件。 如果前一個影格失效,可能會繪製一個新影格。 在迴圈完成之前返回 true。

Definition at line 37 of file loop.cpp.

◆ RunOnceBlocking()

void RunOnceBlocking ( )

等待至少一個事件被處理並執行 Loop::RunOnce()

Definition at line 43 of file loop.cpp.

◆ Run()

void Run ( )

執行迴圈,阻塞當前執行緒,直到迴圈退出。

Definition at line 48 of file loop.cpp.

◆ operator=() [1/2]

Loop & operator= ( Loop && )
delete

◆ operator=() [2/2]

Loop & operator= ( const Loop & )
delete

The documentation for this class was generated from the following files: