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.
This commit is contained in:
ShadowNinja 2016-02-28 13:27:54 -05:00
parent 9dd38cf968
commit 8b006a154b

@ -536,7 +536,8 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
// Copy text to clipboard // Copy text to clipboard
if (prompt.getCursorLength() <= 0) if (prompt.getCursorLength() <= 0)
return true; 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()); Environment->getOSOperator()->copyToClipboard(selected.c_str());
return true; return true;
} }
@ -553,8 +554,10 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
} }
IOSOperator *os_operator = Environment->getOSOperator(); IOSOperator *os_operator = Environment->getOSOperator();
const c8 *text = os_operator->getTextFromClipboard(); const c8 *text = os_operator->getTextFromClipboard();
if (text) if (!text)
prompt.input(narrow_to_wide(text)); return true;
std::basic_string<unsigned char> str((const unsigned char*)text);
prompt.input(std::wstring(str.begin(), str.end()));
return true; return true;
} }
else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control) else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control)