FTXUI  0.11.1
C++ functional terminal UI.
bold.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, bold
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 
10 namespace ftxui {
11 
12 class Bold : public NodeDecorator {
13  public:
15 
16  void Render(Screen& screen) override {
17  for (int y = box_.y_min; y <= box_.y_max; ++y) {
18  for (int x = box_.x_min; x <= box_.x_max; ++x) {
19  screen.PixelAt(x, y).bold = true;
20  }
21  }
22  Node::Render(screen);
23  }
24 };
25 
26 /// @brief Use a bold font, for elements with more emphasis.
27 /// @ingroup dom
29  return std::make_shared<Bold>(std::move(child));
30 }
31 
32 } // namespace ftxui
33 
34 // Copyright 2020 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.
NodeDecorator(Element child)
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Definition: node.cpp:27
Box box_
Definition: node.hpp:50
std::shared_ptr< Node > Element
Definition: elements.hpp:16
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition: bold.cpp:28
void Render(Screen &screen, const Element &node)
Display an element on a ftxui::Screen.
Definition: node.cpp:40
int x_max
Definition: box.hpp:8
int y_min
Definition: box.hpp:9
int y_max
Definition: box.hpp:10
int x_min
Definition: box.hpp:7