implement word wrap in text node
This commit is contained in:
19
src/util.h
19
src/util.h
@@ -45,6 +45,24 @@ std::vector<T> poly_remove_duplicate(const std::vector<T>& v, const float toller
|
||||
template<>
|
||||
std::vector<vertex_t> poly_remove_duplicate<vertex_t>(const std::vector<vertex_t>& v, const float tollerance);
|
||||
|
||||
template <typename T>
|
||||
std::vector<std::string> split(const std::string& subject, T d, int max_split = 0)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
size_t start = 0;
|
||||
size_t n = subject.find_first_of(d);
|
||||
while (n != std::string::npos)
|
||||
{
|
||||
ret.push_back(subject.substr(start, n - start));
|
||||
start = n + 1;
|
||||
if (max_split && ret.size() == max_split)
|
||||
break;
|
||||
n = subject.find_first_of(d, start);
|
||||
}
|
||||
ret.push_back(subject.substr(start));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// from {origin, size} to {min, max}
|
||||
glm::vec4 rect_to_box(const glm::vec4& rect);
|
||||
// from {min, max} to {origin, size}
|
||||
@@ -88,7 +106,6 @@ uint32_t convert_rgb_long(glm::vec3 rgb);
|
||||
glm::vec3 convert_hsv2rgb(const glm::vec3 c);
|
||||
glm::vec3 convert_rgb2hsv(const glm::vec3 c);
|
||||
|
||||
std::vector<std::string> split(const std::string& subject, char d, int max_split = 0);
|
||||
std::string unescape(const std::string& s);
|
||||
std::wstring str2wstr(const std::string& str);
|
||||
std::string wstr2str(const std::wstring& wstr);
|
||||
|
||||
Reference in New Issue
Block a user