FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
screen.hpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni. 保留所有权利。
2// 此源代码的使用受 MIT 许可证的约束,该许可证可在
3// LICENSE 文件中找到。
4#ifndef FTXUI_SCREEN_SCREEN_HPP
5#define FTXUI_SCREEN_SCREEN_HPP
6
7#include <cstdint> // for uint8_t
8#include <functional> // for function
9#include <string> // for string, basic_string, allocator
10#include <vector> // for vector
11
12#include "ftxui/screen/image.hpp" // for Pixel, Image
13#include "ftxui/screen/terminal.hpp" // for Dimensions
14
15namespace ftxui {
16
17/// @brief 定义屏幕的尺寸应如何呈现。
18/// @ingroup screen
19namespace Dimension {
22} // namespace Dimension
23
24/// @brief 像素的矩形网格。
25/// @ingroup screen
26class Screen : public Image {
27 public:
28 // 构造函数:
29 Screen(int dimx, int dimy);
30 static Screen Create(Dimensions dimension);
31 static Screen Create(Dimensions width, Dimensions height);
32
33 // 析构函数:
34 ~Screen() override = default;
35
36 std::string ToString() const;
37
38 // 将屏幕打印到终端。
39 void Print() const;
40
41 // 用空格填充屏幕并重置任何屏幕状态,例如超链接和
42 // 光标
43 void Clear();
44
45 // 将终端光标向上移动 n 行,其中 n = dimy()。
46 std::string ResetPosition(bool clear = false) const;
47
48 void ApplyShader();
49
50 struct Cursor {
51 int x = 0;
52 int y = 0;
53
64 };
65
66 Cursor cursor() const { return cursor_; }
68
69 // 在屏幕中存储一个超链接。返回超链接的ID。当用户点击时,
70 // 此ID用于识别超链接。
71 uint8_t RegisterHyperlink(const std::string& link);
72 const std::string& Hyperlink(uint8_t id) const;
73
74 using SelectionStyle = std::function<void(Pixel&)>;
75 const SelectionStyle& GetSelectionStyle() const;
76 void SetSelectionStyle(SelectionStyle decorator);
77
78 protected:
80 std::vector<std::string> hyperlinks_ = {""};
81
82 // 当前选择样式。这将被各种DOM元素覆盖。
84 pixel.inverted ^= true;
85 };
86};
87
88} // namespace ftxui
89
90#endif // FTXUI_SCREEN_SCREEN_HPP
std::function< void(Pixel &)> SelectionStyle
const SelectionStyle & GetSelectionStyle() const
返回当前选择样式。
const std::string & Hyperlink(uint8_t id) const
int dimy() const
std::string ToString() const
void SetCursor(Cursor cursor)
~Screen() override=default
static Screen Create(Dimensions dimension)
创建一个具有给定维度的屏幕。
uint8_t RegisterHyperlink(const std::string &link)
Screen(int dimx, int dimy)
Cursor cursor() const
std::string ResetPosition(bool clear=false) const
返回一个字符串,用于将光标位置重置到屏幕开头。
void Clear()
清除屏幕上的所有像素。
SelectionStyle selection_style_
void SetSelectionStyle(SelectionStyle decorator)
设置当前选择样式。
std::vector< std::string > hyperlinks_
void Print() const
int dimx() const
像素的矩形网格。
像素的矩形网格。
Dimensions 是一个表示终端大小的结构。
一个 Unicode 字符及其相关样式。
FTXUI ftxui::Dimension:: 命名空间
Dimensions Fixed(int)
Dimensions Full()
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase