FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
examples/component/menu.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni. 保留所有权利。
2// 本源代码的使用受 MIT 许可证的约束,该许可证可在 LICENSE 文件中找到。
3#include <functional> // for function
4#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
5#include <string> // for string, basic_string, allocator
6#include <vector> // for vector
7
8#include "ftxui/component/captured_mouse.hpp" // for ftxui
9#include "ftxui/component/component.hpp" // for Menu
10#include "ftxui/component/component_options.hpp" // for MenuOption
11#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
12
13int main() {
14 using namespace ftxui;
15 auto screen = ScreenInteractive::TerminalOutput();
16
17 std::vector<std::string> entries = {
18 "entry 1",
19 "entry 2",
20 "entry 3",
21 };
22 int selected = 0;
23
24 MenuOption option;
25 option.on_enter = screen.ExitLoopClosure();
26 auto menu = Menu(&entries, &selected, option);
27
28 screen.Loop(menu);
29
30 std::cout << "Selected element = " << selected << std::endl;
31}
std::function< void()> on_enter
Menu 组件的选项。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase