Skip to content

Commit

Permalink
Add support for non-ASCII characters to chat console
Browse files Browse the repository at this point in the history
This still only supports 256 characters, but that's because
Irrlicht's clipboard handlers don't support wide characters.
  • Loading branch information
ShadowNinja committed Mar 3, 2016
1 parent 9dd38cf commit 8b006a1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/guiChatConsole.cpp
Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down

0 comments on commit 8b006a1

Please sign in to comment.