FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
table.hpp
Aller à la documentation de ce fichier.
1// Copyright 2021 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_DOM_TABLE
5#define FTXUI_DOM_TABLE
6
7#include <string> // for string
8#include <vector> // for vector
9
10#include "ftxui/dom/elements.hpp" // for Element, BorderStyle, LIGHT, Decorator
11
12namespace ftxui {
13
14class Table;
15class TableSelection;
16
17/// @brief Table est un utilitaire pour dessiner des tableaux.
18///
19/// **exemple**
20/// ```cpp
21/// auto table = Table({
22/// {"X", "Y"},
23/// {"-1", "1"},
24/// {"+0", "0"},
25/// {"+1", "1"},
26/// });
27///
28/// table.SelectAll().Border(LIGHT);
29/// table.SelectRow(1).Border(DOUBLE);
30/// table.SelectRow(1).SeparatorInternal(LIGHT);
31///
32/// std::move(table).Render();
33/// ```
34///
35/// @ingroup dom
36class Table {
37 public:
38 Table();
39 explicit Table(std::vector<std::vector<std::string>>);
40 explicit Table(std::vector<std::vector<Element>>);
41 Table(std::initializer_list<std::vector<std::string>> init);
43 TableSelection SelectCell(int column, int row);
44 TableSelection SelectRow(int row_index);
45 TableSelection SelectRows(int row_min, int row_max);
46 TableSelection SelectColumn(int column_index);
47 TableSelection SelectColumns(int column_min, int column_max);
48 TableSelection SelectRectangle(int column_min,
49 int column_max,
50 int row_min,
51 int row_max);
53
54 private:
55 void Initialize(std::vector<std::vector<Element>>);
56 friend TableSelection;
57 std::vector<std::vector<Element>> elements_;
58 int input_dim_x_ = 0;
59 int input_dim_y_ = 0;
60 int dim_x_ = 0;
61 int dim_y_ = 0;
62};
63
65 public:
66 void Decorate(Decorator);
67 void DecorateAlternateRow(Decorator, int modulo = 2, int shift = 0);
68 void DecorateAlternateColumn(Decorator, int modulo = 2, int shift = 0);
69
71 void DecorateCellsAlternateColumn(Decorator, int modulo = 2, int shift = 0);
72 void DecorateCellsAlternateRow(Decorator, int modulo = 2, int shift = 0);
73
74 void Border(BorderStyle border = LIGHT);
75 void BorderLeft(BorderStyle border = LIGHT);
76 void BorderRight(BorderStyle border = LIGHT);
77 void BorderTop(BorderStyle border = LIGHT);
78 void BorderBottom(BorderStyle border = LIGHT);
79
80 void Separator(BorderStyle border = LIGHT);
81 void SeparatorVertical(BorderStyle border = LIGHT);
83
84 private:
85 friend Table;
86 Table* table_;
87 int x_min_;
88 int x_max_;
89 int y_min_;
90 int y_max_;
91};
92
93} // namespace ftxui
94
95#endif /* end of include guard: FTXUI_DOM_TABLE */
void DecorateAlternateColumn(Decorator, int modulo=2, int shift=0)
Applique le décorateur à la sélection. Ceci décore uniquement les lignes modulo modulo avec un décala...
void SeparatorVertical(BorderStyle border=LIGHT)
Dessine des lignes de séparation verticales dans la sélection.
void DecorateCells(Decorator)
Applique le décorateur à la sélection.
void BorderLeft(BorderStyle border=LIGHT)
Dessine des lignes de séparation sur le côté gauche de la sélection.
void DecorateCellsAlternateColumn(Decorator, int modulo=2, int shift=0)
void Decorate(Decorator)
Applique le décorateur à la sélection. Ceci décore à la fois les cellules, les lignes et les coins.
void DecorateAlternateRow(Decorator, int modulo=2, int shift=0)
Applique le décorateur à la sélection. Ceci décore uniquement les lignes modulo modulo avec un décala...
void BorderTop(BorderStyle border=LIGHT)
Dessine des lignes de séparation sur le côté supérieur de la sélection.
void Separator(BorderStyle border=LIGHT)
Dessine des lignes de séparation dans la sélection.
void BorderBottom(BorderStyle border=LIGHT)
Dessine des lignes de séparation sur le côté inférieur de la sélection.
void DecorateCellsAlternateRow(Decorator, int modulo=2, int shift=0)
Applique le décorateur à la sélection. Ceci décore uniquement les coins modulo modulo avec un décalag...
void BorderRight(BorderStyle border=LIGHT)
Dessine des lignes de séparation sur le côté droit de la sélection.
void Border(BorderStyle border=LIGHT)
Applique une bordure autour de la sélection.
void SeparatorHorizontal(BorderStyle border=LIGHT)
Dessine des lignes de séparation horizontales dans la sélection.
Element Render()
Rend la table.
Table()
Crée une table vide.
TableSelection SelectCell(int column, int row)
Sélectionne une cellule de la table.
TableSelection SelectColumn(int column_index)
Sélectionne une colonne de la table.
TableSelection SelectRow(int row_index)
Sélectionne une ligne de la table.
TableSelection SelectColumns(int column_min, int column_max)
Sélectionne une plage de colonnes de la table.
TableSelection SelectRows(int row_min, int row_max)
Sélectionne une plage de lignes de la table.
TableSelection SelectAll()
Sélectionne toute la table.
TableSelection SelectRectangle(int column_min, int column_max, int row_min, int row_max)
Sélectionne un rectangle de la table.
Table est un utilitaire pour dessiner des tableaux.
Definition table.hpp:36
BorderStyle
BorderStyle est une énumération qui représente les différents styles de bordures pouvant être appliqu...
Definition elements.hpp:35
@ LIGHT
Definition elements.hpp:36
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10
std::function< Element(Element)> Decorator
Definition elements.hpp:24
std::shared_ptr< Node > Element
Definition elements.hpp:22