FTXUI  5.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
table.hpp
Go to the documentation of this file.
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 <memory>
8#include <string> // for string
9#include <vector> // for vector
10
11#include "ftxui/dom/elements.hpp" // for Element, BorderStyle, LIGHT, Decorator
12
13namespace ftxui {
14
15// Usage:
16//
17// Initialization:
18// ---------------
19//
20// auto table = Table({
21// {"X", "Y"},
22// {"-1", "1"},
23// {"+0", "0"},
24// {"+1", "1"},
25// });
26//
27// table.SelectAll().Border(LIGHT);
28//
29// table.SelectRow(1).Border(DOUBLE);
30// table.SelectRow(1).SeparatorInternal(Light);
31//
32// std::move(table).Element();
33
34class Table;
35class TableSelection;
36
37class Table {
38 public:
39 Table();
40 Table(std::vector<std::vector<std::string>>);
41 Table(std::vector<std::vector<Element>>);
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
79
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)
Apply the decorator to the selection. This decorate only the lines modulo modulo with a shift of shif...
Definition table.cpp:270
void SeparatorVertical(BorderStyle border=LIGHT)
Draw some vertical separator lines in the selection.
Definition table.cpp:381
void DecorateCells(Decorator)
Apply the decorator to the selection.
Definition table.cpp:252
void BorderLeft(BorderStyle border=LIGHT)
Draw some separator lines to the left side of the selection.
Definition table.cpp:409
void DecorateCellsAlternateColumn(Decorator, int modulo=2, int shift=0)
Apply the decorator to the selection. This decorate only the corners modulo modulo with a shift of sh...
Definition table.cpp:310
void Decorate(Decorator)
Apply the decorator to the selection. This decorate both the cells, the lines and the corners.
Definition table.cpp:238
void DecorateAlternateRow(Decorator, int modulo=2, int shift=0)
Apply the decorator to the selection. This decorate only the lines modulo modulo with a shift of shif...
Definition table.cpp:290
void BorderTop(BorderStyle border=LIGHT)
Draw some separator lines to the top side of the selection.
Definition table.cpp:429
void Separator(BorderStyle border=LIGHT)
Draw some separator lines in the selection.
Definition table.cpp:365
void BorderBottom(BorderStyle border=LIGHT)
Draw some separator lines to the bottom side of the selection.
Definition table.cpp:439
void DecorateCellsAlternateRow(Decorator, int modulo=2, int shift=0)
Apply the decorator to the selection. This decorate only the corners modulo modulo with a shift of sh...
Definition table.cpp:330
void BorderRight(BorderStyle border=LIGHT)
Draw some separator lines to the right side of the selection.
Definition table.cpp:419
void Border(BorderStyle border=LIGHT)
Apply a border around the selection.
Definition table.cpp:346
void SeparatorHorizontal(BorderStyle border=LIGHT)
Draw some horizontal separator lines in the selection.
Definition table.cpp:395
Element Render()
Render the table.
Definition table.cpp:207
Table()
Create an empty table.
Definition table.cpp:46
TableSelection SelectCell(int column, int row)
Select a cell of the table.
Definition table.cpp:161
TableSelection SelectColumn(int column_index)
Select a column of the table.
Definition table.cpp:143
TableSelection SelectRow(int row_index)
Select a row of the table.
Definition table.cpp:126
TableSelection SelectColumns(int column_min, int column_max)
Select a range of columns of the table.
Definition table.cpp:152
TableSelection SelectRows(int row_min, int row_max)
Select a range of rows of the table.
Definition table.cpp:135
TableSelection SelectAll()
Select all the table.
Definition table.cpp:194
TableSelection SelectRectangle(int column_min, int column_max, int row_min, int row_max)
Select a rectangle of the table.
Definition table.cpp:172
std::function< Element(Element)> Decorator
Definition elements.hpp:25
std::shared_ptr< Node > Element
Definition elements.hpp:23
Component Slider(SliderOption< T > options)
A slider in any direction.
Definition slider.cpp:339
Element border(Element)
Draw a border around the element.
Definition border.cpp:227
BorderStyle
Definition elements.hpp:28
@ LIGHT
Definition elements.hpp:29