]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/terminal_chat_console.cpp
Merge pull request #59 from PrairieAstronomer/readme_irrlicht_change
[dragonfireclient.git] / src / terminal_chat_console.cpp
index c86a960fa49d0dacc964f4569609d8c0d101f04e..b12261c3b8bac71e3c0fb37690ed8756d3495ea1 100644 (file)
@@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#include <inttypes.h>
 #include "config.h"
 #if USE_CURSES
 #include "version.h"
@@ -25,6 +26,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 +347,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
@@ -394,7 +399,7 @@ void TerminalChatConsole::step(int ch)
        minutes = (float)minutes / 1000 * 60;
 
        if (m_game_time)
-               printw(" | Game %d Time of day %02d:%02d ",
+               printw(" | Game %" PRIu64 " Time of day %02d:%02d ",
                        m_game_time, hours, minutes);
 
        // draw text
@@ -436,9 +441,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());
                }
        }
 }