FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
clear_under.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni。保留所有权利。
2// 此源代码的使用受 MIT 许可证管理,该许可证可在
3// LICENSE 文件中找到。
4#include <memory> // for make_shared
5#include <utility> // for move
6
7#include "ftxui/dom/elements.hpp" // for Element, clear_under
8#include "ftxui/dom/node.hpp" // for Node
9#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
10#include "ftxui/screen/box.hpp" // for Box
11#include "ftxui/screen/screen.hpp" // for Pixel, Screen
12
13namespace ftxui {
14
15namespace {
16using ftxui::Screen;
17
18class ClearUnder : public NodeDecorator {
19 public:
21
22 void Render(Screen& screen) override {
23 for (int y = box_.y_min; y <= box_.y_max; ++y) {
24 for (int x = box_.x_min; x <= box_.x_max; ++x) {
25 screen.PixelAt(x, y) = Pixel();
26 screen.PixelAt(x, y).character = " "; // 考虑像素已写入。
27 }
28 }
29 Node::Render(screen);
30 }
31};
32} // namespace
33
34/// @brief 在绘制 |child| 之前,清除下方的像素。这与 dbox 结合使用很有用。
35/// @see ftxui::dbox
36/// @ingroup dom
38 return std::make_shared<ClearUnder>(std::move(element));
39}
40
41} // namespace ftxui
friend void Render(Screen &screen, Node *node, Selection &selection)
Element clear_under(Element element)
在绘制 |child| 之前,清除下方的像素。这与 dbox 结合使用很有用。
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上显示元素。
像素的矩形网格。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::shared_ptr< Node > Element