FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
examples/component/dropdown.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni。保留所有权利。
2// 本源代码的使用受 MIT 许可的约束,该许可可在 LICENSE 文件中找到。
3#include <string> // for basic_string, string, allocator
4#include <vector> // for vector
5
6#include "ftxui/component/captured_mouse.hpp" // for ftxui
7#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
8#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
9
10int main() {
11 using namespace ftxui;
12
13 std::vector<std::string> entries = {
14 "tribute", "clearance", "ally", "bend", "electronics",
15 "module", "era", "cultural", "sniff", "nationalism",
16 "negotiation", "deliver", "figure", "east", "tribute",
17 "clearance", "ally", "bend", "electronics", "module",
18 "era", "cultural", "sniff", "nationalism", "negotiation",
19 "deliver", "figure", "east", "tribute", "clearance",
20 "ally", "bend", "electronics", "module", "era",
21 "cultural", "sniff", "nationalism", "negotiation", "deliver",
22 "figure", "east",
23 };
24
25 int selected_1 = 0;
26 int selected_2 = 0;
27 int selected_3 = 0;
28 int selected_4 = 0;
29
30 auto layout = Container::Vertical({
31 Container::Horizontal({
32 Dropdown(&entries, &selected_1),
33 Dropdown(&entries, &selected_2),
34 }),
35 Container::Horizontal({
36 Dropdown(&entries, &selected_3),
37 Dropdown(&entries, &selected_4),
38 }),
39 });
40
41 auto screen = ScreenInteractive::FitComponent();
42 screen.Loop(layout);
43}
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase