Translated using Weblate (Italian)
[oweals/minetest.git] / src / terminal_chat_console.cpp
index c86a960fa49d0dacc964f4569609d8c0d101f04e..9e3d33736190bc6ca2275d43b2ca84f37423c66a 100644 (file)
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "settings.h"
 #include "util/numeric.h"
 #include "util/string.h"
+#include "chat_interface.h"
 
 TerminalChatConsole g_term_console;
 
@@ -345,9 +346,12 @@ void TerminalChatConsole::step(int ch)
                if (p.first > m_log_level)
                        continue;
 
-               m_chat_backend.addMessage(
-                       utf8_to_wide(Logger::getLevelLabel(p.first)),
-                       utf8_to_wide(p.second));
+               std::wstring error_message = utf8_to_wide(Logger::getLevelLabel(p.first));
+               if (!g_settings->getBool("disable_escape_sequences")) {
+                       error_message = std::wstring(L"\x1b(c@red)").append(error_message)
+                               .append(L"\x1b(c@white)");
+               }
+               m_chat_backend.addMessage(error_message, utf8_to_wide(p.second));
        }
 
        // handle input
@@ -436,9 +440,8 @@ void TerminalChatConsole::draw_text()
                const ChatFormattedLine& line = buf.getFormattedLine(row);
                if (line.fragments.empty())
                        continue;
-               for (u32 i = 0; i < line.fragments.size(); ++i) {
-                       const ChatFormattedFragment& fragment = line.fragments[i];
-                       addstr(wide_to_utf8(fragment.text).c_str());
+               for (const ChatFormattedFragment &fragment : line.fragments) {
+                       addstr(wide_to_utf8(fragment.text.getString()).c_str());
                }
        }
 }