Add documentations to every public functions.

This commit is contained in:
ArthurSonzogni 2023-08-19 14:56:28 +02:00
parent 5724f8483b
commit 49a48820dd
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C
32 changed files with 396 additions and 48 deletions

View File

@ -13,33 +13,55 @@
namespace ftxui { namespace ftxui {
void AnimatedColorOption::Set(Color a_inactive, /// @brief A color option that can be animated.
Color a_active, /// @params _inactive The color when the component is inactive.
animation::Duration a_duration, /// @params _active The color when the component is active.
animation::easing::Function a_function) { /// @params _duration The duration of the animation.
/// @params _function The easing function of the animation.
/// @ingroup component
void AnimatedColorOption::Set(Color _inactive,
Color _active,
animation::Duration _duration,
animation::easing::Function _function) {
enabled = true; enabled = true;
inactive = a_inactive; inactive = _inactive;
active = a_active; active = _active;
duration = a_duration; duration = _duration;
function = std::move(a_function); function = std::move(_function);
} }
/// @brief Set how the underline should animate.
/// @param d The duration of the animation.
/// @param f The easing function of the animation.
/// @ingroup component
void UnderlineOption::SetAnimation(animation::Duration d, void UnderlineOption::SetAnimation(animation::Duration d,
animation::easing::Function f) { animation::easing::Function f) {
SetAnimationDuration(d); SetAnimationDuration(d);
SetAnimationFunction(std::move(f)); SetAnimationFunction(std::move(f));
} }
/// @brief Set how the underline should animate.
/// @param d The duration of the animation.
/// @ingroup component
void UnderlineOption::SetAnimationDuration(animation::Duration d) { void UnderlineOption::SetAnimationDuration(animation::Duration d) {
leader_duration = d; leader_duration = d;
follower_duration = d; follower_duration = d;
} }
/// @brief Set how the underline should animate.
/// @param f The easing function of the animation.
/// @ingroup component
void UnderlineOption::SetAnimationFunction(animation::easing::Function f) { void UnderlineOption::SetAnimationFunction(animation::easing::Function f) {
leader_function = f; leader_function = f;
follower_function = std::move(f); follower_function = std::move(f);
} }
/// @brief Set how the underline should animate.
/// This is useful to desynchronize the animation of the leader and the
/// follower.
/// @param f_leader The duration of the animation for the leader.
/// @param f_follower The duration of the animation for the follower.
/// @ingroup component
void UnderlineOption::SetAnimationFunction( void UnderlineOption::SetAnimationFunction(
animation::easing::Function f_leader, animation::easing::Function f_leader,
animation::easing::Function f_follower) { animation::easing::Function f_follower) {
@ -47,6 +69,9 @@ void UnderlineOption::SetAnimationFunction(
follower_function = std::move(f_follower); follower_function = std::move(f_follower);
} }
/// @brief Standard options for an horizontal menu.
/// This can be useful to implement a tab bar.
/// @ingroup component
// static // static
MenuOption MenuOption::Horizontal() { MenuOption MenuOption::Horizontal() {
MenuOption option; MenuOption option;
@ -69,6 +94,9 @@ MenuOption MenuOption::Horizontal() {
return option; return option;
} }
/// @brief Standard options for an animated horizontal menu.
/// This can be useful to implement a tab bar.
/// @ingroup component
// static // static
MenuOption MenuOption::HorizontalAnimated() { MenuOption MenuOption::HorizontalAnimated() {
auto option = Horizontal(); auto option = Horizontal();
@ -76,6 +104,9 @@ MenuOption MenuOption::HorizontalAnimated() {
return option; return option;
} }
/// @brief Standard options for a vertical menu.
/// This can be useful to implement a list of selectable items.
/// @ingroup component
// static // static
MenuOption MenuOption::Vertical() { MenuOption MenuOption::Vertical() {
MenuOption option; MenuOption option;
@ -95,6 +126,9 @@ MenuOption MenuOption::Vertical() {
return option; return option;
} }
/// @brief Standard options for an animated vertical menu.
/// This can be useful to implement a list of selectable items.
/// @ingroup component
// static // static
MenuOption MenuOption::VerticalAnimated() { MenuOption MenuOption::VerticalAnimated() {
auto option = MenuOption::Vertical(); auto option = MenuOption::Vertical();
@ -115,6 +149,9 @@ MenuOption MenuOption::VerticalAnimated() {
return option; return option;
} }
/// @brief Standard options for a horitontal menu with some separator.
/// This can be useful to implement a tab bar.
/// @ingroup component
// static // static
MenuOption MenuOption::Toggle() { MenuOption MenuOption::Toggle() {
auto option = MenuOption::Horizontal(); auto option = MenuOption::Horizontal();
@ -123,6 +160,7 @@ MenuOption MenuOption::Toggle() {
} }
/// @brief Create a ButtonOption, highlighted using [] characters. /// @brief Create a ButtonOption, highlighted using [] characters.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Ascii() { ButtonOption ButtonOption::Ascii() {
ButtonOption option; ButtonOption option;
@ -135,6 +173,7 @@ ButtonOption ButtonOption::Ascii() {
} }
/// @brief Create a ButtonOption, inverted when focused. /// @brief Create a ButtonOption, inverted when focused.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Simple() { ButtonOption ButtonOption::Simple() {
ButtonOption option; ButtonOption option;
@ -150,6 +189,7 @@ ButtonOption ButtonOption::Simple() {
/// @brief Create a ButtonOption. The button is shown using a border, inverted /// @brief Create a ButtonOption. The button is shown using a border, inverted
/// when focused. This is the current default. /// when focused. This is the current default.
/// @ingroup component
ButtonOption ButtonOption::Border() { ButtonOption ButtonOption::Border() {
ButtonOption option; ButtonOption option;
option.transform = [](const EntryState& s) { option.transform = [](const EntryState& s) {
@ -166,6 +206,7 @@ ButtonOption ButtonOption::Border() {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated() { ButtonOption ButtonOption::Animated() {
return Animated(Color::Black, Color::GrayLight, // return Animated(Color::Black, Color::GrayLight, //
@ -173,6 +214,7 @@ ButtonOption ButtonOption::Animated() {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated(Color color) { ButtonOption ButtonOption::Animated(Color color) {
return ButtonOption::Animated( return ButtonOption::Animated(
@ -183,6 +225,7 @@ ButtonOption ButtonOption::Animated(Color color) {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated(Color background, Color foreground) { ButtonOption ButtonOption::Animated(Color background, Color foreground) {
// NOLINTBEGIN // NOLINTBEGIN
@ -195,6 +238,7 @@ ButtonOption ButtonOption::Animated(Color background, Color foreground) {
} }
/// @brief Create a ButtonOption, using animated colors. /// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static // static
ButtonOption ButtonOption::Animated(Color background, ButtonOption ButtonOption::Animated(Color background,
Color foreground, Color foreground,
@ -214,6 +258,7 @@ ButtonOption ButtonOption::Animated(Color background,
} }
/// @brief Option for standard Checkbox. /// @brief Option for standard Checkbox.
/// @ingroup component
// static // static
CheckboxOption CheckboxOption::Simple() { CheckboxOption CheckboxOption::Simple() {
auto option = CheckboxOption(); auto option = CheckboxOption();
@ -238,6 +283,7 @@ CheckboxOption CheckboxOption::Simple() {
} }
/// @brief Option for standard Radiobox /// @brief Option for standard Radiobox
/// @ingroup component
// static // static
RadioboxOption RadioboxOption::Simple() { RadioboxOption RadioboxOption::Simple() {
auto option = RadioboxOption(); auto option = RadioboxOption();
@ -261,6 +307,8 @@ RadioboxOption RadioboxOption::Simple() {
return option; return option;
} }
/// @brief Standard options for the input component.
/// @ingroup component
// static // static
InputOption InputOption::Default() { InputOption InputOption::Default() {
InputOption option; InputOption option;
@ -282,6 +330,8 @@ InputOption InputOption::Default() {
return option; return option;
} }
/// @brief Standard options for a more beautiful input component.
/// @ingroup component
// static // static
InputOption InputOption::Spacious() { InputOption InputOption::Spacious() {
InputOption option; InputOption option;

View File

@ -15,6 +15,10 @@
namespace ftxui { namespace ftxui {
/// @brief A dropdown menu.
/// @ingroup component
/// @param entries The list of entries to display.
/// @param selected The index of the selected entry.
Component Dropdown(ConstStringListRef entries, int* selected) { Component Dropdown(ConstStringListRef entries, int* selected) {
class Impl : public ComponentBase { class Impl : public ComponentBase {
public: public:

View File

@ -9,6 +9,9 @@
namespace ftxui { namespace ftxui {
/// @brief An event corresponding to a given typed character.
/// @param input The character typed by the user.
/// @ingroup component
// static // static
Event Event::Character(std::string input) { Event Event::Character(std::string input) {
Event event; Event event;
@ -17,16 +20,26 @@ Event Event::Character(std::string input) {
return event; return event;
} }
/// @brief An event corresponding to a given typed character.
/// @param c The character typed by the user.
/// @ingroup component
// static // static
Event Event::Character(char c) { Event Event::Character(char c) {
return Event::Character(std::string{c}); return Event::Character(std::string{c});
} }
/// @brief An event corresponding to a given typed character.
/// @param c The character typed by the user.
/// @ingroup component
// static // static
Event Event::Character(wchar_t c) { Event Event::Character(wchar_t c) {
return Event::Character(to_string(std::wstring{c})); return Event::Character(to_string(std::wstring{c}));
} }
/// @brief An event corresponding to a given typed character.
/// @param input The sequence of character send by the terminal.
/// @param mouse The mouse state.
/// @ingroup component
// static // static
Event Event::Mouse(std::string input, struct Mouse mouse) { Event Event::Mouse(std::string input, struct Mouse mouse) {
Event event; Event event;
@ -36,6 +49,9 @@ Event Event::Mouse(std::string input, struct Mouse mouse) {
return event; return event;
} }
/// @brief An custom event whose meaning is defined by the user of the library.
/// @param input An arbitrary sequence of character defined by the developer.
/// @ingroup component.
// static // static
Event Event::Special(std::string input) { Event Event::Special(std::string input) {
Event event; Event event;
@ -43,6 +59,7 @@ Event Event::Special(std::string input) {
return event; return event;
} }
/// @internal
// static // static
Event Event::CursorReporting(std::string input, int x, int y) { Event Event::CursorReporting(std::string input, int x, int y) {
Event event; Event event;

View File

@ -9,6 +9,14 @@
namespace ftxui { namespace ftxui {
/// @brief A Loop is a wrapper around a Component and a ScreenInteractive.
/// It is used to run a Component in a terminal.
/// @ingroup component
/// @see Component, ScreenInteractive.
/// @see ScreenInteractive::Loop().
/// @see ScreenInteractive::ExitLoop().
/// @param screen The screen to use.
/// @param component The component to run.
// NOLINTNEXTLINE // NOLINTNEXTLINE
Loop::Loop(ScreenInteractive* screen, Component component) Loop::Loop(ScreenInteractive* screen, Component component)
: screen_(screen), component_(std::move(component)) { : screen_(screen), component_(std::move(component)) {
@ -19,6 +27,8 @@ Loop::~Loop() {
screen_->PostMain(); screen_->PostMain();
} }
/// @brief Whether the loop has quitted.
/// @ingroup component
bool Loop::HasQuitted() { bool Loop::HasQuitted() {
return screen_->HasQuitted(); return screen_->HasQuitted();
} }

View File

@ -14,6 +14,11 @@
namespace ftxui { namespace ftxui {
/// @brief Decorate a component |child|. It is shown only when |show| returns
/// true.
/// @param child the compoenent to decorate.
/// @param show a function returning whether |child| should shown.
/// @ingroup component
Component Maybe(Component child, std::function<bool()> show) { Component Maybe(Component child, std::function<bool()> show) {
class Impl : public ComponentBase { class Impl : public ComponentBase {
public: public:
@ -40,7 +45,7 @@ Component Maybe(Component child, std::function<bool()> show) {
/// @brief Decorate a component. It is shown only when the |show| function /// @brief Decorate a component. It is shown only when the |show| function
/// returns true. /// returns true.
/// @param show a function returning whether the decoratorated component should /// @param show a function returning whether the decorated component should
/// be shown. /// be shown.
/// @ingroup component /// @ingroup component
/// ///

View File

@ -402,6 +402,9 @@ void ScreenInteractive::TrackMouse(bool enable) {
track_mouse_ = enable; track_mouse_ = enable;
} }
/// @brief Add a task to the main loop.
/// It will be executed later, after every other scheduled tasks.
/// @ingroup component
void ScreenInteractive::Post(Task task) { void ScreenInteractive::Post(Task task) {
// Task/Events sent toward inactive screen or screen waiting to become // Task/Events sent toward inactive screen or screen waiting to become
// inactive are dropped. // inactive are dropped.
@ -412,10 +415,15 @@ void ScreenInteractive::Post(Task task) {
task_sender_->Send(std::move(task)); task_sender_->Send(std::move(task));
} }
/// @brief Add an event to the main loop.
/// It will be executed later, after every other scheduled events.
/// @ingroup component
void ScreenInteractive::PostEvent(Event event) { void ScreenInteractive::PostEvent(Event event) {
Post(event); Post(event);
} }
/// @brief Add a task to draw the screen one more time, until all the animations
/// are done.
void ScreenInteractive::RequestAnimationFrame() { void ScreenInteractive::RequestAnimationFrame() {
if (animation_requested_) { if (animation_requested_) {
return; return;
@ -428,6 +436,10 @@ void ScreenInteractive::RequestAnimationFrame() {
} }
} }
/// @brief Try to get the unique lock about behing able to capture the mouse.
/// @return A unique lock if the mouse is not already captured, otherwise a
/// null.
/// @ingroup component
CapturedMouse ScreenInteractive::CaptureMouse() { CapturedMouse ScreenInteractive::CaptureMouse() {
if (mouse_captured) { if (mouse_captured) {
return nullptr; return nullptr;
@ -437,15 +449,21 @@ CapturedMouse ScreenInteractive::CaptureMouse() {
[this] { mouse_captured = false; }); [this] { mouse_captured = false; });
} }
/// @brief Execute the main loop.
/// @param component The component to draw.
/// @ingroup component
void ScreenInteractive::Loop(Component component) { // NOLINT void ScreenInteractive::Loop(Component component) { // NOLINT
class Loop loop(this, std::move(component)); class Loop loop(this, std::move(component));
loop.Run(); loop.Run();
} }
/// @brief Return whether the main loop has been quit.
/// @ingroup component
bool ScreenInteractive::HasQuitted() { bool ScreenInteractive::HasQuitted() {
return task_receiver_->HasQuitted(); return task_receiver_->HasQuitted();
} }
// private
void ScreenInteractive::PreMain() { void ScreenInteractive::PreMain() {
// Suspend previously active screen: // Suspend previously active screen:
if (g_active_screen) { if (g_active_screen) {
@ -467,6 +485,7 @@ void ScreenInteractive::PreMain() {
previous_animation_time_ = animation::Clock::now(); previous_animation_time_ = animation::Clock::now();
} }
// private
void ScreenInteractive::PostMain() { void ScreenInteractive::PostMain() {
// Put cursor position at the end of the drawing. // Put cursor position at the end of the drawing.
ResetCursorPosition(); ResetCursorPosition();
@ -505,11 +524,13 @@ Closure ScreenInteractive::WithRestoredIO(Closure fn) { // NOLINT
}; };
} }
/// @brief Return the currently active screen, or null if none.
// static // static
ScreenInteractive* ScreenInteractive::Active() { ScreenInteractive* ScreenInteractive::Active() {
return g_active_screen; return g_active_screen;
} }
// private
void ScreenInteractive::Install() { void ScreenInteractive::Install() {
frame_valid_ = false; frame_valid_ = false;
@ -622,6 +643,7 @@ void ScreenInteractive::Install() {
std::thread(&AnimationListener, &quit_, task_receiver_->MakeSender()); std::thread(&AnimationListener, &quit_, task_receiver_->MakeSender());
} }
// private
void ScreenInteractive::Uninstall() { void ScreenInteractive::Uninstall() {
ExitNow(); ExitNow();
event_listener_.join(); event_listener_.join();
@ -629,6 +651,7 @@ void ScreenInteractive::Uninstall() {
OnExit(); OnExit();
} }
// private
// NOLINTNEXTLINE // NOLINTNEXTLINE
void ScreenInteractive::RunOnceBlocking(Component component) { void ScreenInteractive::RunOnceBlocking(Component component) {
ExecuteSignalHandlers(); ExecuteSignalHandlers();
@ -639,6 +662,7 @@ void ScreenInteractive::RunOnceBlocking(Component component) {
RunOnce(component); RunOnce(component);
} }
// private
void ScreenInteractive::RunOnce(Component component) { void ScreenInteractive::RunOnce(Component component) {
Task task; Task task;
while (task_receiver_->ReceiveNonBlocking(&task)) { while (task_receiver_->ReceiveNonBlocking(&task)) {
@ -648,6 +672,7 @@ void ScreenInteractive::RunOnce(Component component) {
Draw(std::move(component)); Draw(std::move(component));
} }
// private
void ScreenInteractive::HandleTask(Component component, Task& task) { void ScreenInteractive::HandleTask(Component component, Task& task) {
// clang-format off // clang-format off
std::visit([&](auto&& arg) { std::visit([&](auto&& arg) {
@ -699,6 +724,7 @@ void ScreenInteractive::HandleTask(Component component, Task& task) {
// clang-format on // clang-format on
} }
// private
// NOLINTNEXTLINE // NOLINTNEXTLINE
void ScreenInteractive::Draw(Component component) { void ScreenInteractive::Draw(Component component) {
if (frame_valid_) { if (frame_valid_) {
@ -793,24 +819,31 @@ void ScreenInteractive::Draw(Component component) {
frame_valid_ = true; frame_valid_ = true;
} }
// private
void ScreenInteractive::ResetCursorPosition() { void ScreenInteractive::ResetCursorPosition() {
std::cout << reset_cursor_position; std::cout << reset_cursor_position;
reset_cursor_position = ""; reset_cursor_position = "";
} }
/// @brief Return a function to exit the main loop.
/// @ingroup component
Closure ScreenInteractive::ExitLoopClosure() { Closure ScreenInteractive::ExitLoopClosure() {
return [this] { Exit(); }; return [this] { Exit(); };
} }
/// @brief Exit the main loop.
/// @ingroup component
void ScreenInteractive::Exit() { void ScreenInteractive::Exit() {
Post([this] { ExitNow(); }); Post([this] { ExitNow(); });
} }
// private:
void ScreenInteractive::ExitNow() { void ScreenInteractive::ExitNow() {
quit_ = true; quit_ = true;
task_sender_.reset(); task_sender_.reset();
} }
// private:
void ScreenInteractive::Signal(int signal) { void ScreenInteractive::Signal(int signal) {
if (signal == SIGABRT) { if (signal == SIGABRT) {
OnExit(); OnExit();

View File

@ -34,7 +34,6 @@ Decorator flexDirection(Direction direction) {
} }
return xflex; // NOT_REACHED() return xflex; // NOT_REACHED()
} }
} // namespace
template <class T> template <class T>
class SliderBase : public ComponentBase { class SliderBase : public ComponentBase {
@ -256,6 +255,7 @@ class SliderWithLabel : public ComponentBase {
Box box_; Box box_;
bool mouse_hover_ = false; bool mouse_hover_ = false;
}; };
} // namespace
/// @brief An horizontal slider. /// @brief An horizontal slider.
/// @param label The name of the slider. /// @param label The name of the slider.

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Blink : public NodeDecorator { class Blink : public NodeDecorator {
public: public:
using NodeDecorator::NodeDecorator; using NodeDecorator::NodeDecorator;
@ -25,6 +26,7 @@ class Blink : public NodeDecorator {
} }
} }
}; };
} // namespace
/// @brief The text drawn alternates in between visible and hidden. /// @brief The text drawn alternates in between visible and hidden.
/// @ingroup dom /// @ingroup dom

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Bold : public NodeDecorator { class Bold : public NodeDecorator {
public: public:
using NodeDecorator::NodeDecorator; using NodeDecorator::NodeDecorator;
@ -25,6 +26,7 @@ class Bold : public NodeDecorator {
Node::Render(screen); Node::Render(screen);
} }
}; };
} // namespace
/// @brief Use a bold font, for elements with more emphasis. /// @brief Use a bold font, for elements with more emphasis.
/// @ingroup dom /// @ingroup dom

View File

@ -18,6 +18,7 @@
namespace ftxui { namespace ftxui {
namespace {
using Charset = std::array<std::string, 6>; // NOLINT using Charset = std::array<std::string, 6>; // NOLINT
using Charsets = std::array<Charset, 6>; // NOLINT using Charsets = std::array<Charset, 6>; // NOLINT
// NOLINTNEXTLINE // NOLINTNEXTLINE
@ -190,6 +191,7 @@ class BorderPixel : public Node {
} }
} }
}; };
} // namespace
/// @brief Draw a border around the element. /// @brief Draw a border around the element.
/// @ingroup dom /// @ingroup dom

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
using ftxui::Screen; using ftxui::Screen;
class ClearUnder : public NodeDecorator { class ClearUnder : public NodeDecorator {
@ -27,6 +28,7 @@ class ClearUnder : public NodeDecorator {
Node::Render(screen); Node::Render(screen);
} }
}; };
} // namespace
/// @brief Before drawing |child|, clear the pixels below. This is useful in /// @brief Before drawing |child|, clear the pixels below. This is useful in
// combinaison with dbox. // combinaison with dbox.

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
class BgColor : public NodeDecorator { class BgColor : public NodeDecorator {
public: public:
BgColor(Element child, Color color) BgColor(Element child, Color color)
@ -45,6 +46,7 @@ class FgColor : public NodeDecorator {
Color color_; Color color_;
}; };
} // namespace
/// @brief Set the foreground color of an element. /// @brief Set the foreground color of an element.
/// @param color The color of the output element. /// @param color The color of the output element.

View File

@ -13,6 +13,7 @@
namespace ftxui { namespace ftxui {
namespace {
class DBox : public Node { class DBox : public Node {
public: public:
explicit DBox(Elements children) : Node(std::move(children)) {} 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. /// @brief Stack several element on top of each other.
/// @param children_ The input element. /// @param children_ The input element.

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Dim : public NodeDecorator { class Dim : public NodeDecorator {
public: public:
using NodeDecorator::NodeDecorator; using NodeDecorator::NodeDecorator;
@ -25,6 +26,7 @@ class Dim : public NodeDecorator {
} }
} }
}; };
} // namespace
/// @brief Use a light font, for elements with less emphasis. /// @brief Use a light font, for elements with less emphasis.
/// @ingroup dom /// @ingroup dom

View File

@ -66,8 +66,6 @@ void function_not_flex(Requirement& r) {
r.flex_shrink_y = 0; r.flex_shrink_y = 0;
} }
} // namespace
class Flex : public Node { class Flex : public Node {
public: public:
explicit Flex(FlexFunction f) : f_(f) {} explicit Flex(FlexFunction f) : f_(f) {}
@ -92,6 +90,8 @@ class Flex : public Node {
FlexFunction f_; FlexFunction f_;
}; };
} // namespace
/// @brief An element that will take expand proportionnally to the space left in /// @brief An element that will take expand proportionnally to the space left in
/// a container. /// a container.
/// @ingroup dom /// @ingroup dom

View File

@ -5,31 +5,43 @@
namespace ftxui { namespace ftxui {
/// @brief Set the flexbox direction.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Direction d) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Direction d) {
this->direction = d; this->direction = d;
return *this; return *this;
} }
/// @brief Set the flexbox wrap.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Wrap w) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Wrap w) {
this->wrap = w; this->wrap = w;
return *this; return *this;
} }
/// @brief Set the flexbox justify content.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::JustifyContent j) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::JustifyContent j) {
this->justify_content = j; this->justify_content = j;
return *this; return *this;
} }
/// @brief Set the flexbox align items.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignItems a) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignItems a) {
this->align_items = a; this->align_items = a;
return *this; return *this;
} }
/// @brief Set the flexbox align content.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignContent a) { FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignContent a) {
this->align_content = a; this->align_content = a;
return *this; return *this;
} }
/// @brief Set the flexbox flex direction.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::SetGap(int x, int y) { FlexboxConfig& FlexboxConfig::SetGap(int x, int y) {
this->gap_x = x; this->gap_x = x;
this->gap_y = y; this->gap_y = y;

View File

@ -288,9 +288,6 @@ void JustifyContent(Global& g, std::vector<Line> lines) {
} }
} }
} }
} // namespace
namespace {
void Compute1(Global& global); void Compute1(Global& global);
void Compute2(Global& global); void Compute2(Global& global);

View File

@ -15,8 +15,7 @@
namespace ftxui { namespace ftxui {
// ----------------------------------------------------------------------------- namespace {
class Select : public Node { class Select : public Node {
public: public:
explicit Select(Elements children) : Node(std::move(children)) {} 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 { class Focus : public Select {
public: 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 { class Frame : public Node {
public: public:
Frame(Elements children, bool x_frame, bool y_frame) Frame(Elements children, bool x_frame, bool y_frame)
@ -138,22 +126,6 @@ class Frame : public Node {
bool y_frame_; 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 { class FocusCursor : public Focus {
public: public:
FocusCursor(Elements children, Screen::Cursor::Shape shape) FocusCursor(Elements children, Screen::Cursor::Shape shape)
@ -171,26 +143,128 @@ class FocusCursor : public Focus {
Screen::Cursor::Shape shape_; 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) { Element focusCursorBlock(Element child) {
return std::make_shared<FocusCursor>(unpack(std::move(child)), return std::make_shared<FocusCursor>(unpack(std::move(child)),
Screen::Cursor::Block); 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) { Element focusCursorBlockBlinking(Element child) {
return std::make_shared<FocusCursor>(unpack(std::move(child)), return std::make_shared<FocusCursor>(unpack(std::move(child)),
Screen::Cursor::BlockBlinking); 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) { Element focusCursorBar(Element child) {
return std::make_shared<FocusCursor>(unpack(std::move(child)), return std::make_shared<FocusCursor>(unpack(std::move(child)),
Screen::Cursor::Bar); 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) { Element focusCursorBarBlinking(Element child) {
return std::make_shared<FocusCursor>(unpack(std::move(child)), return std::make_shared<FocusCursor>(unpack(std::move(child)),
Screen::Cursor::BarBlinking); 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) { Element focusCursorUnderline(Element child) {
return std::make_shared<FocusCursor>(unpack(std::move(child)), return std::make_shared<FocusCursor>(unpack(std::move(child)),
Screen::Cursor::Underline); 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) { Element focusCursorUnderlineBlinking(Element child) {
return std::make_shared<FocusCursor>(unpack(std::move(child)), return std::make_shared<FocusCursor>(unpack(std::move(child)),
Screen::Cursor::UnderlineBlinking); Screen::Cursor::UnderlineBlinking);

View File

@ -13,6 +13,7 @@
namespace ftxui { namespace ftxui {
namespace {
// NOLINTNEXTLINE // NOLINTNEXTLINE
static const std::string charset_horizontal[11] = { static const std::string charset_horizontal[11] = {
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK) #if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
@ -158,6 +159,8 @@ class Gauge : public Node {
Direction direction_; Direction direction_;
}; };
} // namespace ftxui
/// @brief Draw a high definition progress bar progressing in specified /// @brief Draw a high definition progress bar progressing in specified
/// direction. /// direction.
/// @param progress The proportion of the area to be filled. Belong to [0,1]. /// @param progress The proportion of the area to be filled. Belong to [0,1].

View File

@ -15,6 +15,7 @@
namespace ftxui { namespace ftxui {
namespace {
// NOLINTNEXTLINE // NOLINTNEXTLINE
static std::string charset[] = static std::string charset[] =
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK) #if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
@ -63,6 +64,8 @@ class Graph : public Node {
GraphFunction graph_function_; GraphFunction graph_function_;
}; };
} // namespace
/// @brief Draw a graph using a GraphFunction. /// @brief Draw a graph using a GraphFunction.
/// @param graph_function the function to be called to get the data. /// @param graph_function the function to be called to get the data.
Element graph(GraphFunction graph_function) { Element graph(GraphFunction graph_function) {

View File

@ -31,7 +31,6 @@ int Integrate(std::vector<int>& elements) {
} }
return accu; return accu;
} }
} // namespace
class GridBox : public Node { class GridBox : public Node {
public: public:
@ -153,7 +152,8 @@ class GridBox : public Node {
int y_size = 0; int y_size = 0;
std::vector<Elements> lines_; std::vector<Elements> lines_;
}; };
} // namespace
//
/// @brief A container displaying a grid of elements. /// @brief A container displaying a grid of elements.
/// @param lines A list of lines, each line being a list of elements. /// @param lines A list of lines, each line being a list of elements.
/// @return The container. /// @return The container.

View File

@ -15,6 +15,7 @@
namespace ftxui { namespace ftxui {
namespace {
class HBox : public Node { class HBox : public Node {
public: public:
explicit HBox(Elements children) : Node(std::move(children)) {} 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. /// @brief A container displaying elements horizontally one by one.
/// @param children The elements in the container /// @param children The elements in the container
/// @return The container. /// @return The container.

View File

@ -13,6 +13,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Hyperlink : public NodeDecorator { class Hyperlink : public NodeDecorator {
public: public:
Hyperlink(Element child, std::string link) Hyperlink(Element child, std::string link)
@ -30,6 +31,7 @@ class Hyperlink : public NodeDecorator {
std::string link_; std::string link_;
}; };
} // namespace
/// @brief Make the rendered area clickable using a web browser. /// @brief Make the rendered area clickable using a web browser.
/// The link will be opened when the user click on it. /// The link will be opened when the user click on it.

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Inverted : public NodeDecorator { class Inverted : public NodeDecorator {
public: public:
using NodeDecorator::NodeDecorator; using NodeDecorator::NodeDecorator;
@ -25,6 +26,7 @@ class Inverted : public NodeDecorator {
} }
} }
}; };
} // namespace
/// @brief Add a filter that will invert the foreground and the background /// @brief Add a filter that will invert the foreground and the background
/// colors. /// colors.

View File

@ -12,6 +12,7 @@
#include "ftxui/screen/screen.hpp" // for Screen #include "ftxui/screen/screen.hpp" // for Screen
namespace ftxui { namespace ftxui {
namespace {
// Helper class. // Helper class.
class Reflect : public Node { class Reflect : public Node {
@ -38,6 +39,7 @@ class Reflect : public Node {
private: private:
Box& reflected_box_; Box& reflected_box_;
}; };
} // namespace
Decorator reflect(Box& box) { Decorator reflect(Box& box) {
return [&](Element child) -> Element { return [&](Element child) -> Element {

View File

@ -28,8 +28,6 @@ const Charsets charsets = {
Charset{" ", " "}, // EMPTY Charset{" ", " "}, // EMPTY
}; };
} // namespace
class Separator : public Node { class Separator : public Node {
public: public:
explicit Separator(std::string value) : value_(std::move(value)) {} explicit Separator(std::string value) : value_(std::move(value)) {}
@ -96,6 +94,7 @@ class SeparatorWithPixel : public SeparatorAuto {
private: private:
Pixel pixel_; Pixel pixel_;
}; };
} // namespace
/// @brief Draw a vertical or horizontal separation in between two other /// @brief Draw a vertical or horizontal separation in between two other
/// elements. /// elements.

View File

@ -13,6 +13,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Size : public Node { class Size : public Node {
public: public:
Size(Element child, WidthOrHeight direction, Constraint constraint, int value) Size(Element child, WidthOrHeight direction, Constraint constraint, int value)
@ -78,6 +79,7 @@ class Size : public Node {
Constraint constraint_; Constraint constraint_;
int value_; int value_;
}; };
} // namespace
/// @brief Apply a constraint on the size of an element. /// @brief Apply a constraint on the size of an element.
/// @param direction Whether the WIDTH of the HEIGHT of the element must be /// @param direction Whether the WIDTH of the HEIGHT of the element must be

View File

@ -41,10 +41,16 @@ void Order(int& a, int& b) {
} // namespace } // namespace
/// @brief Create an empty table.
/// @ingroup dom
Table::Table() { Table::Table() {
Initialize({}); 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) { Table::Table(std::vector<std::vector<std::string>> input) {
std::vector<std::vector<Element>> output; std::vector<std::vector<Element>> output;
output.reserve(input.size()); output.reserve(input.size());
@ -59,10 +65,14 @@ Table::Table(std::vector<std::vector<std::string>> input) {
Initialize(std::move(output)); 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) { Table::Table(std::vector<std::vector<Element>> input) {
Initialize(std::move(input)); Initialize(std::move(input));
} }
// private
void Table::Initialize(std::vector<std::vector<Element>> input) { void Table::Initialize(std::vector<std::vector<Element>> input) {
input_dim_y_ = input.size(); input_dim_y_ = input.size();
input_dim_x_ = 0; 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) { TableSelection Table::SelectRow(int index) {
return SelectRectangle(0, -1, index, 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) { TableSelection Table::SelectRows(int row_min, int row_max) {
return SelectRectangle(0, -1, row_min, 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) { TableSelection Table::SelectColumn(int index) {
return SelectRectangle(index, index, 0, -1); 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) { TableSelection Table::SelectColumns(int column_min, int column_max) {
return SelectRectangle(column_min, column_max, 0, -1); 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) { TableSelection Table::SelectCell(int column, int row) {
return SelectRectangle(column, column, row, 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, TableSelection Table::SelectRectangle(int column_min,
int column_max, int column_max,
int row_min, int row_min,
@ -149,6 +189,8 @@ TableSelection Table::SelectRectangle(int column_min,
return output; return output;
} }
/// @brief Select all the table.
/// @ingroup dom
TableSelection Table::SelectAll() { TableSelection Table::SelectAll() {
TableSelection output; // NOLINT TableSelection output; // NOLINT
output.table_ = this; output.table_ = this;
@ -159,6 +201,9 @@ TableSelection Table::SelectAll() {
return output; return output;
} }
/// @brief Render the table.
/// @return The rendered table. This is an element you can draw.
/// @ingroup dom
Element Table::Render() { Element Table::Render() {
for (int y = 0; y < dim_y_; ++y) { for (int y = 0; y < dim_y_; ++y) {
for (int x = 0; x < dim_x_; ++x) { for (int x = 0; x < dim_x_; ++x) {
@ -185,6 +230,10 @@ Element Table::Render() {
return gridbox(std::move(elements_)); 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 // NOLINTNEXTLINE
void TableSelection::Decorate(Decorator decorator) { void TableSelection::Decorate(Decorator decorator) {
for (int y = y_min_; y <= y_max_; ++y) { 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 // NOLINTNEXTLINE
void TableSelection::DecorateCells(Decorator decorator) { void TableSelection::DecorateCells(Decorator decorator) {
for (int y = y_min_; y <= y_max_; ++y) { 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 // NOLINTNEXTLINE
void TableSelection::DecorateAlternateColumn(Decorator decorator, void TableSelection::DecorateAlternateColumn(Decorator decorator,
int modulo, 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 // NOLINTNEXTLINE
void TableSelection::DecorateAlternateRow(Decorator decorator, void TableSelection::DecorateAlternateRow(Decorator decorator,
int modulo, 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 // NOLINTNEXTLINE
void TableSelection::DecorateCellsAlternateColumn(Decorator decorator, void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
int modulo, 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 // NOLINTNEXTLINE
void TableSelection::DecorateCellsAlternateRow(Decorator decorator, void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
int modulo, 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) { void TableSelection::Border(BorderStyle border) {
BorderLeft(border); BorderLeft(border);
BorderRight(border); BorderRight(border);
@ -279,6 +359,9 @@ void TableSelection::Border(BorderStyle border) {
table_->elements_[y_max_][x_max_] = text(charset[border][3]) | automerge; 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) { void TableSelection::Separator(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) { for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) { 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) { void TableSelection::SeparatorVertical(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) { for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) { 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) { void TableSelection::SeparatorHorizontal(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) { for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) { 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) { void TableSelection::BorderLeft(BorderStyle border) {
for (int y = y_min_; y <= y_max_; y++) { for (int y = y_min_; y <= y_max_; y++) {
table_->elements_[y][x_min_] = 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) { void TableSelection::BorderRight(BorderStyle border) {
for (int y = y_min_; y <= y_max_; y++) { for (int y = y_min_; y <= y_max_; y++) {
table_->elements_[y][x_max_] = 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) { void TableSelection::BorderTop(BorderStyle border) {
for (int x = x_min_; x <= x_max_; x++) { for (int x = x_min_; x <= x_max_; x++) {
table_->elements_[y_min_][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) { void TableSelection::BorderBottom(BorderStyle border) {
for (int x = x_min_; x <= x_max_; x++) { for (int x = x_min_; x <= x_max_; x++) {
table_->elements_[y_max_][x] = table_->elements_[y_max_][x] =

View File

@ -17,6 +17,7 @@
namespace ftxui { namespace ftxui {
namespace {
using ftxui::Screen; using ftxui::Screen;
class Text : public Node { class Text : public Node {
@ -80,6 +81,8 @@ class VText : public Node {
int width_ = 1; int width_ = 1;
}; };
} // namespace
/// @brief Display a piece of UTF8 encoded unicode text. /// @brief Display a piece of UTF8 encoded unicode text.
/// @ingroup dom /// @ingroup dom
/// @see ftxui::to_wstring /// @see ftxui::to_wstring

View File

@ -12,6 +12,7 @@
namespace ftxui { namespace ftxui {
namespace {
class Underlined : public NodeDecorator { class Underlined : public NodeDecorator {
public: public:
using NodeDecorator::NodeDecorator; using NodeDecorator::NodeDecorator;
@ -25,6 +26,7 @@ class Underlined : public NodeDecorator {
} }
} }
}; };
} // namespace
/// @brief Make the underlined element to be underlined. /// @brief Make the underlined element to be underlined.
/// @ingroup dom /// @ingroup dom

View File

@ -15,6 +15,7 @@
namespace ftxui { namespace ftxui {
namespace {
class VBox : public Node { class VBox : public Node {
public: public:
explicit VBox(Elements children) : Node(std::move(children)) {} 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. /// @brief A container displaying elements vertically one by one.
/// @param children The elements in the container /// @param children The elements in the container

View File

@ -87,6 +87,10 @@ Terminal::Color ComputeColorSupport() {
} // namespace } // namespace
namespace Terminal { namespace Terminal {
/// @brief Get the terminal size.
/// @return The terminal size.
/// @ingroup screen
Dimensions Size() { Dimensions Size() {
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
// This dimension was chosen arbitrarily to be able to display: // This dimension was chosen arbitrarily to be able to display:
@ -121,6 +125,8 @@ void SetFallbackSize(const Dimensions& fallbackSize) {
FallbackSize() = fallbackSize; FallbackSize() = fallbackSize;
} }
/// @brief Get the color support of the terminal.
/// @ingroup screen
Color ColorSupport() { Color ColorSupport() {
if (!g_cached) { if (!g_cached) {
g_cached = true; g_cached = true;
@ -129,6 +135,8 @@ Color ColorSupport() {
return g_cached_supported_color; return g_cached_supported_color;
} }
/// @brief Override terminal color support in case auto-detection fails
/// @ingroup dom
void SetColorSupport(Color color) { void SetColorSupport(Color color) {
g_cached = true; g_cached = true;
g_cached_supported_color = color; g_cached_supported_color = color;