FTXUI  4.1.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
strikethrough.cpp
Go to the documentation of this file.
1#include <memory> // for make_shared
2#include <utility> // for move
3
4#include "ftxui/dom/elements.hpp" // for Element, strikethrough
5#include "ftxui/dom/node.hpp" // for Node
6#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
7#include "ftxui/screen/box.hpp" // for Box
8#include "ftxui/screen/screen.hpp" // for Pixel, Screen
9
10namespace ftxui {
11
12/// @brief Apply a strikethrough to text.
13/// @ingroup dom
15 class Impl : public NodeDecorator {
16 public:
17 using NodeDecorator::NodeDecorator;
18
19 void Render(Screen& screen) override {
20 for (int y = box_.y_min; y <= box_.y_max; ++y) {
21 for (int x = box_.x_min; x <= box_.x_max; ++x) {
22 screen.PixelAt(x, y).strikethrough = true;
23 }
24 }
25 Node::Render(screen);
26 }
27 };
28
29 return std::make_shared<Impl>(std::move(child));
30}
31
32} // namespace ftxui
33
34// Copyright 2023 Arthur Sonzogni. All rights reserved.
35// Use of this source code is governed by the MIT license that can be found in
36// the LICENSE file.
A rectangular grid of Pixel.
Definition screen.hpp:57
Pixel & PixelAt(int x, int y)
Access a Pixel at a given position.
Definition screen.cpp:470
std::shared_ptr< Node > Element
Definition elements.hpp:20
Element strikethrough(Element)
Apply a strikethrough to text.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition node.cpp:44
bool strikethrough
Definition screen.hpp:34