FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
selection.hpp
浏览该文件的文档.
1// Copyright 2024 Arthur Sonzogni. All rights reserved.
2// 本源代码的使用受 MIT 许可证的约束,该许可证可在 LICENSE 文件中找到。
3
4#ifndef FTXUI_DOM_SELECTION_HPP
5#define FTXUI_DOM_SELECTION_HPP
6
7#include <functional>
8
9#include <sstream>
10#include "ftxui/screen/box.hpp" // for Box
11#include "ftxui/screen/pixel.hpp" // for Pixel
12
13namespace ftxui {
14
15/// @brief 代表终端用户界面中的选择。
16///
17/// Selection 是一个类,代表终端用户界面中选择的两个端点。
18///
19/// @ingroup dom
20class Selection {
21 public:
22 Selection(); // 空选择。
23 Selection(int start_x, int start_y, int end_x, int end_y);
24
25 const Box& GetBox() const;
26
29 bool IsEmpty() const { return empty_; }
30
31 void AddPart(const std::string& part, int y, int left, int right);
32 std::string GetParts() { return parts_.str(); }
33
34 private:
35 Selection(int start_x, int start_y, int end_x, int end_y, Selection* parent);
36
37 const int start_x_ = 0;
38 const int start_y_ = 0;
39 const int end_x_ = 0;
40 const int end_y_ = 0;
41 const Box box_ = {};
42 Selection* const parent_ = this;
43 const bool empty_ = true;
44 std::stringstream parts_;
45
46 // 最后插入部分的position。
47 int x_ = 0;
48 int y_ = 0;
49};
50
51} // namespace ftxui
52
53#endif /* end of include guard: FTXUI_DOM_SELECTION_HPP */
const Box & GetBox() const
获取选择框。
std::string GetParts()
void AddPart(const std::string &part, int y, int left, int right)
Selection SaturateVertical(Box box)
将选择饱和到框内。 这由 vbox 调用,以将选择传播到其子级。
Selection()
创建一个空选择。
Selection SaturateHorizontal(Box box)
将选择饱和到框内。 这由 hbox 调用,以将选择传播到其子级。
代表终端用户界面中的选择。
Box是一个表示2D空间中矩形区域的结构体。
定义 box.hpp:15
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::uint8_t left
std::uint8_t right