FTXUI  0.8.1
C++ functional terminal UI.
examples/component/menu_style.cpp
#include <functional> // for function
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
#include <string> // for string, basic_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Menu, Horizontal, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, color, separator, Decorator, bgcolor, flex, Element, bold, hbox, border, dim
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::BlueLight, Color::Red, Color::Yellow
int main(int argc, const char* argv[]) {
using namespace ftxui;
std::vector<std::string> entries = {
"Monkey", "Dog", "Cat", "Bird", "Elephant",
};
int menu_1_selected_ = 0;
int menu_2_selected_ = 0;
int menu_3_selected_ = 0;
int menu_4_selected_ = 0;
int menu_5_selected_ = 0;
int menu_6_selected_ = 0;
MenuOption option_1;
option_1.on_enter = screen.ExitLoopClosure();
auto menu_1_ = Menu(&entries, &menu_1_selected_, &option_1);
MenuOption option_2;
option_2.on_enter = screen.ExitLoopClosure();
auto menu_2_ = Menu(&entries, &menu_2_selected_, &option_2);
MenuOption option_3;
option_3.on_enter = screen.ExitLoopClosure();
auto menu_3_ = Menu(&entries, &menu_3_selected_, &option_3);
MenuOption option_4;
option_4.on_enter = screen.ExitLoopClosure();
auto menu_4_ = Menu(&entries, &menu_4_selected_, &option_4);
MenuOption option_5;
option_5.on_enter = screen.ExitLoopClosure();
auto menu_5_ = Menu(&entries, &menu_5_selected_, &option_5);
MenuOption option_6;
option_6.on_enter = screen.ExitLoopClosure();
auto menu_6_ = Menu(&entries, &menu_6_selected_, &option_6);
auto container = Container::Horizontal({
menu_1_,
menu_2_,
menu_3_,
menu_4_,
menu_5_,
menu_6_,
});
// clang-format off
auto renderer = Renderer(container, [&] {
return
hbox({
menu_1_->Render() | flex, separator(),
menu_2_->Render() | flex, separator(),
menu_3_->Render() | flex, separator(),
menu_4_->Render() | flex, separator(),
menu_5_->Render() | flex, separator(),
menu_6_->Render() | flex,
}) | border;
});
// clang-format on
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
ftxui::border
Element border(Element)
Draw a border around the element.
Definition: border.cpp:138
ftxui::Container::Horizontal
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Definition: container.cpp:239
screen_interactive.hpp
ftxui::Color::Red
@ Red
Definition: color.hpp:41
ftxui
Definition: captured_mouse.hpp:6
ftxui::MenuOption::style_normal
Decorator style_normal
style.
Definition: component_options.hpp:12
ftxui::color
Decorator color(Color)
Decorate using a foreground color.
Definition: color.cpp:86
ftxui::bold
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition: bold.cpp:28
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition: hbox.cpp:75
ftxui::flex
Element flex(Element)
Make a child element to expand proportionnally to the space left in a container.
Definition: flex.cpp:119
ftxui::Color::Yellow
@ Yellow
Definition: color.hpp:43
ftxui::Renderer
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition: renderer.cpp:59
ftxui::separator
Element separator(void)
Definition: separator.cpp:54
elements.hpp
captured_mouse.hpp
component.hpp
ftxui::Color::Blue
@ Blue
Definition: color.hpp:44
component_base.hpp
ftxui::bgcolor
Decorator bgcolor(Color)
Decorate using a background color.
Definition: color.cpp:100
ftxui::ScreenInteractive::TerminalOutput
static ScreenInteractive TerminalOutput()
Definition: screen_interactive.cpp:255
color.hpp
ftxui::MenuOption::on_enter
std::function< void()> on_enter
Called when the user presses enter.
Definition: component_options.hpp:21
ftxui::dim
Element dim(Element)
Use a light font, for elements with less emphasis.
Definition: dim.cpp:28
ftxui::Color::BlueLight
@ BlueLight
Definition: color.hpp:52
ftxui::Menu
Component Menu(ConstStringListRef entries, int *selected_, Ref< MenuOption >={})
A list of text. The focused element is selected.
Definition: menu.cpp:173
component_options.hpp
ftxui::MenuOption::style_focused
Decorator style_focused
Style when focused.
Definition: component_options.hpp:13
ftxui::MenuOption::style_selected_focused
Decorator style_selected_focused
Style when selected and focused.
Definition: component_options.hpp:15
ftxui::MenuOption::style_selected
Decorator style_selected
Style when selected.
Definition: component_options.hpp:14
ftxui::MenuOption
Option for the Menu component.
Definition: component_options.hpp:11