visit
parent
c1c989d416
commit
90f271961f
|
@ -208,7 +208,11 @@ namespace blt
|
||||||
return range_itr(_end - offset, offset == 0);
|
return range_itr(_end - offset, offset == 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//#define BLT_LAMBDA(type, var, code) [](const type& var) -> auto { return code; }
|
||||||
|
//#define BLT_LAMBDA(var, code) [](var) -> auto { return code; }
|
||||||
|
|
||||||
|
// TODO: WTF
|
||||||
template<class... TLambdas>
|
template<class... TLambdas>
|
||||||
struct lambda_visitor : TLambdas... {
|
struct lambda_visitor : TLambdas... {
|
||||||
using TLambdas::operator()...;
|
using TLambdas::operator()...;
|
||||||
|
|
|
@ -451,9 +451,9 @@ namespace blt
|
||||||
// if one of the strings are larger than there will be a misalignment as the width of the box is based on the largest string
|
// if one of the strings are larger than there will be a misalignment as the width of the box is based on the largest string
|
||||||
// so we need to add an offset to the smallest string for centering.
|
// so we need to add an offset to the smallest string for centering.
|
||||||
if (box.data.length() > box.title.length())
|
if (box.data.length() > box.title.length())
|
||||||
titlePad += (box.data.length() - box.title.length())/2;
|
titlePad += (box.data.length() - box.title.length()) / 2;
|
||||||
else
|
else
|
||||||
dataPad += (box.title.length() - box.data.length())/2;
|
dataPad += (box.title.length() - box.data.length()) / 2;
|
||||||
|
|
||||||
// copy in the title and data string
|
// copy in the title and data string
|
||||||
for (size_t i = 0; i < box.title.size(); i++)
|
for (size_t i = 0; i < box.title.size(); i++)
|
||||||
|
@ -467,13 +467,13 @@ namespace blt
|
||||||
blt::string::ascii_data blt::string::constructBox(const blt::string::box_type& box)
|
blt::string::ascii_data blt::string::constructBox(const blt::string::box_type& box)
|
||||||
{
|
{
|
||||||
auto width = std::visit(blt::lambda_visitor{
|
auto width = std::visit(blt::lambda_visitor{
|
||||||
[](const blt::string::ascii_box& box) -> size_t {return box.width();},
|
[](const blt::string::ascii_box& box) -> size_t { return box.width(); },
|
||||||
[](const blt::string::ascii_boxes& boxes) -> size_t {return boxes.width();}
|
[](const blt::string::ascii_boxes& boxes) -> size_t { return boxes.width(); }
|
||||||
}, box);
|
}, box);
|
||||||
auto height = std::visit(blt::lambda_visitor{
|
auto height = std::visit(blt::lambda_visitor{
|
||||||
[](const blt::string::ascii_box& box) -> size_t {return box.height();},
|
[](const blt::string::ascii_box& box) -> size_t { return box.height(); },
|
||||||
[](const blt::string::ascii_boxes& boxes) -> size_t {return boxes.height();}
|
[](const blt::string::ascii_boxes& boxes) -> size_t { return boxes.height(); }
|
||||||
}, box);
|
}, box);
|
||||||
|
|
||||||
string::ascii_data data(width, height);
|
string::ascii_data data(width, height);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue