diff options
author | ShadowNinja <shadowninja@minetest.net> | 2016-02-28 13:27:54 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2016-03-02 23:23:31 -0500 |
commit | 8b006a154b31a2fd0fb58e77db25debef4bb61e0 (patch) | |
tree | 440a623509b398c5b65194166023fcc8fc2adc22 | |
parent | 9dd38cf9682539ff5a2cf8e698a269cbcde3961a (diff) | |
download | minetest-8b006a154b31a2fd0fb58e77db25debef4bb61e0.tar.gz minetest-8b006a154b31a2fd0fb58e77db25debef4bb61e0.tar.bz2 minetest-8b006a154b31a2fd0fb58e77db25debef4bb61e0.zip |
Add support for non-ASCII characters to chat console
This still only supports 256 characters, but that's because
Irrlicht's clipboard handlers don't support wide characters.
-rw-r--r-- | src/guiChatConsole.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index d1351a0f7..d59937c31 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -536,7 +536,8 @@ bool GUIChatConsole::OnEvent(const SEvent& event) // Copy text to clipboard if (prompt.getCursorLength() <= 0) return true; - std::string selected = wide_to_narrow(prompt.getSelection()); + std::wstring wselected = prompt.getSelection(); + std::string selected(wselected.begin(), wselected.end()); Environment->getOSOperator()->copyToClipboard(selected.c_str()); return true; } @@ -553,8 +554,10 @@ bool GUIChatConsole::OnEvent(const SEvent& event) } IOSOperator *os_operator = Environment->getOSOperator(); const c8 *text = os_operator->getTextFromClipboard(); - if (text) - prompt.input(narrow_to_wide(text)); + if (!text) + return true; + std::basic_string<unsigned char> str((const unsigned char*)text); + prompt.input(std::wstring(str.begin(), str.end())); return true; } else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control) |