FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
examples/component/menu.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <functional> // for function
5#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
6#include <string> // for string, basic_string, allocator
7#include <vector> // for vector
8
9#include "ftxui/component/captured_mouse.hpp" // for ftxui
10#include "ftxui/component/component.hpp" // for Menu
11#include "ftxui/component/component_options.hpp" // for MenuOption
12#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
13
14 int main() {
15 using namespace ftxui;
16 auto screen = ScreenInteractive::TerminalOutput();
17
18 std::vector<std::string> entries = {
19 "entry 1",
20 "entry 2",
21 "entry 3",
22 };
23 int selected = 0;
24
25 MenuOption option;
26 option.on_enter = screen.ExitLoopClosure();
27 auto menu = Menu(&entries, &selected, option);
28
29 screen.Loop(menu);
30
31 std::cout << "Selected element = " << selected << std::endl;
32}
captured_mouse.hpp
component.hpp
component_options.hpp
main
int main()
Definition examples/component/menu.cpp:14
ftxui::MenuOption::on_enter
std::function< void()> on_enter
Definition component_options.hpp:107
ftxui::MenuOption
Option for the Menu component.
Definition component_options.hpp:86
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
screen_interactive.hpp