mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Add paragraph and fix hflow
This commit is contained in:
@@ -36,18 +36,18 @@ class HFlow : public Node {
|
||||
}
|
||||
|
||||
// Does the current row big enough to contain the element?
|
||||
if (y + requirement.min.y > box.y_max)
|
||||
if (y + requirement.min.y > box.y_max + 1)
|
||||
break; // No? Ignore the element.
|
||||
|
||||
Box children_box;
|
||||
children_box.x_min = x;
|
||||
children_box.x_max = x + requirement.min.x;
|
||||
children_box.x_max = x + requirement.min.x - 1;
|
||||
children_box.y_min = y;
|
||||
children_box.y_max = y + requirement.min.y;
|
||||
children_box.y_max = y + requirement.min.y - 1;
|
||||
child->SetBox(children_box);
|
||||
|
||||
x = x + requirement.min.x + 1;
|
||||
y_next = std::max(y_next, y + requirement.min.y + 1);
|
||||
x = x + requirement.min.x;
|
||||
y_next = std::max(y_next, y + requirement.min.y);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
18
ftxui/src/ftxui/dom/paragraph.cpp
Normal file
18
ftxui/src/ftxui/dom/paragraph.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <sstream>
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
Elements paragraph(std::wstring the_text) {
|
||||
Elements output;
|
||||
std::wstringstream ss(the_text);
|
||||
std::wstring word;
|
||||
while (std::getline(ss, word, L' ')) {
|
||||
if (word.size()) {
|
||||
output.push_back(text(word + L' '));
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
} // namespace ftxui
|
||||
Reference in New Issue
Block a user