with_restored_io
#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
auto screen = ScreenInteractive::Fullscreen();
auto btn_run = Button("Execute with restored IO", screen.WithRestoredIO([] {
std::cout << "This is a child program using stdin/stdout." << std::endl;
for (int i = 0; i < 10; ++i) {
std::cout << "Please enter 10 strings (" << i << "/10)" << std::flush;
std::string input;
std::getline(std::cin, input);
}
}));
auto btn_quit = Button("Quit", screen.ExitLoopClosure());
auto layout = Container::Horizontal({
btn_run,
btn_quit,
});
"After clicking this button, the ScreenInteractive will be "
"suspended and access to stdin/stdout will temporarilly be "
"restore for running a function.");
btn_run->Render(),
btn_quit->Render(),
}),
});
return element;
});
screen.Loop(renderer);
return EXIT_SUCCESS;
}
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Element center(Element)
Center an element horizontally and vertically.
Element filler()
An element that will take expand proportionally to the space left in a container.
Elements paragraph(std::wstring text)
Element border(Element)
Draw a border around the element.
Element borderEmpty(Element)
Draw an empty border around the element.
Element vbox(Elements)
A container displaying elements vertically one by one.
private:
bool checked[3] = {false, false, false};
float slider = 50;
public:
Impl() {
Add(Container::Vertical({
Checkbox("Check me", &checked[0]),
Checkbox("Check me", &checked[1]),
Checkbox("Check me", &checked[2]),
Slider("Slider", &slider, 0.f, 100.f),
}));
}
};
return Make<Impl>();
}
int window_1_left = 20;
int window_1_top = 10;
int window_1_width = 40;
int window_1_height = 20;
.title = "First window",
.left = &window_1_left,
.top = &window_1_top,
.width = &window_1_width,
.height = &window_1_height,
});
.title = "My window",
.left = 40,
.top = 20,
});
.title = "My window",
.left = 60,
.top = 30,
});
});
auto window_container = Container::Stacked({
window_1,
window_2,
window_3,
window_4,
window_5,
});
return text(
"window_1: " +
std::to_string(window_1_width) + "x" +
std::to_string(window_1_height) + " + " +
std::to_string(window_1_left) + "," +
std::to_string(window_1_top));
});
auto layout = Container::Vertical({
display_win_1,
window_container,
});
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(layout);
return EXIT_SUCCESS;
}
It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ft...
Element text(std::wstring text)
Display a piece of unicode text.
std::shared_ptr< ComponentBase > Component