mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Add documentations to every public functions.
This commit is contained in:
@@ -41,10 +41,16 @@ void Order(int& a, int& b) {
|
||||
|
||||
} // namespace
|
||||
|
||||
/// @brief Create an empty table.
|
||||
/// @ingroup dom
|
||||
Table::Table() {
|
||||
Initialize({});
|
||||
}
|
||||
|
||||
|
||||
/// @brief Create a table from a vector of vector of string.
|
||||
/// @param input The input data.
|
||||
/// @ingroup dom
|
||||
Table::Table(std::vector<std::vector<std::string>> input) {
|
||||
std::vector<std::vector<Element>> output;
|
||||
output.reserve(input.size());
|
||||
@@ -59,10 +65,14 @@ Table::Table(std::vector<std::vector<std::string>> input) {
|
||||
Initialize(std::move(output));
|
||||
}
|
||||
|
||||
/// @brief Create a table from a vector of vector of Element
|
||||
/// @param input The input elements.
|
||||
/// @ingroup dom
|
||||
Table::Table(std::vector<std::vector<Element>> input) {
|
||||
Initialize(std::move(input));
|
||||
}
|
||||
|
||||
// private
|
||||
void Table::Initialize(std::vector<std::vector<Element>> input) {
|
||||
input_dim_y_ = input.size();
|
||||
input_dim_x_ = 0;
|
||||
@@ -109,26 +119,56 @@ void Table::Initialize(std::vector<std::vector<Element>> input) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Select a row of the table.
|
||||
/// @param index The index of the row to select.
|
||||
/// @note You can use negative index to select from the end.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectRow(int index) {
|
||||
return SelectRectangle(0, -1, index, index);
|
||||
}
|
||||
|
||||
/// @brief Select a range of rows of the table.
|
||||
/// @param row_min The first row to select.
|
||||
/// @param row_max The last row to select.
|
||||
/// @note You can use negative index to select from the end.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectRows(int row_min, int row_max) {
|
||||
return SelectRectangle(0, -1, row_min, row_max);
|
||||
}
|
||||
|
||||
/// @brief Select a column of the table.
|
||||
/// @param index The index of the column to select.
|
||||
/// @note You can use negative index to select from the end.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectColumn(int index) {
|
||||
return SelectRectangle(index, index, 0, -1);
|
||||
}
|
||||
|
||||
/// @brief Select a range of columns of the table.
|
||||
/// @param column_min The first column to select.
|
||||
/// @param column_max The last column to select.
|
||||
/// @note You can use negative index to select from the end.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectColumns(int column_min, int column_max) {
|
||||
return SelectRectangle(column_min, column_max, 0, -1);
|
||||
}
|
||||
|
||||
/// @brief Select a cell of the table.
|
||||
/// @param column The column of the cell to select.
|
||||
/// @param row The row of the cell to select.
|
||||
/// @note You can use negative index to select from the end.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectCell(int column, int row) {
|
||||
return SelectRectangle(column, column, row, row);
|
||||
}
|
||||
|
||||
/// @brief Select a rectangle of the table.
|
||||
/// @param column_min The first column to select.
|
||||
/// @param column_max The last column to select.
|
||||
/// @param row_min The first row to select.
|
||||
/// @param row_max The last row to select.
|
||||
/// @note You can use negative index to select from the end.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectRectangle(int column_min,
|
||||
int column_max,
|
||||
int row_min,
|
||||
@@ -149,6 +189,8 @@ TableSelection Table::SelectRectangle(int column_min,
|
||||
return output;
|
||||
}
|
||||
|
||||
/// @brief Select all the table.
|
||||
/// @ingroup dom
|
||||
TableSelection Table::SelectAll() {
|
||||
TableSelection output; // NOLINT
|
||||
output.table_ = this;
|
||||
@@ -159,6 +201,9 @@ TableSelection Table::SelectAll() {
|
||||
return output;
|
||||
}
|
||||
|
||||
/// @brief Render the table.
|
||||
/// @return The rendered table. This is an element you can draw.
|
||||
/// @ingroup dom
|
||||
Element Table::Render() {
|
||||
for (int y = 0; y < dim_y_; ++y) {
|
||||
for (int x = 0; x < dim_x_; ++x) {
|
||||
@@ -185,6 +230,10 @@ Element Table::Render() {
|
||||
return gridbox(std::move(elements_));
|
||||
}
|
||||
|
||||
/// @brief Apply the `decorator` to the selection.
|
||||
/// This decorate both the cells, the lines and the corners.
|
||||
/// @param decorator The decorator to apply.
|
||||
/// @ingroup dom
|
||||
// NOLINTNEXTLINE
|
||||
void TableSelection::Decorate(Decorator decorator) {
|
||||
for (int y = y_min_; y <= y_max_; ++y) {
|
||||
@@ -195,6 +244,10 @@ void TableSelection::Decorate(Decorator decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Apply the `decorator` to the selection.
|
||||
/// @param decorator The decorator to apply.
|
||||
/// This decorate only the cells.
|
||||
/// @ingroup dom
|
||||
// NOLINTNEXTLINE
|
||||
void TableSelection::DecorateCells(Decorator decorator) {
|
||||
for (int y = y_min_; y <= y_max_; ++y) {
|
||||
@@ -207,6 +260,12 @@ void TableSelection::DecorateCells(Decorator decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Apply the `decorator` to the selection.
|
||||
/// This decorate only the lines modulo `modulo` with a shift of `shift`.
|
||||
/// @param decorator The decorator to apply.
|
||||
/// @param modulo The modulo of the lines to decorate.
|
||||
/// @param shift The shift of the lines to decorate.
|
||||
/// @ingroup dom
|
||||
// NOLINTNEXTLINE
|
||||
void TableSelection::DecorateAlternateColumn(Decorator decorator,
|
||||
int modulo,
|
||||
@@ -221,6 +280,12 @@ void TableSelection::DecorateAlternateColumn(Decorator decorator,
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Apply the `decorator` to the selection.
|
||||
/// This decorate only the lines modulo `modulo` with a shift of `shift`.
|
||||
/// @param decorator The decorator to apply.
|
||||
/// @param modulo The modulo of the lines to decorate.
|
||||
/// @param shift The shift of the lines to decorate.
|
||||
/// @ingroup dom
|
||||
// NOLINTNEXTLINE
|
||||
void TableSelection::DecorateAlternateRow(Decorator decorator,
|
||||
int modulo,
|
||||
@@ -235,6 +300,12 @@ void TableSelection::DecorateAlternateRow(Decorator decorator,
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Apply the `decorator` to the selection.
|
||||
/// This decorate only the corners modulo `modulo` with a shift of `shift`.
|
||||
/// @param decorator The decorator to apply.
|
||||
/// @param modulo The modulo of the corners to decorate.
|
||||
/// @param shift The shift of the corners to decorate.
|
||||
/// @ingroup dom
|
||||
// NOLINTNEXTLINE
|
||||
void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
|
||||
int modulo,
|
||||
@@ -249,6 +320,12 @@ void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Apply the `decorator` to the selection.
|
||||
/// This decorate only the corners modulo `modulo` with a shift of `shift`.
|
||||
/// @param decorator The decorator to apply.
|
||||
/// @param modulo The modulo of the corners to decorate.
|
||||
/// @param shift The shift of the corners to decorate.
|
||||
/// @ingroup dom
|
||||
// NOLINTNEXTLINE
|
||||
void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
|
||||
int modulo,
|
||||
@@ -263,6 +340,9 @@ void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Apply a `border` around the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::Border(BorderStyle border) {
|
||||
BorderLeft(border);
|
||||
BorderRight(border);
|
||||
@@ -279,6 +359,9 @@ void TableSelection::Border(BorderStyle border) {
|
||||
table_->elements_[y_max_][x_max_] = text(charset[border][3]) | automerge;
|
||||
}
|
||||
|
||||
/// @brief Draw some separator lines in the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::Separator(BorderStyle border) {
|
||||
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
|
||||
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
|
||||
@@ -292,6 +375,9 @@ void TableSelection::Separator(BorderStyle border) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Draw some vertical separator lines in the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::SeparatorVertical(BorderStyle border) {
|
||||
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
|
||||
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
|
||||
@@ -303,6 +389,9 @@ void TableSelection::SeparatorVertical(BorderStyle border) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Draw some horizontal separator lines in the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::SeparatorHorizontal(BorderStyle border) {
|
||||
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
|
||||
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
|
||||
@@ -314,6 +403,9 @@ void TableSelection::SeparatorHorizontal(BorderStyle border) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Draw some separator lines to the left side of the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::BorderLeft(BorderStyle border) {
|
||||
for (int y = y_min_; y <= y_max_; y++) {
|
||||
table_->elements_[y][x_min_] =
|
||||
@@ -321,6 +413,9 @@ void TableSelection::BorderLeft(BorderStyle border) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Draw some separator lines to the right side of the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::BorderRight(BorderStyle border) {
|
||||
for (int y = y_min_; y <= y_max_; y++) {
|
||||
table_->elements_[y][x_max_] =
|
||||
@@ -328,6 +423,9 @@ void TableSelection::BorderRight(BorderStyle border) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Draw some separator lines to the top side of the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::BorderTop(BorderStyle border) {
|
||||
for (int x = x_min_; x <= x_max_; x++) {
|
||||
table_->elements_[y_min_][x] =
|
||||
@@ -335,6 +433,9 @@ void TableSelection::BorderTop(BorderStyle border) {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Draw some separator lines to the bottom side of the selection.
|
||||
/// @param border The border style to apply.
|
||||
/// @ingroup dom
|
||||
void TableSelection::BorderBottom(BorderStyle border) {
|
||||
for (int x = x_min_; x <= x_max_; x++) {
|
||||
table_->elements_[y_max_][x] =
|
||||
|
||||
Reference in New Issue
Block a user