summaryrefslogtreecommitdiff
path: root/src/terminal_chat_console.cpp
diff options
context:
space:
mode:
authorEkdohibs <nathanael.courant@laposte.net>2016-05-31 17:30:11 +0200
committerEkdohibs <nathanael.courant@laposte.net>2016-05-31 17:34:29 +0200
commit14ef2b445adcec770defe1abf83af9d22ccf39d8 (patch)
treebe434ea35d6134f4e7b90a74283a21815ed079ee /src/terminal_chat_console.cpp
parent1d40385d4aacf0cbea4b19ff06940e8c9bebaf47 (diff)
downloadminetest-14ef2b445adcec770defe1abf83af9d22ccf39d8.tar.gz
minetest-14ef2b445adcec770defe1abf83af9d22ccf39d8.tar.bz2
minetest-14ef2b445adcec770defe1abf83af9d22ccf39d8.zip
Add colored text (not only colored chat).
Add documentation, move files to a proper place and avoid memory leaks. Make it work with most kind of texts, and allow backgrounds too.
Diffstat (limited to 'src/terminal_chat_console.cpp')
-rw-r--r--src/terminal_chat_console.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/terminal_chat_console.cpp b/src/terminal_chat_console.cpp
index c86a960fa..a8c4ebaef 100644
--- a/src/terminal_chat_console.cpp
+++ b/src/terminal_chat_console.cpp
@@ -345,9 +345,11 @@ 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 = L"\x1b(c@red)" + error_message + L"\x1b(c@white)";
+ }
+ m_chat_backend.addMessage(error_message, utf8_to_wide(p.second));
}
// handle input
@@ -438,7 +440,7 @@ void TerminalChatConsole::draw_text()
continue;
for (u32 i = 0; i < line.fragments.size(); ++i) {
const ChatFormattedFragment& fragment = line.fragments[i];
- addstr(wide_to_utf8(fragment.text).c_str());
+ addstr(wide_to_utf8(fragment.text.getString()).c_str());
}
}
}