24 explicit Impl(std::function<
bool()> show) : show_(std::move(show)) {}
28 return show_() ? ComponentBase::OnRender() : std::make_unique<Node>();
30 bool Focusable()
const override {
31 return show_() && ComponentBase::Focusable();
33 bool OnEvent(
Event event)
override {
34 return show_() && ComponentBase::OnEvent(event);
37 std::function<bool()> show_;
41 maybe->Add(std::move(child));
58 return [show = std::move(show)](
Component child)
mutable {
59 return Maybe(std::move(child), std::move(show));
75 return Maybe(std::move(child), [show] {
return *show; });
89 return [show](
Component child) {
return Maybe(std::move(child), show); };
它将自身实现为 ftxui::Element。它通过响应 ftxui::Event 来实现键盘导航。
Component Maybe(Component, const bool *show)
装饰一个组件 |child|。它仅在 |show| 为 true 时显示。
代表一个事件。它可以是按键事件、终端大小调整等等...
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
std::function< Component(Component)> ComponentDecorator
std::shared_ptr< ComponentBase > Component