FTXUI  0.11.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
table.hpp
Go to the documentation of this file.
1#ifndef FTXUI_DOM_TABLE
2#define FTXUI_DOM_TABLE
3
4#include <memory>
5#include <string> // for string
6#include <vector> // for vector
7
8#include "ftxui/dom/elements.hpp" // for BorderStyle, LIGHT, Element, Decorator
9
10namespace ftxui {
11
12// Usage:
13//
14// Initialization:
15// ---------------
16//
17// auto table = Table({
18// {"X", "Y"},
19// {"-1", "1"},
20// {"+0", "0"},
21// {"+1", "1"},
22// });
23//
24// table.SelectAll().Border(LIGHT);
25//
26// table.SelectRow(1).Border(DOUBLE);
27// table.SelectRow(1).SeparatorInternal(Light);
28//
29// std::move(table).Element();
30
31class Table;
32class TableSelection;
33
34class Table {
35 public:
36 Table(std::vector<std::vector<std::string>>);
38 TableSelection SelectCell(int column, int row);
39 TableSelection SelectRow(int row_index);
40 TableSelection SelectRows(int row_min, int row_max);
41 TableSelection SelectColumn(int column_index);
42 TableSelection SelectColumns(int column_min, int column_max);
43 TableSelection SelectRectangle(int column_min,
44 int column_max,
45 int row_min,
46 int row_max);
48
49 private:
50 friend TableSelection;
51 std::vector<std::vector<Element>> elements_;
52 int input_dim_x_;
53 int input_dim_y_;
54 int dim_x_;
55 int dim_y_;
56};
57
59 public:
60 void Decorate(Decorator);
61 void DecorateAlternateRow(Decorator, int modulo = 2, int shift = 0);
62 void DecorateAlternateColumn(Decorator, int modulo = 2, int shift = 0);
63
65 void DecorateCellsAlternateColumn(Decorator, int modulo = 2, int shift = 0);
66 void DecorateCellsAlternateRow(Decorator, int modulo = 2, int shift = 0);
67
73
77
78 private:
79 friend Table;
80 Table* table_;
81 int x_min_;
82 int x_max_;
83 int y_min_;
84 int y_max_;
85};
86
87} // namespace ftxui
88
89#endif /* end of include guard: FTXUI_DOM_TABLE */
90
91// Copyright 2021 Arthur Sonzogni. All rights reserved.
92// Use of this source code is governed by the MIT license that can be found in
93// the LICENSE file.
void DecorateAlternateColumn(Decorator, int modulo=2, int shift=0)
Definition table.cpp:175
void SeparatorVertical(BorderStyle border=LIGHT)
Definition table.cpp:251
void DecorateCells(Decorator)
Definition table.cpp:164
void BorderLeft(BorderStyle border=LIGHT)
Definition table.cpp:271
void DecorateCellsAlternateColumn(Decorator, int modulo=2, int shift=0)
Definition table.cpp:201
void Decorate(Decorator)
Definition table.cpp:155
void DecorateAlternateRow(Decorator, int modulo=2, int shift=0)
Definition table.cpp:188
void BorderTop(BorderStyle border=LIGHT)
Definition table.cpp:281
void Separator(BorderStyle border=LIGHT)
Definition table.cpp:239
void BorderBottom(BorderStyle border=LIGHT)
Definition table.cpp:286
void DecorateCellsAlternateRow(Decorator, int modulo=2, int shift=0)
Definition table.cpp:214
void BorderRight(BorderStyle border=LIGHT)
Definition table.cpp:276
void Border(BorderStyle border=LIGHT)
Definition table.cpp:227
void SeparatorHorizontal(BorderStyle border=LIGHT)
Definition table.cpp:261
Table(std::vector< std::vector< std::string > >)
Definition table.cpp:38
Element Render()
Definition table.cpp:131
TableSelection SelectCell(int column, int row)
Definition table.cpp:97
TableSelection SelectColumn(int column_index)
Definition table.cpp:89
TableSelection SelectRow(int row_index)
Definition table.cpp:81
TableSelection SelectColumns(int column_min, int column_max)
Definition table.cpp:93
TableSelection SelectRows(int row_min, int row_max)
Definition table.cpp:85
TableSelection SelectAll()
Definition table.cpp:121
TableSelection SelectRectangle(int column_min, int column_max, int row_min, int row_max)
Definition table.cpp:101
std::function< Element(Element)> Decorator
Definition elements.hpp:17
std::shared_ptr< Node > Element
Definition elements.hpp:15
Element border(Element)
Draw a border around the element.
Definition border.cpp:150
BorderStyle
Definition elements.hpp:20
@ LIGHT
Definition elements.hpp:20