19 const std::string lorem =
20 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "
21 "do eiusmod tempor incididunt ut labore et dolore magna "
22 "aliqua. Ut enim ad minim veniam, quis nostrud exercitation "
23 "ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis "
24 "aute irure dolor in reprehenderit in voluptate velit esse "
25 "cillum dolore eu fugiat nulla pariatur. Excepteur sint "
26 "occaecat cupidatat non proident, sunt in culpa qui officia "
27 "deserunt mollit anim id est laborum.";
29 text(lorem.substr(0, -1)),
text(lorem.substr(5, -1)),
text(
""),
30 text(lorem.substr(10, -1)),
text(lorem.substr(15, -1)),
text(
""),
31 text(lorem.substr(20, -1)),
text(lorem.substr(25, -1)),
text(
""),
32 text(lorem.substr(30, -1)),
text(lorem.substr(35, -1)),
text(
""),
33 text(lorem.substr(40, -1)),
text(lorem.substr(45, -1)),
text(
""),
34 text(lorem.substr(50, -1)),
text(lorem.substr(55, -1)),
text(
""),
35 text(lorem.substr(60, -1)),
text(lorem.substr(65, -1)),
text(
""),
36 text(lorem.substr(70, -1)),
text(lorem.substr(75, -1)),
text(
""),
37 text(lorem.substr(80, -1)),
text(lorem.substr(85, -1)),
text(
""),
38 text(lorem.substr(90, -1)),
text(lorem.substr(95, -1)),
text(
""),
39 text(lorem.substr(100, -1)),
text(lorem.substr(105, -1)),
text(
""),
40 text(lorem.substr(110, -1)),
text(lorem.substr(115, -1)),
text(
""),
41 text(lorem.substr(120, -1)),
text(lorem.substr(125, -1)),
text(
""),
42 text(lorem.substr(130, -1)),
text(lorem.substr(135, -1)),
text(
""),
43 text(lorem.substr(140, -1)),
47 auto scrollable_content =
Renderer(content, [&, content] {
53 option_x.
value = &scroll_x;
56 option_x.increment = 0.1f;
60 auto scrollbar_x =
Slider(option_x);
63 option_y.
value = &scroll_y;
70 auto scrollbar_y =
Slider(option_y);
72 Add(Container::Vertical({
77 Container::Horizontal({
90 .title =
"First window",
104 auto window_container = Container::Stacked({
110 screen.Loop(window_container);
void Add(Component children)
新增一個子項。 @param child 要附加的子項。
static ScreenInteractive Fullscreen()
它將自己實作為 ftxui::Element 進行渲染。它透過回應 ftxui::Event 來實現鍵盤導航。
Component Horizontal(Components children)
一個元件列表,水平地一個接一個繪製,並使用左/右箭頭鍵或 'h'/'l' 鍵進行水平導航。
Component Renderer(Component child, std::function< Element()>)
回傳一個新的元件,類似於 |child|,但使用 |render| 作為 Component::Render() 事件。
Component Window(WindowOptions option)
一個可拖曳/可調整大小的視窗。要使用多個視窗,它們必須透過 Container::Stacked({...}) 元件堆疊。
Decorator focusPositionRelative(float x, float y)
在 frame 內部使用,這會強制視圖滾動到給定位置。該位置以請求大小的比例表示。
Element flex(Element)
使子元素按比例擴展以佔據容器中剩餘的空間。
Element text(std::wstring text)
顯示一段 Unicode 文字。
Element vbox(Elements)
一個垂直一個接一個顯示元素的容器。
return Make< Impl >(option)
Component Slider(SliderOption< T > options)
std::shared_ptr< ComponentBase > Component