mirror of
https://github.com/luanti-org/luanti.git
synced 2025-12-26 08:15:22 +01:00
Preserve color across newline‑split log messages in chat (#16769)
This commit is contained in:
18
src/chat.cpp
18
src/chat.cpp
@@ -31,7 +31,7 @@ ChatBuffer::ChatBuffer(u32 scrollback):
|
||||
}
|
||||
}
|
||||
|
||||
void ChatBuffer::addLine(const std::wstring &name, const std::wstring &text)
|
||||
void ChatBuffer::addLine(const EnrichedString &name, const EnrichedString &text)
|
||||
{
|
||||
m_lines_modified = true;
|
||||
|
||||
@@ -774,13 +774,15 @@ ChatBackend::ChatBackend():
|
||||
void ChatBackend::addMessage(const std::wstring &name, std::wstring text)
|
||||
{
|
||||
// Note: A message may consist of multiple lines, for example the MOTD.
|
||||
text = translate_string(text);
|
||||
WStrfnd fnd(text);
|
||||
while (!fnd.at_end())
|
||||
{
|
||||
std::wstring line = fnd.next(L"\n");
|
||||
m_console_buffer.addLine(name, line);
|
||||
m_recent_buffer.addLine(name, line);
|
||||
EnrichedString ename(name);
|
||||
EnrichedString etext(text);
|
||||
|
||||
size_t str_pos = 0;
|
||||
while (str_pos < etext.size()) {
|
||||
EnrichedString line = etext.getNextLine(&str_pos);
|
||||
|
||||
m_console_buffer.addLine(ename, line);
|
||||
m_recent_buffer.addLine(ename, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
// Append chat line
|
||||
// Removes oldest chat line if scrollback size is reached
|
||||
void addLine(const std::wstring &name, const std::wstring &text);
|
||||
void addLine(const EnrichedString &name, const EnrichedString &text);
|
||||
|
||||
// Remove all chat lines
|
||||
void clear();
|
||||
|
||||
Reference in New Issue
Block a user