Euphoria
|
#include <textbox.h>
Public Member Functions | |
void | put_char (int x, int y, char c) |
Place a single character in the given coordinate. More... | |
template<typename F > | |
void | mod_char (int x, int y, F &&func) |
Modify a character using a callback. More... | |
void | put_string (int x, int y, const std::string &s) |
Put a string of characters starting at the given coordinate. More... | |
void | put_box (int x, int y, const TextBox &b) |
void | put_horizontal_line (int x, int y, int width, bool bef, bool aft) |
Draw a horizontal line. More... | |
void | put_vertical_line (int x, int y, int height, bool bef, bool aft) |
Draw a vertical line. More... | |
void | trim () |
Delete trailing blank from the bottom and right edges. More... | |
TextBox | put_box_copy (int x, int y, const TextBox &b) const |
std::vector< std::string > | to_string (const TextBoxStyle &style=get_terminal_style()) const |
int | get_horizontal_append_position (int y, const TextBox &b) const |
Calculate the earliest X coordinate where the given box could be placed. More... | |
int | get_vertical_append_position (int x, const TextBox &b) const |
Calculate the earliest Y coordinate where the given box could be placed without colliding with existing content in this box. More... | |
int | get_height () const |
Calculate the current dimensions of the string. More... | |
int | get_width () const |
std::pair< int, int > | get_size () const |
Static Public Member Functions | |
static TextBox | create_empty () |
static TextBox | create_from_strings (const std::vector< std::string > &str) |
static TextBox | from_string (const std::string &s, int x=0, int y=0) |
template<typename T , typename TToStringFunc , typename TCountChildrenFunc , typename TOneLinerTestFunc , typename TSimpleTestFunc > | |
static TextBox | create_tree_graph (const T &e, int maxwidth, TToStringFunc &&to_string, TCountChildrenFunc &&count_children_func, TOneLinerTestFunc &&oneliner_test_func, TSimpleTestFunc &&simple_test_func, int margin=4, int firstx=2) |
An utility function that can be used to create a tree graph rendering from a structure. More... | |
Detailed Description
Member Function Documentation
◆ create_empty()
|
static |
Definition at line 77 of file textbox.cc.
◆ create_from_strings()
|
static |
Definition at line 84 of file textbox.cc.
◆ create_tree_graph()
|
inlinestatic |
An utility function that can be used to create a tree graph rendering from a structure.
- Parameters
-
e The element that will be rendered. Possibly some user-defined type that represents a node in a tree structure. maxwidth The maximum width of the resulting box in characters. to_string A functor of type std::string(const T&). It renders the given element into an 1D string. Note that the string must not contain multibyte characters, because size() will be used to determine its width in columns. count_children_func A functor of type std::pair<ForwardIterator,ForwardIterator>(const T&). It returns a pair of iterators representing the range of children for the given element. create_tree_graph will call itself recursively for each element in this range. oneliner_test_func A functor of type bool(const T&). If the result is true, enables simplified horizontal topology. simple_test_func A functor of type bool(const T&). If the result is true, enables very simplified horizontal topology. margin the spacing between children firstx the first child offset
Topology types:
Vertical:
Horizontal:
Simplified horizontal:
The vertical and horizontal topologies are automatically chosen depending on the situation compared to the maxwidth parameter.
Simplified topology will be used if
- oneliner_test_func() returns true,
- all children fit on one line,
- and very simplified topology is not used.
Very simplified topology will be used if
- oneliner_test_func() returns true,
- simple_test_func() returns true,
- there is only 1 child,
- and it fits on one line.
◆ from_string()
|
static |
Definition at line 129 of file textbox.cc.
◆ get_height()
int eu::core::TextBox::get_height | ( | ) | const |
Calculate the current dimensions of the string.
Definition at line 216 of file textbox.cc.
◆ get_horizontal_append_position()
int eu::core::TextBox::get_horizontal_append_position | ( | int | y, |
const TextBox & | b | ||
) | const |
Calculate the earliest X coordinate where the given box could be placed.
without colliding with existing content in this box. Guaranteed to be <= width(). Find leftmost position where box b can be appended into *this without overlap
Definition at line 310 of file textbox.cc.
◆ get_size()
std::pair< int, int > eu::core::TextBox::get_size | ( | ) | const |
- Returns
- width x height
Definition at line 237 of file textbox.cc.
◆ get_vertical_append_position()
int eu::core::TextBox::get_vertical_append_position | ( | int | x, |
const TextBox & | b | ||
) | const |
Calculate the earliest Y coordinate where the given box could be placed without colliding with existing content in this box.
Guaranteed to be <= height(). Find topmost position where box b can be appended into *this without overlap
Definition at line 325 of file textbox.cc.
◆ get_width()
int eu::core::TextBox::get_width | ( | ) | const |
Definition at line 223 of file textbox.cc.
◆ mod_char()
|
inline |
◆ put_box()
void eu::core::TextBox::put_box | ( | int | x, |
int | y, | ||
const TextBox & | b | ||
) |
Definition at line 138 of file textbox.cc.
◆ put_box_copy()
Definition at line 182 of file textbox.cc.
◆ put_char()
void eu::core::TextBox::put_char | ( | int | x, |
int | y, | ||
char | c | ||
) |
Place a single character in the given coordinate.
Notice that behavior is undefined if the character is in 00-1F range.
Definition at line 93 of file textbox.cc.
◆ put_horizontal_line()
void eu::core::TextBox::put_horizontal_line | ( | int | x, |
int | y, | ||
int | width, | ||
bool | bef, | ||
bool | aft | ||
) |
Draw a horizontal line.
If bef=true, the line starts from the left edge of the first character cell, otherwise it starts from its center. If aft=true, the line ends in the right edge of the last character cell, otherwise it ends in its center
Definition at line 244 of file textbox.cc.
◆ put_string()
void eu::core::TextBox::put_string | ( | int | x, |
int | y, | ||
const std::string & | s | ||
) |
Put a string of characters starting at the given coordinate.
Note that behavior is undefined if the string contains characters in 00-1F range or if the string includes multibyte characters.
Definition at line 115 of file textbox.cc.
◆ put_vertical_line()
void eu::core::TextBox::put_vertical_line | ( | int | x, |
int | y, | ||
int | height, | ||
bool | bef, | ||
bool | aft | ||
) |
Draw a vertical line.
If bef=true, the line starts from the top edge of the first character cell, otherwise it starts from its center. If aft=true, the line ends in the bottom edge of the last character cell, otherwise it ends in its center
Definition at line 277 of file textbox.cc.
◆ to_string()
std::vector< std::string > eu::core::TextBox::to_string | ( | const TextBoxStyle & | style = get_terminal_style() | ) | const |
Definition at line 344 of file textbox.cc.
◆ trim()
void eu::core::TextBox::trim | ( | ) |
Delete trailing blank from the bottom and right edges.
Definition at line 196 of file textbox.cc.
The documentation for this struct was generated from the following files:
- libs/core/src/core/textbox.h
- libs/core/src/core/textbox.cc