mirror of
https://github.com/luanti-org/luanti.git
synced 2025-12-17 04:25:26 +01:00
HUD: Text element color support (#14558)
This commit is contained in:
@@ -166,6 +166,21 @@ void EnrichedString::operator+=(const EnrichedString &other)
|
||||
}
|
||||
}
|
||||
|
||||
EnrichedString EnrichedString::getNextLine(size_t *pos) const
|
||||
{
|
||||
size_t str_pos = *pos;
|
||||
|
||||
// Split per line
|
||||
size_t str_nl = getString().find(L'\n', str_pos);
|
||||
if (str_nl == std::wstring::npos)
|
||||
str_nl = getString().size();
|
||||
EnrichedString line = substr(str_pos, str_nl - str_pos);
|
||||
str_pos += line.size() + 1;
|
||||
|
||||
*pos = str_pos;
|
||||
return line;
|
||||
}
|
||||
|
||||
EnrichedString EnrichedString::substr(size_t pos, size_t len) const
|
||||
{
|
||||
if (pos >= m_string.length())
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
// color. The color used will be the one from the last character.
|
||||
void addCharNoColor(wchar_t c);
|
||||
|
||||
EnrichedString getNextLine(size_t *pos) const;
|
||||
EnrichedString substr(size_t pos = 0, size_t len = std::string::npos) const;
|
||||
EnrichedString operator+(const EnrichedString &other) const;
|
||||
void operator+=(const EnrichedString &other);
|
||||
|
||||
Reference in New Issue
Block a user