FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
menu_in_frame_horizontal.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni。保留所有权利。
2// 此源代码的使用受 MIT 许可证的约束,该许可证可在 LICENSE 文件中找到。
3#include <memory> // for shared_ptr, __shared_ptr_access
4#include <string> // for string, basic_string, operator+, to_string
5#include <vector> // for vector
6
7#include "ftxui/component/captured_mouse.hpp" // for ftxui
8#include "ftxui/component/component.hpp" // for Radiobox, Renderer
9#include "ftxui/component/component_base.hpp" // for ComponentBase
10#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
11#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, HEIGHT, LESS_THAN
12
13using namespace ftxui;
14
15int main() {
16 std::vector<std::string> entries;
17 int selected = 0;
18
19 for (int i = 0; i < 100; ++i) {
20 entries.push_back(std::to_string(i));
21 }
22 auto radiobox = Menu(&entries, &selected, MenuOption::Horizontal());
23 auto renderer = Renderer(
24 radiobox, [&] { return radiobox->Render() | hscroll_indicator | frame; });
25
26 auto screen = ScreenInteractive::FitComponent();
27 screen.Loop(renderer);
28
29 return 0;
30}
static ScreenInteractive FitComponent()
创建一个 ScreenInteractive,其宽度和高度与正在绘制的组件匹配。
static MenuOption Horizontal()
水平菜单的标准选项。 这对于实现选项卡栏非常有用。
Component Menu(MenuOption options)
文本列表。選定的元素是焦點。
Component Renderer(Component child, std::function< Element()>)
返回一个新组件,类似于 |child|,但使用 |render| 作为 Component::Render() 事件。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
Element frame(Element)
允许元素显示在“虚拟”区域内。其大小可以 大于其容器。在这种情况下,只显示较小的部分。 视图是可滚动的,以使获得焦点的元素可见。