#include <stdlib.h>
#include <chrono>
#include <memory>
#include <string>
#include <thread>
auto screen = ScreenInteractive::FitComponent();
int custom_loop_count = 0;
int frame_count = 0;
int event_count = 0;
frame_count++;
return vbox({
text("這演示了使用自定義 ftxui::Loop。它 "),
text("以每秒 100 次迭代的速度運行。FTXUI 事件 "),
text("每次迭代處理一次,並根據需要渲染新幀 "),
text("根據需要渲染"),
separator(),
text("ftxui event count: " + std::to_string(event_count)),
text("ftxui frame count: " + std::to_string(frame_count)),
text("Custom loop count: " + std::to_string(custom_loop_count)),
}) |
border;
});
event_count++;
return false;
});
while (!loop.HasQuitted()) {
custom_loop_count++;
loop.RunOnce();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
return EXIT_SUCCESS;
}
代表一個事件。它可以是按鍵事件、終端機大小調整,或更多...