FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
screen.hpp
Aller à la documentation de ce fichier.
1// Copyright 2020 Arthur Sonzogni. Tous droits réservés.
2// L'utilisation de ce code source est régie par la licence MIT qui peut être trouvée dans
3// le fichier 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 Définit l'apparence des dimensions de l'écran.
18/// @ingroup screen
19namespace Dimension {
22} // namespace Dimension
23
24/// @brief Une grille rectangulaire de pixels.
25/// @ingroup screen
26class Screen : public Image {
27 public:
28 // Constructors:
29 Screen(int dimx, int dimy);
30 static Screen Create(Dimensions dimension);
31 static Screen Create(Dimensions width, Dimensions height);
32
33 // Destructor:
34 ~Screen() override = default;
35
36 std::string ToString() const;
37
38 // Affiche l'écran sur le terminal.
39 void Print() const;
40
41 // Remplit l'écran avec des espaces et réinitialise tout état de l'écran, comme les hyperliens, et
42 // le curseur.
43 void Clear();
44
45 // Déplace le curseur du terminal de n lignes vers le haut, où n = dimy().
46 std::string ResetPosition(bool clear = false) const;
47
49
50 struct Cursor {
51 int x = 0;
52 int y = 0;
53
64 };
65
66 Cursor cursor() const { return cursor_; }
68
69 // Stocke un hyperlien dans l'écran. Retourne l'identifiant de l'hyperlien. L'identifiant est
70 // utilisé pour identifier l'hyperlien lorsque l'utilisateur clique dessus.
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&)>;
77
78 protected:
80 std::vector<std::string> hyperlinks_ = {""};
81
82 // Le style de sélection actuel. Ceci est remplacé par divers éléments DOM.
84 pixel.inverted ^= true;
85 };
86};
87
88} // namespace ftxui
89
90#endif // FTXUI_SCREEN_SCREEN_HPP
std::function< void(Pixel &)> SelectionStyle
Definition screen.hpp:74
void ApplyShader()
const std::string & Hyperlink(uint8_t id) const
int dimy() const
Definition image.hpp:36
std::string ToString() const
void SetCursor(Cursor cursor)
Definition screen.hpp:67
~Screen() override=default
Screen(int dimx, int dimy)
uint8_t RegisterHyperlink(const std::string &link)
Cursor cursor() const
Definition screen.hpp:66
std::string ResetPosition(bool clear=false) const
static Screen Create(Dimensions width, Dimensions height)
Cursor cursor_
Definition screen.hpp:79
const SelectionStyle & GetSelectionStyle() const
SelectionStyle selection_style_
Definition screen.hpp:83
void SetSelectionStyle(SelectionStyle decorator)
std::vector< std::string > hyperlinks_
Definition screen.hpp:80
static Screen Create(Dimensions dimension)
void Print() const
int dimx() const
Definition image.hpp:35
Une grille rectangulaire de pixels.
Definition image.hpp:17
Une grille rectangulaire de pixels.
Definition screen.hpp:26
Dimensions est une structure qui représente la taille du terminal.
Definition terminal.hpp:11
Un caractère Unicode et son style associé.
Definition pixel.hpp:15
L'espace de noms FTXUI ftxui::Dimension::
Dimensions Fixed(int)
Dimensions Full()
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10