]> git.lizzy.rs Git - minetest.git/blobdiff - src/chat.cpp
Optionally specify propagateSunlight area in calcLighting
[minetest.git] / src / chat.cpp
index 1135ccdf7486be295043e659a1d0685edcd241ea..b78b90145f2588e57d2de19fd5ad16cd2ba8e937 100644 (file)
@@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "chat.h"
 #include "debug.h"
-#include <cassert>
+#include "strfnd.h"
 #include <cctype>
 #include <sstream>
 #include "util/string.h"
@@ -151,7 +151,7 @@ void ChatBuffer::reformat(u32 cols, u32 rows)
        }
        else if (cols != m_cols || rows != m_rows)
        {
-               // TODO: Avoid reformatting ALL lines (even inivisble ones)
+               // TODO: Avoid reformatting ALL lines (even invisible ones)
                // each time the console size changes.
 
                // Find out the scroll position in *unformatted* lines
@@ -407,6 +407,15 @@ void ChatPrompt::input(wchar_t ch)
        m_nick_completion_end = 0;
 }
 
+void ChatPrompt::input(const std::wstring &str)
+{
+       m_line.insert(m_cursor, str);
+       m_cursor += str.size();
+       clampView();
+       m_nick_completion_start = 0;
+       m_nick_completion_end = 0;
+}
+
 std::wstring ChatPrompt::submit()
 {
        std::wstring line = m_line;
@@ -464,7 +473,7 @@ void ChatPrompt::historyNext()
        }
 }
 
-void ChatPrompt::nickCompletion(const std::list<std::wstring>& names, bool backwards)
+void ChatPrompt::nickCompletion(const std::list<std::string>& names, bool backwards)
 {
        // Two cases:
        // (a) m_nick_completion_start == m_nick_completion_end == 0
@@ -493,13 +502,13 @@ void ChatPrompt::nickCompletion(const std::list<std::wstring>& names, bool backw
 
        // find all names that start with the selected prefix
        std::vector<std::wstring> completions;
-       for (std::list<std::wstring>::const_iterator
+       for (std::list<std::string>::const_iterator
                        i = names.begin();
                        i != names.end(); ++i)
        {
-               if (str_starts_with(*i, prefix, true))
+               if (str_starts_with(narrow_to_wide(*i), prefix, true))
                {
-                       std::wstring completion = *i;
+                       std::wstring completion = narrow_to_wide(*i);
                        if (prefix_start == 0)
                                completion += L":";
                        completions.push_back(completion);