Merge branch releases/1.8 revisions 4722 to 4748 into trunk:

- CGUIEditBox and the GUI-Editor now convert pasted text correctly using mbstowcs.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4749 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2014-04-01 11:26:54 +00:00
parent f21b7b9cf8
commit fce2b8fdaf
3 changed files with 22 additions and 6 deletions

View File

@ -51,6 +51,7 @@ Changes in 1.9 (not yet released)
--------------------------
Changes in 1.8.2
- CGUIEditBox and the GUI-Editor now convert pasted text correctly using mbstowcs.
- C::B project files work again on newer Linux-distributions which have cleaned up their dev-lib dependencies.
- Makefile for the new IrrFontTool links now correctly to libfontconfig

View File

@ -344,17 +344,25 @@ bool CGUIEditBox::processKey(const SEvent& event)
const c8* p = Operator->getTextFromClipboard();
if (p)
{
// TODO: we should have such a function in core::string
size_t lenOld = strlen(p);
wchar_t *ws = new wchar_t[lenOld + 1];
size_t len = mbstowcs(ws,p,lenOld);
ws[len] = 0;
irr::core::stringw widep(ws);
delete[] ws;
if (MarkBegin == MarkEnd)
{
// insert text
core::stringw s = Text.subString(0, CursorPos);
s.append(p);
s.append(widep);
s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
if (!Max || s.size()<=Max) // thx to Fish FH for fix
{
Text = s;
s = p;
s = widep;
CursorPos += s.size();
}
}
@ -363,13 +371,13 @@ bool CGUIEditBox::processKey(const SEvent& event)
// replace text
core::stringw s = Text.subString(0, realmbgn);
s.append(p);
s.append(widep);
s.append( Text.subString(realmend, Text.size()-realmend) );
if (!Max || s.size()<=Max) // thx to Fish FH for fix
{
Text = s;
s = p;
s = widep;
CursorPos = realmbgn + s.size();
}
}

View File

@ -875,9 +875,16 @@ void CGUIEditWorkspace::CopySelectedElementXML()
void CGUIEditWorkspace::PasteXMLToSelectedElement()
{
// get clipboard data
core::stringc XMLText = Environment->getOSOperator()->getTextFromClipboard();
const char * p = Environment->getOSOperator()->getTextFromClipboard();
// convert to stringw
core::stringw wXMLText = XMLText.c_str();
// TODO: we should have such a function in core::string
size_t lenOld = strlen(p);
wchar_t *ws = new wchar_t[lenOld + 1];
size_t len = mbstowcs(ws,p,lenOld);
ws[len] = 0;
irr::core::stringw wXMLText(ws);
delete[] ws;
io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#");