FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
selection.hpp
Go to the documentation of this file.
1// Copyright 2024 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權條款約束,詳情請參閱
3// LICENSE 檔案。
4
5#ifndef FTXUI_DOM_SELECTION_HPP
6#define FTXUI_DOM_SELECTION_HPP
7
8#include <functional>
9
10#include <sstream>
11#include "ftxui/screen/box.hpp" // for Box
12#include "ftxui/screen/pixel.hpp" // for Pixel
13
14namespace ftxui {
15
16/// @brief 表示終端機使用者介面中的選取範圍。
17///
18/// Selection 是一個類別,表示終端機使用者介面中選取範圍的兩個端點。
19///
20/// @ingroup dom
21class Selection {
22 public:
23 Selection(); // 空選取範圍。
24 Selection(int start_x, int start_y, int end_x, int end_y);
25
26 const Box& GetBox() const;
27
30 bool IsEmpty() const { return empty_; }
31
32 void AddPart(const std::string& part, int y, int left, int right);
33 std::string GetParts() { return parts_.str(); }
34
35 private:
36 Selection(int start_x, int start_y, int end_x, int end_y, Selection* parent);
37
38 const int start_x_ = 0;
39 const int start_y_ = 0;
40 const int end_x_ = 0;
41 const int end_y_ = 0;
42 const Box box_ = {};
43 Selection* const parent_ = this;
44 const bool empty_ = true;
45 std::stringstream parts_;
46
47 // 最後插入部分的座標。
48 int x_ = 0;
49 int y_ = 0;
50};
51
52} // namespace ftxui
53
54#endif /* end of include guard: FTXUI_DOM_SELECTION_HPP */
const Box & GetBox() const
取得選取範圍的方塊。
std::string GetParts()
Definition selection.hpp:33
bool IsEmpty() const
Definition selection.hpp:30
void AddPart(const std::string &part, int y, int left, int right)
Selection SaturateVertical(Box box)
將選取範圍飽和在方塊內。 這是由 vbox 呼叫,用於將選取範圍傳播到其子元素。
Selection()
建立一個空的選取範圍。
Selection SaturateHorizontal(Box box)
將選取範圍飽和在方塊內。 這是由 hbox 呼叫,用於將選取範圍傳播到其子元素。
表示終端機使用者介面中的選取範圍。
Definition selection.hpp:21
Box 是一個表示二維空間中矩形區域的結構。
Definition box.hpp:14
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
std::uint8_t left
Definition screen.cpp:130
std::uint8_t right
Definition screen.cpp:132