mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-18 09:08:08 +08:00
Add documentations to every public functions.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Blink : public NodeDecorator {
|
||||
public:
|
||||
using NodeDecorator::NodeDecorator;
|
||||
@@ -25,6 +26,7 @@ class Blink : public NodeDecorator {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief The text drawn alternates in between visible and hidden.
|
||||
/// @ingroup dom
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Bold : public NodeDecorator {
|
||||
public:
|
||||
using NodeDecorator::NodeDecorator;
|
||||
@@ -25,6 +26,7 @@ class Bold : public NodeDecorator {
|
||||
Node::Render(screen);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Use a bold font, for elements with more emphasis.
|
||||
/// @ingroup dom
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
using Charset = std::array<std::string, 6>; // NOLINT
|
||||
using Charsets = std::array<Charset, 6>; // NOLINT
|
||||
// NOLINTNEXTLINE
|
||||
@@ -190,6 +191,7 @@ class BorderPixel : public Node {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Draw a border around the element.
|
||||
/// @ingroup dom
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
using ftxui::Screen;
|
||||
|
||||
class ClearUnder : public NodeDecorator {
|
||||
@@ -27,6 +28,7 @@ class ClearUnder : public NodeDecorator {
|
||||
Node::Render(screen);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Before drawing |child|, clear the pixels below. This is useful in
|
||||
// combinaison with dbox.
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class BgColor : public NodeDecorator {
|
||||
public:
|
||||
BgColor(Element child, Color color)
|
||||
@@ -45,6 +46,7 @@ class FgColor : public NodeDecorator {
|
||||
|
||||
Color color_;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Set the foreground color of an element.
|
||||
/// @param color The color of the output element.
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class DBox : public Node {
|
||||
public:
|
||||
explicit DBox(Elements children) : Node(std::move(children)) {}
|
||||
@@ -47,6 +48,7 @@ class DBox : public Node {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Stack several element on top of each other.
|
||||
/// @param children_ The input element.
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Dim : public NodeDecorator {
|
||||
public:
|
||||
using NodeDecorator::NodeDecorator;
|
||||
@@ -25,6 +26,7 @@ class Dim : public NodeDecorator {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Use a light font, for elements with less emphasis.
|
||||
/// @ingroup dom
|
||||
|
@@ -66,8 +66,6 @@ void function_not_flex(Requirement& r) {
|
||||
r.flex_shrink_y = 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class Flex : public Node {
|
||||
public:
|
||||
explicit Flex(FlexFunction f) : f_(f) {}
|
||||
@@ -92,6 +90,8 @@ class Flex : public Node {
|
||||
FlexFunction f_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// @brief An element that will take expand proportionnally to the space left in
|
||||
/// a container.
|
||||
/// @ingroup dom
|
||||
|
@@ -5,31 +5,43 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
/// @brief Set the flexbox direction.
|
||||
/// @ingroup dom
|
||||
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Direction d) {
|
||||
this->direction = d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Set the flexbox wrap.
|
||||
/// @ingroup dom
|
||||
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Wrap w) {
|
||||
this->wrap = w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Set the flexbox justify content.
|
||||
/// @ingroup dom
|
||||
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::JustifyContent j) {
|
||||
this->justify_content = j;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Set the flexbox align items.
|
||||
/// @ingroup dom
|
||||
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignItems a) {
|
||||
this->align_items = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Set the flexbox align content.
|
||||
/// @ingroup dom
|
||||
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignContent a) {
|
||||
this->align_content = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Set the flexbox flex direction.
|
||||
/// @ingroup dom
|
||||
FlexboxConfig& FlexboxConfig::SetGap(int x, int y) {
|
||||
this->gap_x = x;
|
||||
this->gap_y = y;
|
||||
|
@@ -288,9 +288,6 @@ void JustifyContent(Global& g, std::vector<Line> lines) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
void Compute1(Global& global);
|
||||
void Compute2(Global& global);
|
||||
|
@@ -15,8 +15,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
class Select : public Node {
|
||||
public:
|
||||
explicit Select(Elements children) : Node(std::move(children)) {}
|
||||
@@ -38,11 +37,6 @@ class Select : public Node {
|
||||
}
|
||||
};
|
||||
|
||||
Element select(Element child) {
|
||||
return std::make_shared<Select>(unpack(std::move(child)));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class Focus : public Select {
|
||||
public:
|
||||
@@ -83,12 +77,6 @@ class Focus : public Select {
|
||||
}
|
||||
};
|
||||
|
||||
Element focus(Element child) {
|
||||
return std::make_shared<Focus>(unpack(std::move(child)));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class Frame : public Node {
|
||||
public:
|
||||
Frame(Elements children, bool x_frame, bool y_frame)
|
||||
@@ -138,22 +126,6 @@ class Frame : public Node {
|
||||
bool y_frame_;
|
||||
};
|
||||
|
||||
/// @brief Allow an element to be displayed inside a 'virtual' area. It size can
|
||||
/// be larger than its container. In this case only a smaller portion is
|
||||
/// displayed. The view is scrollable to make the focused element visible.
|
||||
/// @see focus
|
||||
Element frame(Element child) {
|
||||
return std::make_shared<Frame>(unpack(std::move(child)), true, true);
|
||||
}
|
||||
|
||||
Element xframe(Element child) {
|
||||
return std::make_shared<Frame>(unpack(std::move(child)), true, false);
|
||||
}
|
||||
|
||||
Element yframe(Element child) {
|
||||
return std::make_shared<Frame>(unpack(std::move(child)), false, true);
|
||||
}
|
||||
|
||||
class FocusCursor : public Focus {
|
||||
public:
|
||||
FocusCursor(Elements children, Screen::Cursor::Shape shape)
|
||||
@@ -171,26 +143,128 @@ class FocusCursor : public Focus {
|
||||
Screen::Cursor::Shape shape_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
/// @brief Set the `child` to be the one selected among its siblings.
|
||||
/// @param child The element to be selected.
|
||||
/// @ingroup dom
|
||||
Element select(Element child) {
|
||||
return std::make_shared<Select>(unpack(std::move(child)));
|
||||
}
|
||||
|
||||
/// @brief Set the `child` to be the one in focus globally.
|
||||
/// @param child The element to be focused.
|
||||
/// @ingroup dom
|
||||
Element focus(Element child) {
|
||||
return std::make_shared<Focus>(unpack(std::move(child)));
|
||||
}
|
||||
|
||||
/// @brief Allow an element to be displayed inside a 'virtual' area. It size can
|
||||
/// be larger than its container. In this case only a smaller portion is
|
||||
/// displayed. The view is scrollable to make the focused element visible.
|
||||
/// @see frame
|
||||
/// @see xframe
|
||||
/// @see yframe
|
||||
Element frame(Element child) {
|
||||
return std::make_shared<Frame>(unpack(std::move(child)), true, true);
|
||||
}
|
||||
|
||||
/// @brief Same as `frame`, but only on the x-axis.
|
||||
/// @see frame
|
||||
/// @see xframe
|
||||
/// @see yframe
|
||||
Element xframe(Element child) {
|
||||
return std::make_shared<Frame>(unpack(std::move(child)), true, false);
|
||||
}
|
||||
|
||||
/// @brief Same as `frame`, but only on the y-axis.
|
||||
/// @see frame
|
||||
/// @see xframe
|
||||
/// @see yframe
|
||||
Element yframe(Element child) {
|
||||
return std::make_shared<Frame>(unpack(std::move(child)), false, true);
|
||||
}
|
||||
|
||||
/// @brief Same as `focus`, but set the cursor shape to be a still block.
|
||||
/// @see focus
|
||||
/// @see focusCursorBlock
|
||||
/// @see focusCursorBlockBlinking
|
||||
/// @see focusCursorBar
|
||||
/// @see focusCursorBarBlinking
|
||||
/// @see focusCursorUnderline
|
||||
/// @see focusCursorUnderlineBlinking
|
||||
/// @ingroup dom
|
||||
Element focusCursorBlock(Element child) {
|
||||
return std::make_shared<FocusCursor>(unpack(std::move(child)),
|
||||
Screen::Cursor::Block);
|
||||
}
|
||||
|
||||
/// @brief Same as `focus`, but set the cursor shape to be a blinking block.
|
||||
/// @see focus
|
||||
/// @see focusCursorBlock
|
||||
/// @see focusCursorBlockBlinking
|
||||
/// @see focusCursorBar
|
||||
/// @see focusCursorBarBlinking
|
||||
/// @see focusCursorUnderline
|
||||
/// @see focusCursorUnderlineBlinking
|
||||
/// @ingroup dom
|
||||
Element focusCursorBlockBlinking(Element child) {
|
||||
return std::make_shared<FocusCursor>(unpack(std::move(child)),
|
||||
Screen::Cursor::BlockBlinking);
|
||||
}
|
||||
|
||||
/// @brief Same as `focus`, but set the cursor shape to be a still block.
|
||||
/// @see focus
|
||||
/// @see focusCursorBlock
|
||||
/// @see focusCursorBlockBlinking
|
||||
/// @see focusCursorBar
|
||||
/// @see focusCursorBarBlinking
|
||||
/// @see focusCursorUnderline
|
||||
/// @see focusCursorUnderlineBlinking
|
||||
/// @ingroup dom
|
||||
Element focusCursorBar(Element child) {
|
||||
return std::make_shared<FocusCursor>(unpack(std::move(child)),
|
||||
Screen::Cursor::Bar);
|
||||
}
|
||||
|
||||
/// @brief Same as `focus`, but set the cursor shape to be a blinking bar.
|
||||
/// @see focus
|
||||
/// @see focusCursorBlock
|
||||
/// @see focusCursorBlockBlinking
|
||||
/// @see focusCursorBar
|
||||
/// @see focusCursorBarBlinking
|
||||
/// @see focusCursorUnderline
|
||||
/// @see focusCursorUnderlineBlinking
|
||||
/// @ingroup dom
|
||||
Element focusCursorBarBlinking(Element child) {
|
||||
return std::make_shared<FocusCursor>(unpack(std::move(child)),
|
||||
Screen::Cursor::BarBlinking);
|
||||
}
|
||||
|
||||
/// @brief Same as `focus`, but set the cursor shape to be a still underline.
|
||||
/// @see focus
|
||||
/// @see focusCursorBlock
|
||||
/// @see focusCursorBlockBlinking
|
||||
/// @see focusCursorBar
|
||||
/// @see focusCursorBarBlinking
|
||||
/// @see focusCursorUnderline
|
||||
/// @see focusCursorUnderlineBlinking
|
||||
/// @ingroup dom
|
||||
Element focusCursorUnderline(Element child) {
|
||||
return std::make_shared<FocusCursor>(unpack(std::move(child)),
|
||||
Screen::Cursor::Underline);
|
||||
}
|
||||
|
||||
/// @brief Same as `focus`, but set the cursor shape to be a blinking underline.
|
||||
/// @see focus
|
||||
/// @see focusCursorBlock
|
||||
/// @see focusCursorBlockBlinking
|
||||
/// @see focusCursorBar
|
||||
/// @see focusCursorBarBlinking
|
||||
/// @see focusCursorUnderline
|
||||
/// @see focusCursorUnderlineBlinking
|
||||
/// @ingroup dom
|
||||
Element focusCursorUnderlineBlinking(Element child) {
|
||||
return std::make_shared<FocusCursor>(unpack(std::move(child)),
|
||||
Screen::Cursor::UnderlineBlinking);
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
// NOLINTNEXTLINE
|
||||
static const std::string charset_horizontal[11] = {
|
||||
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||
@@ -158,6 +159,8 @@ class Gauge : public Node {
|
||||
Direction direction_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
/// @brief Draw a high definition progress bar progressing in specified
|
||||
/// direction.
|
||||
/// @param progress The proportion of the area to be filled. Belong to [0,1].
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
// NOLINTNEXTLINE
|
||||
static std::string charset[] =
|
||||
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||
@@ -63,6 +64,8 @@ class Graph : public Node {
|
||||
GraphFunction graph_function_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// @brief Draw a graph using a GraphFunction.
|
||||
/// @param graph_function the function to be called to get the data.
|
||||
Element graph(GraphFunction graph_function) {
|
||||
|
@@ -31,7 +31,6 @@ int Integrate(std::vector<int>& elements) {
|
||||
}
|
||||
return accu;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class GridBox : public Node {
|
||||
public:
|
||||
@@ -153,7 +152,8 @@ class GridBox : public Node {
|
||||
int y_size = 0;
|
||||
std::vector<Elements> lines_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
//
|
||||
/// @brief A container displaying a grid of elements.
|
||||
/// @param lines A list of lines, each line being a list of elements.
|
||||
/// @return The container.
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class HBox : public Node {
|
||||
public:
|
||||
explicit HBox(Elements children) : Node(std::move(children)) {}
|
||||
@@ -65,6 +66,8 @@ class HBox : public Node {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// @brief A container displaying elements horizontally one by one.
|
||||
/// @param children The elements in the container
|
||||
/// @return The container.
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Hyperlink : public NodeDecorator {
|
||||
public:
|
||||
Hyperlink(Element child, std::string link)
|
||||
@@ -30,6 +31,7 @@ class Hyperlink : public NodeDecorator {
|
||||
|
||||
std::string link_;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Make the rendered area clickable using a web browser.
|
||||
/// The link will be opened when the user click on it.
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Inverted : public NodeDecorator {
|
||||
public:
|
||||
using NodeDecorator::NodeDecorator;
|
||||
@@ -25,6 +26,7 @@ class Inverted : public NodeDecorator {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Add a filter that will invert the foreground and the background
|
||||
/// colors.
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "ftxui/screen/screen.hpp" // for Screen
|
||||
|
||||
namespace ftxui {
|
||||
namespace {
|
||||
|
||||
// Helper class.
|
||||
class Reflect : public Node {
|
||||
@@ -38,6 +39,7 @@ class Reflect : public Node {
|
||||
private:
|
||||
Box& reflected_box_;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Decorator reflect(Box& box) {
|
||||
return [&](Element child) -> Element {
|
||||
|
@@ -28,8 +28,6 @@ const Charsets charsets = {
|
||||
Charset{" ", " "}, // EMPTY
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class Separator : public Node {
|
||||
public:
|
||||
explicit Separator(std::string value) : value_(std::move(value)) {}
|
||||
@@ -96,6 +94,7 @@ class SeparatorWithPixel : public SeparatorAuto {
|
||||
private:
|
||||
Pixel pixel_;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Draw a vertical or horizontal separation in between two other
|
||||
/// elements.
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Size : public Node {
|
||||
public:
|
||||
Size(Element child, WidthOrHeight direction, Constraint constraint, int value)
|
||||
@@ -78,6 +79,7 @@ class Size : public Node {
|
||||
Constraint constraint_;
|
||||
int value_;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Apply a constraint on the size of an element.
|
||||
/// @param direction Whether the WIDTH of the HEIGHT of the element must be
|
||||
|
@@ -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] =
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
using ftxui::Screen;
|
||||
|
||||
class Text : public Node {
|
||||
@@ -80,6 +81,8 @@ class VText : public Node {
|
||||
int width_ = 1;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// @brief Display a piece of UTF8 encoded unicode text.
|
||||
/// @ingroup dom
|
||||
/// @see ftxui::to_wstring
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class Underlined : public NodeDecorator {
|
||||
public:
|
||||
using NodeDecorator::NodeDecorator;
|
||||
@@ -25,6 +26,7 @@ class Underlined : public NodeDecorator {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief Make the underlined element to be underlined.
|
||||
/// @ingroup dom
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
namespace {
|
||||
class VBox : public Node {
|
||||
public:
|
||||
explicit VBox(Elements children) : Node(std::move(children)) {}
|
||||
@@ -64,6 +65,7 @@ class VBox : public Node {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
/// @brief A container displaying elements vertically one by one.
|
||||
/// @param children The elements in the container
|
||||
|
Reference in New Issue
Block a user