FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
menu_in_frame_horizontal.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 <memory> // for shared_ptr, __shared_ptr_access
5#include <string> // for string, basic_string, operator+, to_string
6#include <vector> // for vector
7
8#include "ftxui/component/captured_mouse.hpp" // for ftxui
9#include "ftxui/component/component.hpp" // for Radiobox, Renderer
10#include "ftxui/component/component_base.hpp" // for ComponentBase
11#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
12#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, HEIGHT, LESS_THAN
13
14using namespace ftxui;
15
16int main() {
17 std::vector<std::string> entries;
18 int selected = 0;
19
20 for (int i = 0; i < 100; ++i) {
21 entries.push_back(std::to_string(i));
22 }
23 auto radiobox = Menu(&entries, &selected, MenuOption::Horizontal());
24 auto renderer = Renderer(
25 radiobox, [&] { return radiobox->Render() | hscroll_indicator | frame; });
26
27 auto screen = ScreenInteractive::FitComponent();
28 screen.Loop(renderer);
29
30 return 0;
31}
auto radiobox
Definition gallery.cpp:73
static ScreenInteractive FitComponent()
static MenuOption Horizontal()
水平選單的標準選項。 這對於實現一個標籤頁列很有用。
Component Menu(MenuOption options)
文字列表。選定的元素會被聚焦。
Component Renderer(Component child, std::function< Element()>)
回傳一個新的元件,類似於 |child|,但使用 |render| 作為 Component::Render() 事件。
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
Element frame(Element)
允許元素顯示在「虛擬」區域內。其大小可以大於其容器。在這種情況下,只會顯示較小的一部分。視圖可滾動以使聚焦元素可見。
Definition frame.cpp:116