FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
resizable_split_clamp.cpp
Go to the documentation of this file.
1// Copyright 2025 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSEファイルにあるMITライセンスに準拠しています。
3#include <memory> // for shared_ptr, allocator, __shared_ptr_access
4
5#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
6#include "ftxui/component/component_base.hpp" // for ComponentBase
7#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
8#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
9
10using namespace ftxui;
11
12int main() {
13 auto screen = ScreenInteractive::Fullscreen();
14
15 // State:
16 int size = 40;
17 int size_min = 10;
18 int size_max = 80;
19
20 // Renderers:
21 auto split = ResizableSplit({
22 .main = Renderer([] { return text("Left") | center; }),
23 .back = Renderer([] { return text("Right") | center; }),
24 .direction = Direction::Left,
25 .main_size = &size,
26 .min = &size_min,
27 .max = &size_max,
28 });
29
30 auto renderer = Renderer(split, [&] {
31 return window(text("セパレータをマウスでドラッグしてください"),
32 vbox({
33 text("最小: " + std::to_string(size_min)),
34 text("最大: " + std::to_string(size_max)),
35 text("サイズ: " + std::to_string(size)),
36 separator(),
37 split->Render() | flex,
38 }));
39 });
40
41 screen.Loop(renderer);
42}
static ScreenInteractive Fullscreen()
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
virtual void Render(Screen &screen)
要素をftxui::Screenに表示します。
Definition node.cpp:59
Element flex(Element)
子要素をコンテナに残されたスペースに比例して拡大させます。
Definition flex.cpp:120
Element center(Element)
要素を水平方向および垂直方向に中央揃えします。
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
Element vbox(Elements)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:94
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Component ResizableSplit(ResizableSplitOption options)
2つのコンポーネント間の分割。
Element window(Element title, Element content, BorderStyle border=ROUNDED)
Element separator()