FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
examples/dom/table.cpp
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
3// dans le fichier LICENSE.
4#include <ftxui/dom/elements.hpp> // for color, Fit, LIGHT, align_right, bold, DOUBLE
5#include <ftxui/dom/table.hpp> // for Table, TableSelection
6#include <ftxui/screen/screen.hpp> // for Screen
7#include <iostream> // for endl, cout, ostream
8#include <string> // for basic_string, allocator, string
9#include <vector> // for vector
10
11#include "ftxui/dom/node.hpp" // for Render
12#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::White, ftxui
13
14int main() {
15 using namespace ftxui;
16
17 auto table = Table({
18 {"Version", "Marketing name", "Release date", "API level", "Runtime"},
19 {"2.3", "Gingerbread", "February 9 2011", "10", "Dalvik 1.4.0"},
20 {"4.0", "Ice Cream Sandwich", "October 19 2011", "15", "Dalvik"},
21 {"4.1", "Jelly Bean", "July 9 2012", "16", "Dalvik"},
22 {"4.2", "Jelly Bean", "November 13 2012", "17", "Dalvik"},
23 {"4.3", "Jelly Bean", "July 24 2013", "18", "Dalvik"},
24 {"4.4", "KitKat", "October 31 2013", "19", "Dalvik and ART"},
25 {"5.0", "Lollipop", "November 3 2014", "21", "ART"},
26 {"5.1", "Lollipop", "March 9 2015", "22", "ART"},
27 {"6.0", "Marshmallow", "October 5 2015", "23", "ART"},
28 {"7.0", "Nougat", "August 22 2016", "24", "ART"},
29 {"7.1", "Nougat", "October 4 2016", "25", "ART"},
30 {"8.0", "Oreo", "August 21 2017", "26", "ART"},
31 {"8.1", "Oreo", "December 5 2017", "27", "ART"},
32 {"9", "Pie", "August 6 2018", "28", "ART"},
33 {"10", "10", "September 3 2019", "29", "ART"},
34 {"11", "11", "September 8 2020", "30", "ART"},
35 });
36
37 table.SelectAll().Border(LIGHT);
38
39 // Ajouter une bordure autour de la première colonne.
40 table.SelectColumn(0).Border(LIGHT);
41
42 // Rendre la première ligne en gras avec une double bordure.
43 table.SelectRow(0).Decorate(bold);
44 table.SelectRow(0).SeparatorVertical(LIGHT);
45 table.SelectRow(0).Border(DOUBLE);
46
47 // Aligner à droite la colonne "Release date".
48 table.SelectColumn(2).DecorateCells(align_right);
49
50 // Sélectionner la ligne de la deuxième à la dernière.
51 auto content = table.SelectRows(1, -1);
52 // Alterner entre 3 couleurs.
53 content.DecorateCellsAlternateRow(color(Color::Blue), 3, 0);
54 content.DecorateCellsAlternateRow(color(Color::Cyan), 3, 1);
55 content.DecorateCellsAlternateRow(color(Color::White), 3, 2);
56
57 auto document = table.Render();
58 auto screen =
59 Screen::Create(Dimension::Fit(document, /*extend_beyond_screen=*/true));
60 Render(screen, document);
61 screen.Print();
62 std::cout << std::endl;
63
64 return 0;
65}
void Border(BorderStyle border=LIGHT)
Applique une bordure autour de la sélection.
auto screen
TableSelection SelectAll()
Sélectionne toute la table.
Table est un utilitaire pour dessiner des tableaux.
Definition table.hpp:36
Element color(const LinearGradient &gradient, Element child)
Définit la couleur de premier plan d'un élément avec un effet de dégradé linéaire.
void Render(Screen &screen, const Element &element)
Affiche un élément sur un ftxui::Screen.
Definition node.cpp:83
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10