16 using namespace ftxui;
18 auto screen = ScreenInteractive::Fullscreen();
22 auto btn_run = Button(
"Execute with restored IO", screen.WithRestoredIO([] {
23 std::cout <<
"This is a child program using stdin/stdout." << std::endl;
24 for (int i = 0; i < 10; ++i) {
25 std::cout <<
"Please enter 10 strings (" << i <<
"/10)" << std::flush;
27 std::getline(std::cin, input);
31 auto btn_quit = Button(
"Quit", screen.ExitLoopClosure());
33 auto layout = Container::Horizontal({
38 auto renderer = Renderer(layout, [&] {
39 auto explanation = paragraph(
40 "點擊此按鈕後,ScreenInteractive 將會被暫停,並暫時恢復對 stdin/stdout 的訪問,以執行一個函數。");
42 explanation | borderEmpty,
50 element = element | borderEmpty | border | size(WIDTH, LESS_THAN, 80) |
51 size(HEIGHT, LESS_THAN, 20) | center;
55 screen.Loop(renderer);