FTXUI  4.1.1
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 Element, BorderStyle, LIGHT, 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();
37 Table(std::vector<std::vector<std::string>>);
38 Table(std::vector<std::vector<Element>>);
40 TableSelection SelectCell(int column, int row);
41 TableSelection SelectRow(int row_index);
42 TableSelection SelectRows(int row_min, int row_max);
43 TableSelection SelectColumn(int column_index);
44 TableSelection SelectColumns(int column_min, int column_max);
45 TableSelection SelectRectangle(int column_min,
46 int column_max,
47 int row_min,
48 int row_max);
50
51 private:
52 void Initialize(std::vector<std::vector<Element>>);
53 friend TableSelection;
54 std::vector<std::vector<Element>> elements_;
55 int input_dim_x_ = 0;
56 int input_dim_y_ = 0;
57 int dim_x_ = 0;
58 int dim_y_ = 0;
59};
60
62 public:
63 void Decorate(Decorator);
64 void DecorateAlternateRow(Decorator, int modulo = 2, int shift = 0);
65 void DecorateAlternateColumn(Decorator, int modulo = 2, int shift = 0);
66
68 void DecorateCellsAlternateColumn(Decorator, int modulo = 2, int shift = 0);
69 void DecorateCellsAlternateRow(Decorator, int modulo = 2, int shift = 0);
70
76
80
81 private:
82 friend Table;
83 Table* table_;
84 int x_min_;
85 int x_max_;
86 int y_min_;
87 int y_max_;
88};
89
90} // namespace ftxui
91
92#endif /* end of include guard: FTXUI_DOM_TABLE */
93
94// Copyright 2021 Arthur Sonzogni. All rights reserved.
95// Use of this source code is governed by the MIT license that can be found in
96// the LICENSE file.
void DecorateAlternateColumn(Decorator, int modulo=2, int shift=0)
Definition table.cpp:206
void SeparatorVertical(BorderStyle border=LIGHT)
Definition table.cpp:290
void DecorateCells(Decorator)
Definition table.cpp:194
void BorderLeft(BorderStyle border=LIGHT)
Definition table.cpp:312
void DecorateCellsAlternateColumn(Decorator, int modulo=2, int shift=0)
Definition table.cpp:234
void Decorate(Decorator)
Definition table.cpp:184
void DecorateAlternateRow(Decorator, int modulo=2, int shift=0)
Definition table.cpp:220
void BorderTop(BorderStyle border=LIGHT)
Definition table.cpp:326
void Separator(BorderStyle border=LIGHT)
Definition table.cpp:277
void BorderBottom(BorderStyle border=LIGHT)
Definition table.cpp:333
void DecorateCellsAlternateRow(Decorator, int modulo=2, int shift=0)
Definition table.cpp:248
void BorderRight(BorderStyle border=LIGHT)
Definition table.cpp:319
void Border(BorderStyle border=LIGHT)
Definition table.cpp:261
void SeparatorHorizontal(BorderStyle border=LIGHT)
Definition table.cpp:301
Element Render()
Definition table.cpp:157
TableSelection SelectCell(int column, int row)
Definition table.cpp:123
TableSelection SelectColumn(int column_index)
Definition table.cpp:115
TableSelection SelectRow(int row_index)
Definition table.cpp:107
TableSelection SelectColumns(int column_min, int column_max)
Definition table.cpp:119
TableSelection SelectRows(int row_min, int row_max)
Definition table.cpp:111
TableSelection SelectAll()
Definition table.cpp:147
TableSelection SelectRectangle(int column_min, int column_max, int row_min, int row_max)
Definition table.cpp:127
std::function< Element(Element)> Decorator
Definition elements.hpp:21
std::shared_ptr< Node > Element
Definition elements.hpp:19
Element border(Element)
Draw a border around the element.
Definition border.cpp:222
BorderStyle
Definition elements.hpp:24
@ LIGHT
Definition elements.hpp:25